List of usage examples for java.util SortedSet add
boolean add(E e);
From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java
/** * @param t// www . j a v a2 s . c o m * @return ImportTables with Table equal to t. */ protected Vector<UploadTable> getUploadTable(Table t) { SortedSet<UploadTable> its = new TreeSet<UploadTable>(); for (UploadTable it : uploadTables) { if (it.getTable().equals(t)) { its.add(it); } } return new Vector<UploadTable>(its); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java
protected void doUploadSansUIMatchProcessingStuff(HashMap<UploadTable, HashMap<Integer, Integer>> uploadedRecs, List<Pair<Integer, List<UploadTableMatchInfo>>> matchInfos) { List<UploadTableMatchInfo> mis = new ArrayList<UploadTableMatchInfo>(); List<UploadTable> prevMatches = new ArrayList<UploadTable>(); for (UploadTable t : uploadTables) { if (t.isCheckMatchInfo() && !t.isSkipMatching()) { Integer[] mCount = t.getMatchCountForCurrentRow(); SortedSet<UploadedRecordInfo> urs = t.getUploadedRecs() == null || t.getUploadedRecs().size() == 0 ? new TreeSet<UploadedRecordInfo>() : t.getUploadedRecs().tailSet(new UploadedRecordInfo(null, rowUploading, 0, null)); if (urs.size() == 0) { urs.add(new UploadedRecordInfo(null, rowUploading, 0, null)); }/*from w w w.j a va2s . com*/ for (UploadedRecordInfo ur : urs) { Integer seq = ur == null ? 0 : ur.getSeq(); List<Integer> colIdxs = new ArrayList<Integer>(); for (UploadField uf : t.getUploadFields().get(seq)) { if (uf.getIndex() != -1) { colIdxs.add(uf.getIndex()); } } HashMap<Integer, Integer> recs = mCount[seq] > 1 ? null : uploadedRecs.get(t); if ((mCount[seq] == 0 && t.getCurrentRecord(seq) != null) || mCount[seq] > 1) { //a record was added or multiple matches addMatchInfo(mis, prevMatches, t, mCount[seq], colIdxs); if (mCount[seq] == 0) { if (recs != null && ur != null) { recs.put(ur.getKey(), ur.getSeq()); } else { System.out.println( "Error: " + t + " is not enhashed or beset for row " + rowUploading); } } } else if (mCount[seq] == 1) { //figure out if record was added earlier in the upload if (recs != null && t.getCurrentRecord(seq) != null) { Integer oseq = recs.get(t.getCurrentRecord(seq).getId()); if (oseq != null) { addMatchInfo(mis, prevMatches, t, 0, colIdxs); } } else { System.out.println("Error: " + t + " is not enhashed or beset for row " + rowUploading); } } else { //what the hell? } } } } if (mis.size() > 0) { matchInfos.add(new Pair<Integer, List<UploadTableMatchInfo>>(rowUploading, mis)); } }
From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java
/** * Builds form for upload UI.//from w w w .j av a2s. c o m */ protected void buildMainUI() { mainPanel = new UploadMainPanel(isUpdateUpload()); SortedSet<UploadInfoRenderable> uts = new TreeSet<UploadInfoRenderable>(); for (UploadTable ut : uploadTables) { UploadInfoRenderable render = new UploadInfoRenderable(ut); if (uts.contains(render)) { for (UploadInfoRenderable r : uts) { if (r.equals(render)) { r.addTable(ut); break; } } } else { uts.add(new UploadInfoRenderable(ut)); } } mainPanel.addAffectedTables(uts.iterator()); mainPanel.setActionListener(this); }
From source file:edu.mayo.informatics.lexgrid.convert.directConversions.protegeOwl.ProtegeOwl2LG.java
/** * Resolve and assign all property information contained by the given RDF * resource to the EMF Entity.//ww w .j a v a2 s. com * * @param lgEntity * @param rdfResource * * Last updated: 05/28/2008 */ protected void resolveEntityProperties(Entity lgEntity, RDFResource rdfResource) { String rdfName = rdfResource.getLocalName(); // Temporary container for EMF properties. // Note: The EMF object does not enforce order. However, the XSD models // have required properties to occur in the XML in a specific order. // The comparator ensures a compatible order is maintained. SortedSet sortedProps = new TreeSet(propertyComparator); // Counters to use in property ID assignment to keep things unique // and track assigned presentation count. int i = 0; int presentationCount = 0; // Start with properties from RDF-defined property set ... for (Iterator props = rdfResource.getRDFProperties().iterator(); props.hasNext();) { RDFProperty prop = (RDFProperty) props.next(); String propName = getRDFResourceLocalName(prop); // Do we care about this rdf property? if (isNoop(propName) || isNoopNamespace(propName)) continue; // Do we have an EMF class match? String propClass = owlDatatypeName2lgPropClass_.get(propName); if (isNoop(propClass)) continue; // Determine the EMF property name and datatype ... String lgDType = owlDatatypeName2lgDatatype_.get(propName); String lgLabel = owlDatatypeName2label_.get(propName); // Interpret RDF property value(s) ... for (Iterator values = rdfResource.getPropertyValues(prop).iterator(); values.hasNext();) { Object value = values.next(); String resolvedText = resolveRDFText(rdfResource, value); String lang = null; if (value instanceof DefaultRDFSLiteral) lang = ((DefaultRDFSLiteral) value).getLanguage(); // Special case for handling concept code and status, which are // set directly as attributes on the LexGrid concept. if (propName.matches(prefManager.getMatchPattern_conceptCode())) { lgEntity.setEntityCode(resolvedText); } else if (lgLabel != null && lgLabel.matches(prefManager.getMatchPattern_conceptStatus())) { lgEntity.setStatus(resolvedText); if (resolvedText.matches(prefManager.getMatchPattern_inactiveStatus())) lgEntity.setIsActive(false); } // Otherwise instantiate a new EMF property and add the new // property to the list to eventually add to the concept. else { Property newProp = resolveProp(prop, propClass, generatePropertyID(++i), lgLabel, lgDType, prop.getNamespace(), resolvedText, lang); if (newProp.getValue() != null) { sortedProps.add(newProp); if (newProp instanceof Presentation) presentationCount++; } } } } // Indicate whether the concept is primitive (no equivalent classes) ... Collection values = rdfResource .getPropertyValues(rdfResource.getOWLModel().getOWLEquivalentClassProperty()); if (values == null || values.isEmpty()) { Property lgProp = CreateUtils.createProperty(generatePropertyID(++i), prefManager.getPropertyName_primitive(), "true", lgSupportedMappings_, null, null); sortedProps.add(lgProp); } else { Property lgProp = CreateUtils.createProperty(generatePropertyID(++i), prefManager.getPropertyName_primitive(), "false", lgSupportedMappings_, null, null); sortedProps.add(lgProp); } // The LexGrid model requires a matching presentation for the entity // description. If no presentations exist, manufacture a default to // satisfy the requirement. If created, the name of the new property // is set to indicate where the value was found. Also support // explicit requests for "rdfs:label" as the preferred property. boolean generatePreferred = prefManager.getPrioritized_presentation_names().size() == 0 || ProtegeOwl2LGConstants.PROPNAME_RDFS_LABEL .equalsIgnoreCase(prefManager.getPrioritized_presentation_names().get(0)) || presentationCount == 0; if (generatePreferred) { String entityDesc = lgEntity.getEntityDescription().getContent(); sortedProps.add(CreateUtils.createPresentation(generatePropertyID(++i), rdfName.equals(entityDesc) ? ProtegeOwl2LGConstants.PROPNAME_RDF_ID : ProtegeOwl2LGConstants.PROPNAME_RDFS_LABEL, entityDesc, true, lgSupportedMappings_, null, null)); } // Track assignment of preferred presentation and definition. // For presentation, check to see if preference was set above. boolean assignedPreferredPres = generatePreferred; boolean assignedPreferredDefn = false; // Iterate through properties; stop when complete or if both a preferred // presentation and definition have been assigned ... for (Iterator props = sortedProps.iterator(); props.hasNext() && !(assignedPreferredPres && assignedPreferredDefn);) { Object prop = props.next(); if (!assignedPreferredPres && (prop instanceof Presentation)) { // Tag the property Presentation pres = (Presentation) prop; pres.setIsPreferred(Boolean.TRUE); // Entity description on concept should match preferred // presentation. EntityDescription ed = new EntityDescription(); ed.setContent(((Presentation) prop).getValue().getContent()); lgEntity.setEntityDescription(ed); // Remember that a preferred presentation was assigned ... assignedPreferredPres = true; } if (!assignedPreferredDefn && (prop instanceof Definition)) { // Tag the definition ((Definition) prop).setIsPreferred(Boolean.TRUE); // Remember that a preferred definition was assigned ... assignedPreferredDefn = true; } } // Updated on 05/28/2008: It was decided that we also need to // hook all the OWLDatatypeProperties for a particular concept // as "Concept Properties". This will assist in the visualization // of the concepts in a browser. The idea is that the "concept" is // stored as the "Range", and the "PropertyText" corresponds to the // "range" of the property. However, note that these // OWLDatatypeProperties are also represented in the "Relations" // container as "Associations", since they may have relations // between themselves: e.g., subPropertyOf relations. // OWLNamedClass myOWLNamedClass = (OWLNamedClass) rdfResource; // Added on 01/14/2009 by Satya as Concept and its // properties can be created for OWLObjectProperty's as well. if (rdfResource instanceof RDFSNamedClass) { RDFSNamedClass rdfsNamedClass = (RDFSNamedClass) rdfResource; for (Iterator classProps = rdfsNamedClass.getAssociatedProperties().iterator(); classProps.hasNext();) { RDFProperty prop = (RDFProperty) classProps.next(); if (prop instanceof OWLDatatypeProperty) { String propertyName = getFromLastIndexOfColonOrHash(prop.getBrowserText()); RDFSDatatype range = prop.getRangeDatatype(); if (range != null) { String propertyRangeName = getRDFResourceLocalName(range); Property lgProp = CreateUtils.createProperty(generatePropertyID(++i), propertyName, propertyRangeName, lgSupportedMappings_, prop.getURI(), null); sortedProps.add(lgProp); } } } } // Now add all the sorted properties to the concept. for (Iterator<? extends Property> lgProps = sortedProps.iterator(); lgProps.hasNext();) { Property lgProp = lgProps.next(); lgEntity.addAnyProperty(lgProp); } }
From source file:edu.mayo.informatics.lexgrid.convert.directConversions.owlapi.OwlApi2LG.java
/** * Resolve and assign all property information contained by the given RDF * resource to the EMF Entity.//from w ww . ja v a 2 s . c o m * * @param lgEntity * @param owlClass * * Last updated: 05/28/2008 */ protected void resolveEntityProperties(Entity lgEntity, OWLEntity owlClass) { String rdfName = getLocalName(owlClass); // Temporary container for EMF properties. // Note: The EMF object does not enforce order. However, the XSD models // have required properties to occur in the XML in a specific order. // The comparator ensures a compatible order is maintained. SortedSet sortedProps = new TreeSet(propertyComparator); // Counters to use in property ID assignment to keep things unique // and track assigned presentation count. int i = 0; int presentationCount = 0; for (OWLAnnotationAssertionAxiom annotationAxiom : ontology .getAnnotationAssertionAxioms(owlClass.getIRI())) { String propName = getLocalName(annotationAxiom.getProperty()); // Do we care about this rdf property? if (isNoop(propName) || isNoopNamespace(propName)) continue; // Do we have an class match? String propClass = owlDatatypeName2lgPropClass_.get(propName); if (isNoop(propClass)) continue; // Determine the property name and datatype ... String lgDType = owlDatatypeName2lgDatatype_.get(propName); String lgLabel = owlDatatypeName2label_.get(propName); OWLAnnotationValue value = annotationAxiom.getValue(); String resolvedText = ""; if (value instanceof OWLLiteral) { OWLLiteral literal = (OWLLiteral) value; resolvedText = literal.getLiteral(); } else if (value instanceof IRI) { IRI iri_v = (IRI) value; resolvedText = iri_v.toString(); } else { resolvedText = renderer.render(value); } // Interpret RDF property value(s) ... // Special case for handling concept code and status, which are // set directly as attributes on the LexGrid concept. if (propName.matches(prefManager.getMatchPattern_conceptCode())) { lgEntity.setEntityCode(resolvedText); } else if (lgLabel != null && lgLabel.matches(prefManager.getMatchPattern_conceptStatus())) { lgEntity.setStatus(resolvedText); if (resolvedText.matches(prefManager.getMatchPattern_inactiveStatus())) lgEntity.setIsActive(false); } // Otherwise instantiate a new EMF property and add the new // property to the list to eventually add to the concept. else { Property newProp = resolveProp(annotationAxiom, propClass, generatePropertyID(++i), lgLabel, lgDType, getNameSpace(annotationAxiom.getProperty()), resolvedText, null); if (newProp.getValue() != null) { sortedProps.add(newProp); if (newProp instanceof Presentation) presentationCount++; } } } // The LexGrid model requires a matching presentation for the entity // description. If no presentations exist, manufacture a default to // satisfy the requirement. If created, the name of the new property // is set to indicate where the value was found. Also support // explicit requests for "rdfs:label" as the preferred property. boolean generatePreferred = prefManager.getPrioritized_presentation_names().size() == 0 || OwlApi2LGConstants.PROPNAME_RDFS_LABEL .equalsIgnoreCase(prefManager.getPrioritized_presentation_names().get(0)) || presentationCount == 0; if (generatePreferred) { String entityDesc = lgEntity.getEntityDescription().getContent(); sortedProps.add(CreateUtils.createPresentation(generatePropertyID(++i), rdfName.equals(entityDesc) ? OwlApi2LGConstants.PROPNAME_RDF_ID : OwlApi2LGConstants.PROPNAME_RDFS_LABEL, entityDesc, true, lgSupportedMappings_, null, null)); } // Track assignment of preferred presentation and definition. // For presentation, check to see if preference was set above. boolean assignedPreferredPres = generatePreferred; boolean assignedPreferredDefn = false; // Iterate through properties; stop when complete or if both a preferred // presentation and definition have been assigned ... for (Iterator props = sortedProps.iterator(); props.hasNext() && !(assignedPreferredPres && assignedPreferredDefn);) { Object prop = props.next(); if (!assignedPreferredPres && (prop instanceof Presentation)) { // Tag the property Presentation pres = (Presentation) prop; pres.setIsPreferred(Boolean.TRUE); // Entity description on concept should match preferred // presentation. EntityDescription ed = new EntityDescription(); ed.setContent(((Presentation) prop).getValue().getContent()); lgEntity.setEntityDescription(ed); // Remember that a preferred presentation was assigned ... assignedPreferredPres = true; } if (!assignedPreferredDefn && (prop instanceof Definition)) { // Tag the definition ((Definition) prop).setIsPreferred(Boolean.TRUE); // Remember that a preferred definition was assigned ... assignedPreferredDefn = true; } } // Updated on 05/28/2008: It was decided that we also need to // hook all the OWLDatatypeProperties for a particular concept // as "Concept Properties". This will assist in the visualization // of the concepts in a browser. The idea is that the "concept" is // stored as the "Range", and the "PropertyText" corresponds to the // "range" of the property. However, note that these // OWLDatatypeProperties are also represented in the "Relations" // container as "Associations", since they may have relations // between themselves: e.g., subPropertyOf relations. // OWLNamedClass myOWLNamedClass = (OWLNamedClass) rdfResource; // Added on 01/14/2009 by Satya as Concept and its // properties can be created for OWLObjectProperty's as well. for (OWLDatatype prop : owlClass.getDatatypesInSignature()) { String propertyName = getLocalName(prop); DataRangeType range = prop.getDataRangeType(); if (range != null) { String propertyRangeName = range.getName(); Property lgProp = CreateUtils.createProperty(generatePropertyID(++i), propertyName, propertyRangeName, lgSupportedMappings_, prop.getIRI().toString(), null); sortedProps.add(lgProp); } } //Giving the One of data properties full definition status. for (OWLDataProperty prop : owlClass.getDataPropertiesInSignature()) { String propertyName = prop.getIRI().getFragment(); Set<OWLDataRange> ranges = prop.getRanges(ontology); if (!ranges.isEmpty()) { OWLDataRange range = prop.getRanges(ontology).iterator().next(); if (range instanceof OWLDataOneOf) { OWLDataOneOfImpl oneOf = (OWLDataOneOfImpl) range; for (OWLLiteral lit : oneOf.getValues()) { String literal = lit.getLiteral(); Property lgProp = CreateUtils.createDefinition(generatePropertyID(++i), propertyName, literal, false, lgSupportedMappings_, prop.getIRI().toString(), ""); sortedProps.add(lgProp); } } } } // Now add all the sorted properties to the concept. for (Iterator<? extends Property> lgProps = sortedProps.iterator(); lgProps.hasNext();) { Property lgProp = lgProps.next(); lgEntity.addAnyProperty(lgProp); } }
From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java
/** * @param solutions/*from w w w .j a v a2 s . co m*/ * @return a copy of solutions with only duplicate solutions (i.e same tables, different order) removed. */ protected Vector<Vector<Table>> removeDuplicateSolutions(Vector<Vector<Table>> solutions) { SortedSet<Vector<Table>> sorted = new TreeSet<Vector<Table>>(new Comparator<Vector<Table>>() { /* * (non-Javadoc) * * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ public int compare(Vector<Table> o1, Vector<Table> o2) { int size1 = o1 == null ? 0 : o1.size(); int size2 = o2 == null ? 0 : o2.size(); if (o1 != null && o2 != null && size1 == size2) { if (o1.containsAll(o2)) { return 0; } // else if (o1.size() == 0) return 0; int id1 = o1.get(0).getTableInfo().getTableId(); int id2 = o2.get(0).getTableInfo().getTableId(); return id1 < id2 ? -1 : (id1 == id2 ? 0 : 1); } return size1 < size2 ? -1 : 1; } }); for (Vector<Table> solution : solutions) { sorted.add(solution); } Vector<Vector<Table>> result = new Vector<Vector<Table>>(); result.addAll(sorted); return result; }
From source file:br.gov.jfrj.siga.ex.bl.ExBL.java
private void concluirAlteracaoParcial(ExMobil mob) { SortedSet<ExMobil> set = threadAlteracaoParcial.get(); if (set == null) { threadAlteracaoParcial.set(new TreeSet<ExMobil>()); set = threadAlteracaoParcial.get(); }/*from www .j a v a 2s . c o m*/ if (mob.doc() != null) { atualizarMarcas(mob.doc()); atualizarVariaveisDenormalizadas(mob.doc()); } set.add(mob); }
From source file:br.gov.jfrj.siga.ex.bl.ExBL.java
private void acrescentarMarca(SortedSet<ExMarca> set, ExMobil mob, Long idMarcador, Date dt, DpPessoa pess, DpLotacao lota) {//w w w. jav a2 s. co m ExMarca mar = new ExMarca(); mar.setExMobil(mob); mar.setCpMarcador(dao().consultar(idMarcador, CpMarcador.class, false)); if (pess != null) mar.setDpPessoaIni(pess.getPessoaInicial()); if (lota != null) mar.setDpLotacaoIni(lota.getLotacaoInicial()); mar.setDtIniMarca(dt); set.add(mar); }
From source file:br.gov.jfrj.siga.ex.bl.ExBL.java
private void acrescentarMarcaTransferencia(SortedSet<ExMarca> set, ExMobil mob, Long idMarcador, Date dtIni, Date dtFim, DpPessoa pess, DpLotacao lota) { ExMarca mar = new ExMarca(); mar.setExMobil(mob);/* www. jav a 2 s .co m*/ mar.setCpMarcador(dao().consultar(idMarcador, CpMarcador.class, false)); if (pess != null) mar.setDpPessoaIni(pess.getPessoaInicial()); if (lota != null) mar.setDpLotacaoIni(lota.getLotacaoInicial()); mar.setDtIniMarca(dtIni); mar.setDtFimMarca(dtFim); set.add(mar); }