/** * Gets an AttributeDescriptor for a field of the given name. Returns null if * not found. Does NOT look in any superclasses or interfaces. * * @param name the name of an AttributeDescriptor to find * @return an AttributeDescriptor */ public AttributeDescriptor getAttributeDescriptorByName(String name) { return getAttributeDescriptorByName(name, false); }
/** * Gets an AttributeDescriptor for a field of the given name. Returns null if * not found. Does NOT look in any superclasses or interfaces. * * @param name the name of an AttributeDescriptor to find * @return an AttributeDescriptor */ public AttributeDescriptor getAttributeDescriptorByName(String name) { return getAttributeDescriptorByName(name, false); }
/** * Return true if the name parameter is an attribute of the class for this Item or if * the Model or the className of this Item haven't been set. * * @param name the attribute name * @return true if the name is a valid attribute name */ public boolean checkAttribute(String name) { if (model == null || classDescriptor == null) { return true; } for (ClassDescriptor cld : getAllClassDescriptors()) { if (cld.getAttributeDescriptorByName(name, true) != null) { return true; } } return false; }
/** * Return true if the name parameter is an attribute of the class for this Item or if * the Model or the className of this Item haven't been set. * * @param name the attribute name * @return true if the name is a valid attribute name */ public boolean checkAttribute(String name) { if (model == null || classDescriptor == null) { return true; } for (ClassDescriptor cld : getAllClassDescriptors()) { if (cld.getAttributeDescriptorByName(name, true) != null) { return true; } } return false; }
private static void verifyClassAndField(String className, String fieldName, Model model) { String checkFileMsg = "Please check modelUpdate.properties file"; if ("".equals(className)) { throw new BuildException("Class " + className + " can not be blank. " + checkFileMsg); } ClassDescriptor cd = model.getClassDescriptorByName(className); if (cd == null) { if (fieldName != null) { throw new BuildException("Class " + className + " containing " + fieldName + " not defined in the model " + model.getName() + ". " + checkFileMsg); } else { throw new BuildException("Class " + className + " not defined in the model " + model.getName() + ". " + checkFileMsg); } } if (fieldName != null) { if ("".equals(fieldName)) { throw new BuildException("Attribute " + fieldName + " in the class " + className + " can not be blank. " + checkFileMsg); } if (cd.getAttributeDescriptorByName(fieldName) == null && cd.getReferenceDescriptorByName(fieldName) == null && cd.getCollectionDescriptorByName(fieldName) == null) { throw new BuildException("The " + fieldName + " in the class " + className + " not defined in the model " + model.getName() + ". " + checkFileMsg); } } }
private static void verifyClassAndField(String className, String fieldName, Model model) { String checkFileMsg = "Please check modelUpdate.properties file"; if ("".equals(className)) { throw new BuildException("Class " + className + " can not be blank. " + checkFileMsg); } ClassDescriptor cd = model.getClassDescriptorByName(className); if (cd == null) { if (fieldName != null) { throw new BuildException("Class " + className + " containing " + fieldName + " not defined in the model " + model.getName() + ". " + checkFileMsg); } else { throw new BuildException("Class " + className + " not defined in the model " + model.getName() + ". " + checkFileMsg); } } if (fieldName != null) { if ("".equals(fieldName)) { throw new BuildException("Attribute " + fieldName + " in the class " + className + " can not be blank. " + checkFileMsg); } if (cd.getAttributeDescriptorByName(fieldName) == null && cd.getReferenceDescriptorByName(fieldName) == null && cd.getCollectionDescriptorByName(fieldName) == null) { throw new BuildException("The " + fieldName + " in the class " + className + " not defined in the model " + model.getName() + ". " + checkFileMsg); } } }
/** * Method to set up chromosome fields for helping */ public ChromosomeLocationHelper() { Model model = Model.getInstanceByName("genomic"); if (model == null) { throw new RuntimeException("No genomic model is available"); } ClassDescriptor chr = model.getClassDescriptorByName("Chromosome"); if (chr == null) { throw new RuntimeException("This genomic model does not contain Chromosomes"); } ClassDescriptor org = model.getClassDescriptorByName("Organism"); if (org == null) { throw new RuntimeException("This genomic model does not contain Organisms"); } AttributeDescriptor taxonDesc = org.getAttributeDescriptorByName("taxonId"); taxonIdsAreStrings = "java.lang.String".equals(taxonDesc.getType()); chromosome = new QueryClass(chr.getType()); organism = new QueryClass(org.getType()); chrIdField = new QueryField(chromosome, "primaryIdentifier"); taxonIdField = new QueryField(organism, "taxonId"); }
&& (superCld.getAttributeDescriptorByName(fieldName, true) != null)) { LOG.info("Pushing too many values from " + cld.getUnqualifiedName()
&& (superCld.getAttributeDescriptorByName(fieldName, true) != null)) { LOG.info("Pushing too many values from " + cld.getUnqualifiedName()
/** * Merge the attributes of a target model class descriptor <code>original</code> with * the attributes present in class descriptor <code>merge</code>. Returns a new set of * AttributeDescriptors. * * @param original the target model class descriptor * @param merge the additions * @return new set of AttributeDescriptors * @throws ModelMergerException if an error occurs during model mergining */ public static Set<AttributeDescriptor> mergeAttributes(ClassDescriptor original, ClassDescriptor merge) throws ModelMergerException { for (AttributeDescriptor merg : merge.getAttributeDescriptors()) { // nb: does not look for references in superclasses/superinterfaces AttributeDescriptor orig = original.getAttributeDescriptorByName(merg.getName()); if (orig != null) { if (!merg.getType().equals(orig.getType())) { String fldName = original.getName() + "." + orig.getName(); throw new ModelMergerException("type mismatch between attributes: " + fldName + ":" + merg.getType() + " != " + fldName + ":" + orig.getType()); } } } Set<AttributeDescriptor> newSet = new HashSet<AttributeDescriptor>(); newSet.addAll(cloneAttributeDescriptors(original.getAttributeDescriptors())); newSet.addAll(cloneAttributeDescriptors(merge.getAttributeDescriptors())); return newSet; }
/** * Merge the attributes of a target model class descriptor <code>original</code> with * the attributes present in class descriptor <code>merge</code>. Returns a new set of * AttributeDescriptors. * * @param original the target model class descriptor * @param merge the additions * @return new set of AttributeDescriptors * @throws ModelMergerException if an error occurs during model mergining */ public static Set<AttributeDescriptor> mergeAttributes(ClassDescriptor original, ClassDescriptor merge) throws ModelMergerException { for (AttributeDescriptor merg : merge.getAttributeDescriptors()) { // nb: does not look for references in superclasses/superinterfaces AttributeDescriptor orig = original.getAttributeDescriptorByName(merg.getName()); if (orig != null) { if (!merg.getType().equals(orig.getType())) { String fldName = original.getName() + "." + orig.getName(); throw new ModelMergerException("type mismatch between attributes: " + fldName + ":" + merg.getType() + " != " + fldName + ":" + orig.getType()); } } } Set<AttributeDescriptor> newSet = new HashSet<AttributeDescriptor>(); newSet.addAll(cloneAttributeDescriptors(original.getAttributeDescriptors())); newSet.addAll(cloneAttributeDescriptors(merge.getAttributeDescriptors())); return newSet; }
if (scd.getAttributeDescriptorByName(ad.getName()) != null) { LOG.info("removing attribute " + ad.getName() + " redefinition in " + cd.getName() + " (is now defined in "
if (scd.getAttributeDescriptorByName(ad.getName()) != null) { LOG.info("removing attribute " + ad.getName() + " redefinition in " + cd.getName() + " (is now defined in "