public void checkAttributeNameisNumerical() throws IncorrectAttributeValueType { if (!Number.class.isAssignableFrom(att.getDataType())) { throw new IncorrectAttributeValueType(att.getDataType() + " is not a type of number and therefore can not be used to rank paths"); } }
/** * @throws IncorrectAttributeValueType i.e the attribute value is not a number */ private void checkAttributeNameisNumerical() throws IncorrectAttributeValueType { if (!Number.class.isAssignableFrom(att.getDataType())) { throw new IncorrectAttributeValueType(att.getDataType() + " is not a type of number and therefore can not be used to rank paths"); } }
/** * @param attn * an attribute name to bind the class for * @return if this contained a valid object for serialization */ public synchronized boolean addAttribute(AttributeName attn) { Class<?> dataType = attn.getDataType(); if (!dataType.isInterface() // don't add interfaces && getHolder(dataType) == null) {// or something that has a // holder attributes.put(attn, dataType); return true; } return false; }
@Override public void actionPerformed(ActionEvent e) { if (box.getSelectedItem() instanceof AttributeName) { AttributeName an = (AttributeName) box.getSelectedItem(); Class<?> clazz = an.getDataType(); if (!Comparable.class.isAssignableFrom(clazz)) { JOptionPane .showMessageDialog( OVTK2Desktop.getInstance().getMainFrame(), "Selected values are not comparable. Please make a different selection.", "Error in value selection", JOptionPane.ERROR_MESSAGE); } } }
/** * Extracts all attribute names corresponding to GDSs with * <code>Double</code> values, that can be used as edge weights. * * @return an array of attribute name IDs. */ private String[] getAttributeNames() { Vector<String> v = new Vector<String>(); v.add(defVal); for (AttributeName a : graph.getMetaData().getAttributeNames()) { if (Number.class.isAssignableFrom(a.getDataType())) v.add(a.getId()); } return v.toArray(new String[v.size()]); }
/** * adds all suitable attribute names to the jlist. */ private void addAttributeNamesToList() { for (AttributeName attn : graph.getMetaData().getAttributeNames()) { // should also accept list types now. if (Comparable.class.isAssignableFrom(attn.getDataType()) || Collection.class.isAssignableFrom(attn.getDataType())) { Set<ONDEXConcept> concepts = graph.getConceptsOfAttributeName(attn); if (concepts != null && concepts.size() > 0 && !AppearanceSynchronizer.attr.contains(attn.getId())) anlm.addAttributeName(attn); } } }
/** * Extracts all attribute names corresponding to GDSs with * <code>Double</code> values, that can be used as edge weights. * * @return an array of attribute name IDs. */ private String[] getAttributeNames() { Vector<String> v = new Vector<String>(); v.add(defVal); for (AttributeName a : graph.getMetaData().getAttributeNames()) { if (Number.class.isAssignableFrom(a.getDataType()) && !AppearanceSynchronizer.attr.contains(a.getId())) v.add(a.getId()); } return v.toArray(new String[v.size()]); }
/** * adds all suitable attribute names to the jlist. */ private void addAttributeNamesToList() { for (AttributeName attn : graph.getMetaData().getAttributeNames()) { // should also accept list types now. if (Comparable.class.isAssignableFrom(attn.getDataType()) || Collection.class.isAssignableFrom(attn.getDataType())) { Set<ONDEXConcept> concepts = graph .getConceptsOfAttributeName(attn); if (concepts != null && concepts.size() > 0 && !AppearanceSynchronizer.attr.contains(attn.getId())) anlm.addAttributeName(attn); } } }
/** * Extracts all attribute names corresponding to GDSs with * <code>Double</code> values, that can be used as edge weights. * * @return an array of attribute name IDs. */ private String[] getAttributeNames() { Vector<String> v = new Vector<String>(); v.add(defVal); for (AttributeName a : graph.getMetaData().getAttributeNames()) { if (Number.class.isAssignableFrom(a.getDataType()) && !AppearanceSynchronizer.attr.contains(a.getId())) { if (graph.getRelationsOfAttributeName(a).size() > 0) v.add(a.getId()); } } String[] sorted = v.toArray(new String[v.size()]); Arrays.sort(sorted); return sorted; }
private AttributeName getAttributeName(ONDEXGraph aog, String str, Class<?> cls) { if (str.equals(WEIGHT)) str = NWBWeight; AttributeName an = aog.getMetaData().getAttributeName(str); if (an == null) { an = aog.getMetaData().getFactory().createAttributeName(str, cls); } else if (!an.getDataType().isAssignableFrom(cls) && !Number.class.isAssignableFrom(cls)) { System.err .println("Error: Attribute name " + str + " is already part of Ondex controlled vocabulary with " + an.getDataType() + ". Change NWB " + cls + " to conform or choose a differnt name for this attribute."); return null; } return an; }
/** * Fills attribute selection list */ private void addAttributeNamesToList() { for (AttributeName attn : graph.getMetaData().getAttributeNames()) { if (Comparable.class.isAssignableFrom(attn.getDataType())) { Set<ONDEXConcept> concepts = graph.getConceptsOfAttributeName(attn); if (concepts != null && concepts.size() > 0 && !AppearanceSynchronizer.attr.contains(attn.getId())) anlm.addAttributeName(attn); } } }
private void init() { textDist = new JTextField(constDist + ""); textMulti = new JTextField(multi + ""); textHorizontal = new JTextField(horizontalSpacing + ""); textVertical = new JTextField(verticalSpacing + ""); ONDEXJUNGGraph aog = (ONDEXJUNGGraph) graph; // drop down boxes for attribute names Collection<AttributeName> ans = aog.getMetaData().getAttributeNames(); // Category can be anything dropCategory = new JComboBox(ans.toArray()); // only integer attribute names ArrayList<AttributeName> integers = new ArrayList<AttributeName>(); for (AttributeName an : ans) { if (Integer.class.isAssignableFrom(an.getDataType())) integers.add(an); } dropPosition = new JComboBox(integers.toArray()); // default values AttributeName anPos = aog.getMetaData().getAttributeName("BEGIN"); AttributeName anCat = aog.getMetaData().getAttributeName("Chromosome"); // set if defaults exists, otherwise random choice if (anPos != null && anCat != null) { dropPosition.setSelectedItem(anPos); dropCategory.setSelectedItem(anCat); } }
if (!(getOfType().getDataType().isAssignableFrom(value.getClass()))) throw new WrongParameterException( Config.properties.getProperty("GDS.ObjectTypeMismatch"));
private void createAttributes(ONDEXEntity entity, Map<String, String> attributes) throws ParsingFailedException { String type = attributes.get("type"); Class<?> clazz = null; Object value = null; if (type.equals("string")) { clazz = String.class; value = attributes.get("value"); } else if (type.equals("real")) { clazz = Double.class; value = Double.parseDouble(attributes.get("value")); } else if (type.equals("integer")) { clazz = Integer.class; value = Integer.parseInt(attributes.get("value")); } String name = attributes.get("name").replaceAll(" ", "_"); AttributeName an = graph.getMetaData().getAttributeName(name); if (an == null) { an = graph.getMetaData().getFactory() .createAttributeName(name, clazz); } else if (!an.getDataType().equals(clazz)) { throw new ParsingFailedException( "inconsistent use of attribute names"); } if (entity instanceof ONDEXConcept) { ((ONDEXConcept) entity).createAttribute(an, value, false); } else if (entity instanceof ONDEXRelation) { ((ONDEXRelation) entity).createAttribute(an, value, false); } }
/** * Fills list of concept attribute names. * */ private void populateConceptAttributeNameList() { anlmConcepts.clearList(); for (AttributeName an : graph.getMetaData().getAttributeNames()) { Set<ONDEXConcept> concepts = graph.getConceptsOfAttributeName(an); if (concepts != null) { // check concepts exists on this AttributeName Class<?> cl = an.getDataType(); if (concepts.size() > 0 && Number.class.isAssignableFrom(cl) && !AppearanceSynchronizer.attr.contains(an.getId())) { anlmConcepts.addAttributeName(an); } } } anlmConcepts.refresh(); listConceptAttributeNames.setEnabled(!anlmConcepts.isEmpty()); listConceptAttributeNames.repaint(); }
/** * Fills list of relation attribute names. * */ private void populateRelationAttributeNameList() { anlmRelations.clearList(); for (AttributeName an : graph.getMetaData().getAttributeNames()) { Set<ONDEXRelation> relations = graph .getRelationsOfAttributeName(an); if (relations != null) { // check relations exists on this AttributeName Class<?> cl = an.getDataType(); if (relations.size() > 0 && Number.class.isAssignableFrom(cl) && !AppearanceSynchronizer.attr.contains(an.getId())) { anlmRelations.addAttributeName(an); } } } anlmRelations.refresh(); listRelationAttributeNames.setEnabled(!anlmRelations.isEmpty()); listRelationAttributeNames.repaint(); }
/** * Creates table for TableModel containing relation Attribute. * * @param graph * current ONDEXGraph * @param dm * TableModel with relation Attribute */ public RelationGDSTable(TableModel dm, ONDEXGraph graph) { super(dm); this.setAutoCreateRowSorter(true); TableRowSorter<?> sorter = (TableRowSorter<?>) this.getRowSorter(); sorter.setStringConverter(new EditorTableStringConverter()); sorter.setComparator(0, new ONDEXEntityComparator()); rgdsTableCellEditor = new RelationGDSTableCellEditor(graph); // check for number Attribute attributes for (int i = 0; i < dm.getColumnCount(); i++) { AttributeName an = graph.getMetaData().getAttributeName(dm.getColumnName(i)); if (an != null && Number.class.isAssignableFrom(an.getDataType())) { Class<?> cl = an.getDataType(); if (Number.class.isAssignableFrom(cl)) { sorter.setComparator(i, new GDSNumberComparator()); } } } }
/** * @param attNames * @param omd * copy from MetaData * @param nomd * copy to MetaData */ private void copyAttributeNames(Iterable<AttributeName> attNames, ONDEXGraphMetaData omd, ONDEXGraphMetaData nomd) { // "specializations_of"s that occur before there specialisation HashSet<AttributeName> atDependencyNotResolved = new HashSet<AttributeName>(); for (AttributeName att : attNames) { AttributeName spec = att.getSpecialisationOf(); AttributeName newSpec = null; if (spec != null) { newSpec = nomd.getAttributeName(spec.getId()); if (newSpec == null) { atDependencyNotResolved.add(att); continue; } } if (!nomd.checkAttributeName(att.getId())) nomd.createAttributeName(att.getId(), att.getFullname(), att .getDescription(), att.getUnit(), att.getDataType(), newSpec); } if (atDependencyNotResolved.size() > 0) { copyAttributeNames(atDependencyNotResolved, omd, nomd); } }
COMMUTILS.assertResource ( graphModel, myiri, iri ( "rdfs:subPropertyOf" ), parentIri ); String dataTypeIri = Optional.ofNullable ( aname.getDataType () ) .map ( clazz -> XsdMapper.dataTypeIri ( clazz ) ) .orElse ( null );
/** * Creates table for TableModel containing concept Attribute. * * @param graph * current ONDEXGraph * @param dm * TableModel with concept Attribute */ public ConceptGDSTable(TableModel dm, ONDEXGraph graph) { super(dm); this.setAutoCreateRowSorter(true); TableRowSorter<?> sorter = (TableRowSorter<?>) this.getRowSorter(); sorter.setStringConverter(new EditorTableStringConverter()); sorter.setComparator(0, new ONDEXEntityComparator()); cgdsTableCellEditor = new ConceptGDSTableCellEditor(graph); // check for number Attribute attributes for (int i = 0; i < dm.getColumnCount(); i++) { AttributeName an = graph.getMetaData().getAttributeName(dm.getColumnName(i)); if (an != null) { Class<?> cl = an.getDataType(); if (Number.class.isAssignableFrom(cl)) { sorter.setComparator(i, new GDSNumberComparator()); } } } }