/** * Read the Model from the classpath. * * @param osAlias the alias of the ObjectStore properties to get the model name from. * @param properties the Properties object containing the model name * @return a Model * @throws MetaDataException if the model can't be read */ protected static Model getModelFromClasspath(String osAlias, Properties properties) throws MetaDataException { String modelName = properties.getProperty("model"); if (modelName == null) { throw new MetaDataException(osAlias + " does not have a model specified " + " - check properties"); } Model classpathModel = Model.getInstanceByName(modelName); if (classpathModel == null) { throw new MetaDataException("Model is null despite load from classpath"); } return classpathModel; }
/** * Read the Model from the classpath. * * @param osAlias the alias of the ObjectStore properties to get the model name from. * @param properties the Properties object containing the model name * @return a Model * @throws MetaDataException if the model can't be read */ protected static Model getModelFromClasspath(String osAlias, Properties properties) throws MetaDataException { String modelName = properties.getProperty("model"); if (modelName == null) { throw new MetaDataException(osAlias + " does not have a model specified " + " - check properties"); } Model classpathModel = Model.getInstanceByName(modelName); if (classpathModel == null) { throw new MetaDataException("Model is null despite load from classpath"); } return classpathModel; }
private void findSuperclassDescriptor() throws MetaDataException { // descriptor for super class for (ClassDescriptor cld : superDescriptors) { if (!cld.isInterface()) { if (this.isInterface()) { throw new MetaDataException("An interface (" + this + " may not have a superclass (" + cld + ")"); } if (superclassDescriptor != null) { throw new MetaDataException("Cannot have multiple superclasses for: " + this); } superclassDescriptor = cld; } } }
private void findSuperclassDescriptor() throws MetaDataException { // descriptor for super class for (ClassDescriptor cld : superDescriptors) { if (!cld.isInterface()) { if (this.isInterface()) { throw new MetaDataException("An interface (" + this + " may not have a superclass (" + cld + ")"); } if (superclassDescriptor != null) { throw new MetaDataException("Cannot have multiple superclasses for: " + this); } superclassDescriptor = cld; } } }
private void findSuperDescriptors() throws MetaDataException { // descriptors for superclasses and interfaces if (superNames.size() > 0) { for (String superName : superNames) { if (!model.hasClassDescriptor(superName)) { if (!"java.lang.Object".equals(superName)) { throw new MetaDataException("No ClassDescriptor for superclass or interface" + " (" + superName + ") found in model."); } } else { ClassDescriptor superDescriptor = model.getClassDescriptorByName(superName); superDescriptors.add(superDescriptor); } } } }
reader.close(); } catch (Exception e) { throw new MetaDataException("failed to read model file: " + inputModelFile, e); throw new MetaDataException("no addition files set"); } else { for (String additionsFile: additionsFiles) { mergedModel = processFile(mergedModel, additionsFile, parser); } catch (Exception e) { throw new MetaDataException("Exception while merging " + additionsFile + " into " + inputModelFile, e);
reader.close(); } catch (Exception e) { throw new MetaDataException("failed to read model file: " + inputModelFile, e); throw new MetaDataException("no addition files set"); } else { for (String additionsFile: additionsFiles) { mergedModel = processFile(mergedModel, additionsFile, parser); } catch (Exception e) { throw new MetaDataException("Exception while merging " + additionsFile + " into " + inputModelFile, e);
private void findSuperDescriptors() throws MetaDataException { // descriptors for superclasses and interfaces if (superNames.size() > 0) { for (String superName : superNames) { if (!model.hasClassDescriptor(superName)) { if (!"java.lang.Object".equals(superName)) { throw new MetaDataException("No ClassDescriptor for superclass or interface" + " (" + superName + ") found in model."); } } else { ClassDescriptor superDescriptor = model.getClassDescriptorByName(superName); superDescriptors.add(superDescriptor); } } } }
/** * Check that a class exists and has a field of the given name. If the either the class or * field aren't in the model this will write a warning to the log preceded by the give message * and throw a MetaDataException. If fieldName is null or an empty string just the class will * be tested. * @param model the data model * @param className the class to check in the model * @param fieldName check that className has a field with this name, can be null or empty string * @param message some text to precede the logged warning. * @throws MetaDataException if the the class or field name don't exist */ public static void checkFieldExists(Model model, String className, String fieldName, String message) throws MetaDataException { ClassDescriptor cld = model.getClassDescriptorByName(className); if (cld == null) { LOG.warn(message + " because " + className + " doesn't exist in model"); throw new MetaDataException(); } if (!StringUtils.isBlank(fieldName)) { if (cld.getFieldDescriptorByName(fieldName) == null) { LOG.warn(message + " because " + cld.getUnqualifiedName() + "." + fieldName + " doesn't exist in model"); throw new MetaDataException(); } } }
throw new MetaDataException("circular dependency: " + className1 + " is a super class of " + className2 + " and vice versa");
throw new MetaDataException("circular dependency: " + className1 + " is a super class of " + className2 + " and vice versa");
throw new MetaDataException("No classes provided"); throw new MetaDataException("No common type");
/** * Return a list of the super class names for the given class name. * * @param model the Model * @param className the className * @param superClassNames return set of super class names * @throws MetaDataException if className isn't in the model */ static void findSuperClassNames(Model model, String className, Set<String> superClassNames) throws MetaDataException { ClassDescriptor cd = model.getClassDescriptorByName(className); if ((cd == null) && (!"java.lang.Object".equals(className))) { throw new MetaDataException("Model construction failed - class: " + className + " is not in the model but is used as a super class"); } if (cd != null) { for (String superName: cd.getSuperclassNames()) { if (superClassNames.contains(superName)) { continue; } else { superClassNames.add(superName); findSuperClassNames(model, superName, superClassNames); } } } }
throw new MetaDataException("No classes provided"); throw new MetaDataException("No common type");
/** * Return a list of the super class names for the given class name. * * @param model the Model * @param className the className * @param superClassNames return set of super class names * @throws MetaDataException if className isn't in the model */ static void findSuperClassNames(Model model, String className, Set<String> superClassNames) throws MetaDataException { ClassDescriptor cd = model.getClassDescriptorByName(className); if ((cd == null) && (!"java.lang.Object".equals(className))) { throw new MetaDataException("Model construction failed - class: " + className + " is not in the model but is used as a super class"); } if (cd != null) { for (String superName: cd.getSuperclassNames()) { if (superClassNames.contains(superName)) { continue; } else { superClassNames.add(superName); findSuperClassNames(model, superName, superClassNames); } } } }
|| lastCommonType.getAllSuperDescriptors().contains(commonSuperType))) { throw new MetaDataException("Disjoint set.");
findSuperClassNames(model, className, allSupers); if (allSupers.contains(className)) { throw new MetaDataException("circular dependency: " + className + " is a super class of itself");
|| lastCommonType.getAllSuperDescriptors().contains(commonSuperType))) { throw new MetaDataException("Disjoint set.");
findSuperClassNames(model, className, allSupers); if (allSupers.contains(className)) { throw new MetaDataException("circular dependency: " + className + " is a super class of itself");
if ((fdAlready != null) && (fd != fdAlready)) { if (fd.relationType() != fdAlready.relationType()) { throw new MetaDataException("Incompatible similarly named fields (" + fd.getName() + ") inherited" + " from multiple superclasses and interfaces in " + getName()); AttributeDescriptor ad = (AttributeDescriptor) fd; if (!ad.getType().equals(((AttributeDescriptor) fdAlready).getType())) { throw new MetaDataException("Incompatible similarly named fields (" + fd.getName() + ") inherited" + " from multiple superclasses and interfaces in " + getName()); if (!referencedClassName.equals(rdAlready.getReferencedClassName()) || !Util.equals(reverseFieldName, alreadyRevFieldName)) { throw new MetaDataException("Incompatible similarly named fields (" + fd.getName() + ") inherited" + " from multiple superclasses and interfaces ["