Package org.dmd.util.exceptions

Examples of org.dmd.util.exceptions.ResultException


      else if (def instanceof ComplexTypeDefinition)
        this.addComplexType((ComplexTypeDefinition) def);
      else if (def instanceof SchemaDefinition)
        this.addSchema((SchemaDefinition) def);
        else{
          ResultException ex = new ResultException();
          ex.addError("The specified object is not a DmsDefinition object: \n" + def.toOIF());
          throw(ex);
        }

      if (listeners != null){
        for(SchemaDefinitionListenerIF listener: listeners)
View Full Code Here


     
      if (existing == null){
        ruleData.put(rule.getObjectName(), rule);
      }
      else{
        ResultException ex = new ResultException();
        ex.addError("The following rules have a name clash:\n\n" + existing.toOIF() + "\n" + rule.toOIF());
        throw(ex);
      }
    }
View Full Code Here

     * Adds the specified attribute definition to the schema if it doesn't already exist.
     * @throws DmcValueException
     */
    boolean addEnum(EnumDefinition evdthrows ResultException, DmcValueException {
        if (checkAndAdd(evd.getObjectName(),evd,enumDefs) == false){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(evd.getObjectName(),evd,enumDefs,"enum value names"));
            throw(ex);
        }
       
//        DebugInfo.debug(evd.getName().toString());
       
View Full Code Here

    } catch (DmcValueExceptionSet e) {
      e.printStackTrace();
    }
     
        if (checkAndAdd(actd.getObjectName(),actd,actionDefs) == false){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(actd.getObjectName(),actd,actionDefs,"action names"));
            throw(ex);
        }
        if (checkAndAdd(actd.getObjectName(),actd,allDefs) == false){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(actd.getObjectName(),actd,allDefs,"definition names"));
            throw(ex);
        }

        if (actd.getObjectName().getNameString().length() > longestActionName)
            longestActionName = actd.getObjectName().getNameString().length();
View Full Code Here

        while(preadl.hasNext()){
          AttributeDefinition d = preadl.next();
          DmcAttribute<?> attr = d.getDmcObject().get("type");
         
          if (attr == null){
          ResultException ex = new ResultException();
          ex.addError("The AttributeDefinition " + d.getName() + " has no type attribute.");
          ex.result.lastResult().fileName(d.getFile());
          ex.result.lastResult().lineNumber(d.getLineNumber());
          throw(ex);
          }
         
          DmcNamedObjectREF ref = (DmcNamedObjectREF) attr.getSV();
         
          // It might be a "real" type, so try that first
          TypeDefinition td = tdef(ref.getObjectName().getNameString());
         
          if( td == null){
            ClassDefinition cd = cdef(ref.getObjectName().getNameString());
            if (cd == null){
              ResultException ex = new ResultException();
              ex.addError("The type: " + ref.getObjectName() + " referred to in AttributeDefinition " + d.getName() + " is invalid.");
              ex.result.lastResult().fileName(d.getFile());
              ex.result.lastResult().lineNumber(d.getLineNumber());
              throw(ex);
            }
            else{
                ref.setObject((DmcNamedObjectIF) cd.getInternalTypeRef().getDmcObject());
            }
          }
          else{
            ref.setObject((DmcNamedObjectIF) td.getDmcObject());
          }
        }
      }
     
      // And more of the same kind of magic with complex types - we have to
      // preresolve the type references in the same way as with attributes
      Iterator<ComplexTypeDefinition> ctdl = sd.getComplexTypeDefList();
      if (ctdl != null){
        while(ctdl.hasNext()){
          ComplexTypeDefinition ctd = ctdl.next();
         
          // The usual resolution mechanisms don't work for the fields, we have to
          // handle that manually.
          Iterator<Field> fields = ctd.getField();
          while(fields.hasNext()){
            Field field = fields.next();
            DmcNamedObjectREF ref = (DmcNamedObjectREF)field.getType();
           
              // It might be a "real" type, so try that first
              TypeDefinition td = tdef(ref.getObjectName().getNameString());
             
              if( td == null){
                ClassDefinition cd = cdef(ref.getObjectName().getNameString());
                if (cd == null){
                  ResultException ex = new ResultException();
                  ex.addError("The type: " + ref.getObjectName() + " referred to in ComplexTypeDefinition " + ctd.getName() + " is invalid.");
                  ex.result.lastResult().fileName(ctd.getFile());
                  ex.result.lastResult().lineNumber(ctd.getLineNumber());
                  throw(ex);
                }
                else{
                    ref.setObject((DmcNamedObjectIF) cd.getInternalTypeRef().getDmcObject());
                }
              }
              else{
                ref.setObject((DmcNamedObjectIF) td.getDmcObject());
              }

          }
         
          // And finally, the complex type def has to have it object class resolved so that
          // we don't run into problems later when generating the DMW schema
          try {
          ctd.resolveReferences(this);
        } catch (DmcValueExceptionSet e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        }
      }
     
      // And more of the same kind of magic with extended references types - we have to
      // preresolve the type references in the same way as with attributes
      Iterator<ExtendedReferenceTypeDefinition> ertdl = sd.getExtendedReferenceTypeDefList();
      if (ertdl != null){
        while(ertdl.hasNext()){
          ExtendedReferenceTypeDefinition ertd = ertdl.next();
         
              DmcTypeClassDefinitionREFSV attr = (DmcTypeClassDefinitionREFSV) ertd.getDMO().get(MetaDMSAG.__extendedReferenceClass);
          if (attr == null){
          ResultException ex = new ResultException();
          ex.addError("Missing extendedReferenceClass for ExtendedReferenceTypeDefinition: " + ertd.getName());
          ex.result.lastResult().fileName(ertd.getFile());
          ex.result.lastResult().lineNumber(ertd.getLineNumber());
          throw(ex);           
          }
         
          try {
          attr.resolveReferences(this);
        } catch (DmcValueException e) {
          ResultException ex = new ResultException();
          ex.addError("Unknown class referred to by extendedReferenceClass: " + attr.getSV().getObjectName().getNameString());
          ex.result.lastResult().fileName(ertd.getFile());
          ex.result.lastResult().lineNumber(ertd.getLineNumber());
          throw(ex);
        }
       
        try {
          ertd.getInternalType().setOriginalClass(ertd.getExtendedReferenceClass());
        } catch (DmcValueException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
       

//        ClassDefinition cd = cdef(attr.getName());
//        if (cd == null){
//          ResultException ex = new ResultException();
//          ex.addError("Missing extendedReferenceClass for ExtendedReferenceTypeDefinition: " + ertd.getName());
//          ex.result.lastResult().fileName(ertd.getFile());
//          ex.result.lastResult().lineNumber(ertd.getLineNumber());
//          throw(ex);
//        }
         
         
        if (ertd.getExtendedReferenceClass().getIsNamedBy() == null){
          ResultException ex = new ResultException();
          ex.addError("The class: " + ertd.getExtendedReferenceClass().getObjectName().getNameString() + " referred to in ExtendedReferenceTypeDefinition " + ertd.getName() + " is not a named object.");
          ex.result.lastResult().fileName(ertd.getFile());
          ex.result.lastResult().lineNumber(ertd.getLineNumber());
          throw(ex);
        }

          Iterator<Field> fields = ertd.getField();
          while(fields.hasNext()){
            Field field = fields.next();
            DmcNamedObjectREF ref = (DmcNamedObjectREF)field.getType();
           
              // It might be a "real" type, so try that first
              TypeDefinition td = tdef(ref.getObjectName().getNameString());
             
              if( td == null){
                ClassDefinition cd = cdef(ref.getObjectName().getNameString());
                if (cd == null){
                  ResultException ex = new ResultException();
                  ex.addError("The type: " + ref.getObjectName() + " referred to in ExtendedReferenceTypeDefinition " + ertd.getName() + " is invalid.");
                  ex.result.lastResult().fileName(ertd.getFile());
                  ex.result.lastResult().lineNumber(ertd.getLineNumber());
                  throw(ex);
                }
                else{
                    ref.setObject((DmcNamedObjectIF) cd.getInternalTypeRef().getDmcObject());
                }
              }
              else{
                ref.setObject((DmcNamedObjectIF) td.getDmcObject());
              }
          }
        }
      }
     
      Iterator<ActionDefinition> actdl = sd.getActionDefList();
      if (actdl != null){
        while(actdl.hasNext()){
          ActionDefinition d = actdl.next();
          try {
          d.resolveReferences(this);
        } catch (DmcValueExceptionSet e) {
          ResultException ex = new ResultException();
          ex.addError("Unresolved references in ActionDefinition: " + d.getName());
          ex.setLocationInfo(d.getFile(), d.getLineNumber());
         
          for(DmcValueException dve : e.getExceptions()){
            ex.moreMessages(dve.getMessage());
          }
          throw(ex);
        }
        }
      }
     
      Iterator<AttributeDefinition> adl = sd.getAttributeDefList();
      if (adl != null){
        while(adl.hasNext()){
          AttributeDefinition d = adl.next();
         
          if (d.getName().getNameString().equals("field")){
            DebugInfo.debug("HERE");
          }
         
          try {
          d.resolveReferences(this);
        } catch (DmcValueExceptionSet e) {
          ResultException ex = new ResultException();
          ex.addError("Unresolved references in AttributeDefinition: " + d.getName());
          ex.setLocationInfo(d.getFile(), d.getLineNumber());
         
          for(DmcValueException dve : e.getExceptions()){
            ex.moreMessages(dve.getMessage());
          }
          throw(ex);
        }
       
        // TODO move towards generic object validation mechanisms - this check should be a rule
            if ( (d.getValueType() == ValueTypeEnum.HASHMAPPED) || (d.getValueType() == ValueTypeEnum.TREEMAPPED)){
              if (d.getType().getKeyClass() == null){
                if (d.getType().getIsRefType()){
                  if (d.getType().getIsExtendedRefType()){
                ResultException ex = new ResultException();
                ex.addError("AttributeDefinition: " + d.getName() + " cannot have valueType HASHMAPPED/TREEMAPPED since extended reference types are not keyed.");
                ex.setLocationInfo(d.getFile(), d.getLineNumber());
                    throw(ex);
                  }
                  if (d.getType().getOriginalClass().getIsNamedBy() == null){
                ResultException ex = new ResultException();
                ex.addError("AttributeDefinition: " + d.getName() + " cannot have valueType HASHMAPPED/TREEMAPPED since the " + d.getType().getName() + " type does not refer to a named object.");
                ex.setLocationInfo(d.getFile(), d.getLineNumber());
                    throw(ex);
                  }
                }
                else{
              ResultException ex = new ResultException();
              ex.addError("AttributeDefinition: " + d.getName() + " cannot have valueType HASHMAPPED/TREEMAPPED since the " + d.getType().getName() + " type does not have a specified keyClass.");
              ex.setLocationInfo(d.getFile(), d.getLineNumber());
                  throw(ex);
                }
              }
            }
           
        }
      }
     
      Iterator<ClassDefinition> cdl = sd.getClassDefList();
      if (cdl != null){
        while(cdl.hasNext()){
          ClassDefinition d = cdl.next();
          try {
          d.resolveReferences(this);
         
                if (d.getAllowedParentsSize() > 0){
                  // The name must be hierarchic
                  if (d.getIsNamedBy() == null){
                  ResultException ex = new ResultException();
                  ex.addError("The following class indicates that it has allowed parents, but isn't a named object: " + d.getName());
                    throw(ex);
                  }
                  if (!d.getIsNamedBy().getType().getIsHierarchicName()){
                  ResultException ex = new ResultException();
                  ex.addError("The following class indicates that it has allowed parents, but its naming attribute isn't heirarchic: " + d.getName());
                  ex.result.lastResult().moreMessages("isNamedBy: " + d.getIsNamedBy().getName());
                    throw(ex);
                  }
                }

        } catch (DmcValueExceptionSet e) {
          ResultException ex = new ResultException();
          ex.addError("Unresolved references in ClassDefinition: " + d.getName());
          ex.setLocationInfo(d.getFile(), d.getLineNumber());
         
          for(DmcValueException dve : e.getExceptions()){
            ex.moreMessages(dve.getMessage());
          }
          throw(ex);
        }
        }


      }
     
      Iterator<EnumDefinition> edl = sd.getEnumDefList();
      if (edl != null){
        while(edl.hasNext()){
          EnumDefinition d = edl.next();
          try {
          d.resolveReferences(this);
        } catch (DmcValueExceptionSet e) {
          ResultException ex = new ResultException();
          ex.addError("Unresolved references in EnumDefinition: " + d.getName());
          ex.setLocationInfo(d.getFile(), d.getLineNumber());
         
          for(DmcValueException dve : e.getExceptions()){
            ex.moreMessages(dve.getMessage());
          }
          throw(ex);
        }
        }
      }
     
      Iterator<TypeDefinition> tdl = sd.getTypeDefList();
      if (tdl != null){
        while(tdl.hasNext()){
          TypeDefinition d = tdl.next();
          try {
          d.resolveReferences(this);
        } catch (DmcValueExceptionSet e) {
          ResultException ex = new ResultException();
          ex.addError("Unresolved references in TypeDefinition: " + d.getName());
          ex.setLocationInfo(d.getFile(), d.getLineNumber());
         
          for(DmcValueException dve : e.getExceptions()){
            ex.moreMessages(dve.getMessage());
          }
          throw(ex);
        }
        }
      }
     
//      ctdl = sd.getComplexTypeDefList();
//      if (ctdl != null){
//        while(ctdl.hasNext()){
//          ComplexTypeDefinition d = ctdl.next();
//          try {
//          d.resolveReferences(this);
//        } catch (DmcValueExceptionSet e) {
//          ResultException ex = new ResultException();
//          ex.addError("Unresolved references in ComplexTypeDefinition: " + d.getName());
//          ex.setLocationInfo(d.getFile(), d.getLineNumber());
//         
//          for(DmcValueException dve : e.getExceptions()){
//            ex.moreMessages(dve.getMessage());
//          }
//          throw(ex);
//        }
//        }
//      }
     
      Iterator<SliceDefinition> sdl = sd.getSliceDefList();
      if (sdl != null){
        while(sdl.hasNext()){
          SliceDefinition s = sdl.next();
          try {
          s.resolveReferences(this);
        } catch (DmcValueExceptionSet e) {
          ResultException ex = new ResultException();
          ex.addError("Unresolved references in SliceDefinition: " + s.getName());
          ex.setLocationInfo(s.getFile(), s.getLineNumber());
         
          for(DmcValueException dve : e.getExceptions()){
            ex.moreMessages(dve.getMessage());
          }
          throw(ex);
        }
        }
      }     
View Full Code Here

                if (ad == ad.getType().getNameAttributeDef())
                  continue;
               
                AttributeDefinition nd = ad.getType().getNameAttributeDef();
                String sn = ad.getDefinedIn().getName().getNameString();
                  ResultException ex = new ResultException();
                  ex.addError("Only one attribute may be defined of type: " + ad.getType().getName());
                  ex.result.lastResult().moreMessages("You must use the \"" + nd.getName() + "\" attribute from the " + sn + " schema.");
                  ex.result.lastResult().moreMessages("This error was caused by the " + ad.getName() + " attribute definition.");
                  throw(ex);
              }
             
View Full Code Here

  @Override
  public void resetParent(HierarchicObject newParent) throws ResultException, DmcValueException {

        if (getName() == null){
          ResultException ex = new ResultException();
          ex.addError("Missing value for dotName. You must set dotName on this object.");
          throw(ex);
        }

        if (newParent == null){
        this.setFQN(getName());
View Full Code Here

  @Override
  public void setParentObject(HierarchicObject p, boolean buildFQN) throws ResultException, DmcValueException {
       
        if ( (p != null) && (p.getFQN() == null)){
          // The parent hasn't been properly initialized
          ResultException ex = new ResultException();
          ex.addErrorWithStack("The object being set as the parent hasn't been properly initialized. Ensure that its setParentObject() function has been called.",DebugInfo.getCurrentStack());
          throw(ex);
        }
       
      parent = p;
     
      if (!buildFQN)
        return;

        if (getName() == null){
          ResultException ex = new ResultException();
          ex.addError("Missing value for dotName. You must set dotName on this object.");
          throw(ex);
        }
       
      if (parent == null){
        this.setFQN(getName());
View Full Code Here

     * @param buildFQN Indicates if we need to reset this object's FQNs based on the parent.
     * @throws ResultException if there's no value for the naming attribute.
     * @throws DmcValueException
     */
  public void setParentObject(HierarchicObject p, boolean buildFQN) throws ResultException, DmcValueException {
    ResultException ex = new ResultException();
    ex.addError("Cannot set the parent of a root HierarchicObject.");
    throw(ex);
  }
View Full Code Here

     * recurses through the entire subtree and renames the objects based on the new parent.
     * @param newParent
     * @throws DmcValueException
     */
  public void resetParent(HierarchicObject newParent) throws ResultException, DmcValueException {
    ResultException ex = new ResultException();
    ex.addError("Cannot set the reset parent of a root HierarchicObject.");
    throw(ex);
  }
View Full Code Here

TOP

Related Classes of org.dmd.util.exceptions.ResultException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.