@Override public boolean remove(Object o) { boolean result = false; if (o instanceof MappingNode) { result = nodes.remove(o); String list = ((MappingNode)o).getList(); lists.remove(list); nodesByList.remove(list); } // if linear node return result; }// remove
/**Gets the urls from this definition * @return a list of all the ontology urls present in this mapping def */ public List<String> getUrls() { Set<String> result = new HashSet<String>(); for ( int i = 0 ; i < nodes.size() ; i++ ) { result.add(nodes.get(i).getOntologyID()); } // for return new ArrayList<String>(result); } // getUrls()
MappingNode mappingnode = mappingDefinition.getNodeByList(s); if(null != mappingnode) { lookup1.oClass = mappingnode.getClassID(); lookup1.ontology = mappingnode.getOntologyID();
/** * Stores the mapping definition * @throws ResourceInstantiationException if store fails. */ public void store()throws ResourceInstantiationException{ if (null == url) { throw new ResourceInstantiationException("URL not set (null)."); } try { File fileo = Files.fileFromURL(url); fileo.delete(); BufferedWriter mapWriter = new BufferedWriter(new FileWriter(fileo)); for (int index = 0 ; index < nodes.size() ; index++) { mapWriter.write(nodes.get(index).toString()); mapWriter.newLine(); } mapWriter.close(); } catch (IOException ioe) { throw new ResourceInstantiationException(ioe); } } //store();
/**Loads the mapping definition * @throws ResourceInstantiationException if load fails. */ public void load() throws ResourceInstantiationException,InvalidFormatException { if (null == url) { throw new ResourceInstantiationException("URL not set (null)."); } try { BufferedReader mapReader = new BomStrippingInputStreamReader((url).openStream(), ENCODING); String line; MappingNode node; while (null != (line = mapReader.readLine())) { if (0 != line.trim().length()) { node = new MappingNode(line); this.add(node); } // if } //while mapReader.close(); } catch (InvalidFormatException ife){ throw new InvalidFormatException(url,"on load"); } catch (IOException ioe) { throw new ResourceInstantiationException(ioe); } } // load();
MappingNode mnode = mappingDefinition.getNodeByList(defaultLookup.list); if (null!=mnode){ defaultLookup.oClass = mnode.getClassID(); defaultLookup.ontology = mnode.getOntologyID(); MappingNode mnode = mappingDefinition.getNodeByList(lookup.list); if(null != mnode) { lookup.oClass = mnode.getClassID(); lookup.ontology = mnode.getOntologyID();
@Override public MappingNode remove(int index) { MappingNode result = null; result = nodes.remove(index); if (null!=result) { String list = result.getList(); lists.remove(list); nodesByList.remove(list); } return result; }
/** * adds a new node at the specified position, only if its list is new and uniquely mapped to this node. * @param o a node * @param index position in the list */ @Override public void add(int index, MappingNode o) { String list = o.getList(); if(!nodesByList.containsKey(list)) { nodes.add(index, o); nodesByList.put(list, o); lists.add(list); } // if unique } // add()
/** * adds a new node, only if its list is new and uniquely mapped to this node. * @param o a node * @return true if the list of node is not already mapped with another node. */ @Override public boolean add(MappingNode o) { boolean result = false; String list = o.getList(); if(!nodesByList.containsKey(list)) { result = nodes.add(o); nodesByList.put(list, o); lists.add(list); } // if unique return result; } // add()