Package org.dmd.util.exceptions

Examples of org.dmd.util.exceptions.ResultException


       
                try{
                  schemaClass = Class.forName(schemaClassName);
                }
                catch(Exception e){
                  ResultException ex = new ResultException();
                  ex.result.addResult(Result.FATAL,"Couldn't load generated schema class: " + schemaClassName);
                    ex.result.lastResult().moreMessages(e.getMessage());
                    ex.result.lastResult().moreMessages(DebugInfo.extractTheStack(e));
                    throw(ex);
                }

                try{
                  depSchema = (SchemaDefinition) schemaClass.newInstance();
                }
                catch(Exception e){
                  ResultException ex = new ResultException();
                  ex.result.addResult(Result.FATAL,"Couldn't instantiate Java class: " + schemaClassName);
                  ex.result.lastResult().moreMessages("This may be because the class doesn't have a constructor that takes no arguments.");
                  ex.result.lastResult().moreMessages("Or it may be that the class isn't derived from SchemaDefinition.");
                  throw(ex);
                }
View Full Code Here


     */
    void addSchema(SchemaDefinition sd) throws ResultException, DmcValueException {
        currentSchema = sd;

        if (checkAndAdd(sd.getObjectName(),sd,schemaDefs) == false){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(sd.getObjectName(),sd,schemaDefs,"schema names"));
            currentSchema = null;
          throw(ex);
        }
        if (checkAndAdd(sd.getObjectName(),sd,allDefs) == false){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(sd.getObjectName(),sd,allDefs,"definition names"));
            currentSchema = null;
          throw(ex);
        }

        if (sd.getObjectName().getNameString().length() > longestSchemaName)
View Full Code Here

     * @throws DmcValueException
     * @throws DmcValueExceptionSet
     */
    void addComplexType(ComplexTypeDefinition ctd) throws ResultException, DmcValueException {
        if (checkAndAdd(ctd.getObjectName(),ctd,complexTypeDefs) == false){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(ctd.getObjectName(),ctd,complexTypeDefs,"complex type names"));
          throw(ex);
        }
       
        TypeDefinition td  = new TypeDefinition();
        td.setInternallyGenerated(true);
View Full Code Here

     * @throws DmcValueException
     * @throws DmcValueExceptionSet
     */
    void addExtendedReferenceType(ExtendedReferenceTypeDefinition ertd) throws ResultException, DmcValueException {
        if (checkAndAdd(ertd.getObjectName(),ertd,extendedReferenceTypeDefs) == false){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(ertd.getObjectName(),ertd,extendedReferenceTypeDefs,"extended reference type names"));
          throw(ex);
        }
       
        TypeDefinition td  = new TypeDefinition();
        td.setInternallyGenerated(true);
View Full Code Here

     * @throws DmcValueException
     * @throws DmcValueExceptionSet
     */
    void addSlice(SliceDefinition sd) throws ResultException, DmcValueException {
        if (checkAndAdd(sd.getObjectName(),sd,sliceDefs) == false){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(sd.getObjectName(),sd,sliceDefs,"slice names"));
          throw(ex);
        }
        if (checkAndAdd(sd.getObjectName(),sd,allDefs) == false){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(sd.getObjectName(),sd,allDefs,"definition names"));
            throw(ex);
        }
    }
View Full Code Here

     * @throws DmcValueException
     * @throws DmcValueExceptionSet
     */
    void addRuleCategory(RuleCategory rc) throws ResultException, DmcValueException {
        if (checkAndAdd(rc.getObjectName(),rc,ruleCategoryDefs) == false){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(rc.getObjectName(),rc,ruleCategoryDefs,"rule categories"));
          throw(ex);
        }
        if (checkAndAdd(rc.getObjectName(),rc,allDefs) == false){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(rc.getObjectName(),rc,allDefs,"definition names"));
            throw(ex);
        }
       
        if (performIDChecks){
          // Bump up the rule category ID by the amount of schemaBaseID
          int base = rc.getDefinedIn().getSchemaBaseID();
          int range = rc.getDefinedIn().getSchemaIDRange();
          int current = rc.getRuleCategoryID();
         
          if (current >= range){
            ResultException ex = new ResultException("Number of rule categories exceeds schema ID range: " + rc.getName());
            throw(ex);         
          }
         
          rc.setRuleCategoryID(base + current);
        }

        if (ruleCategoriesByID.get(rc.getRuleCategoryID()) != null){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(rc.getRuleCategoryID(),rc,ruleCategoriesByID,"ruleCategoryID"));
          throw(ex);       
        }
    }
View Full Code Here

      // Again, some trickiness, we have to resolve the rule so that we can access and use the must/may
      // attributes that are defined for it and add them to the class definition we create
        try {
      rd.resolveReferences(this);
    } catch (DmcValueExceptionSet e) {     
      ResultException ex = new ResultException();
      ex.addError("Unresolved references in RuleDefinition: " + rd.getName());
     
      for(DmcValueException dve : e.getExceptions()){
        ex.moreMessages(dve.getMessage());
      }
      throw(ex);
    }
     
      StringName ruleClassName = new StringName(rd.getName().getNameString() + "Data");
     
        if (checkAndAdd(rd.getObjectName(),rd,ruleDefs) == false){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(rd.getObjectName(),rd,ruleDefs,"rule definitions"));
          throw(ex);
        }
        if (checkAndAdd(rd.getObjectName(),rd,allDefs) == false){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(rd.getObjectName(),rd,allDefs,"definition names"));
            throw(ex);
        }
       
        if (performIDChecks){
          // Bump up the DMD ID by the amount of schemaBaseID
          int base = rd.getDefinedIn().getSchemaBaseID();
          int range = rd.getDefinedIn().getSchemaIDRange();
          int current = rd.getDmdID();
         
          if (current >= range){
            ResultException ex = new ResultException("Number of rules exceeds schema ID range: " + rd.getName());
            throw(ex);         
          }
         
          rd.setDmdID(base + current);
        }
       
        ClassDefinition existing = classDefs.get(ruleClassName);
        if (existing != null){
          // We have the class for this rule, just check that it's auto generated
          if (existing.getInternallyGenerated()){
            return;
          }
          else{
            // We have some kind of clash
          }
        }
       
        // We check that the ID of the rule doesn't clash with the class definitions, since we're
        // going to create a class for this rule with the rule's ID.
        if (classesByID.get(rd.getDmdID()) != null){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(rd.getDmdID(),rd,classesByID,"dmdID"));
          throw(ex);
        }
       
        ///////////////////////////////////////////////////////////////////////
       
View Full Code Here

     * @throws DmcValueExceptionSet
     */
    void addClass(ClassDefinition cd) throws ResultException, DmcValueException {

        if (checkAndAdd(cd.getObjectName(),cd,classDefs) == false){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(cd.getObjectName(),cd,classDefs,"class names"));
          throw(ex);
        }
       
        if (checkAndAdd(cd.getObjectName(),cd,allDefs) == false){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(cd.getObjectName(),cd,allDefs,"definition names"));
          throw(ex);
        }
       
        if (cd.getAbbrev() != null){
            // We have an abbreviation - so it must also be unique and
            // added to the appropriate maps
          StringName abbrevName = new StringName(cd.getAbbrev());
            if (checkAndAdd(abbrevName,cd,classDefs) == false){
              ResultException ex = new ResultException();
              ex.addError(clashMsg(abbrevName,cd,classDefs,"class abbreviations"));
              throw(ex);
            }
            if (checkAndAdd(abbrevName,cd,allDefs) == false){
              ResultException ex = new ResultException();
              ex.addError(clashMsg(abbrevName,cd,allDefs,"definition names"));
              throw(ex);
            }
            classAbbrevs.put(abbrevName,cd);
        }
       
        ///////////////////////////////////////////////////////////////////////
       
        if (cd.getDmdID() == null){
          ResultException ex = new ResultException("Missing dmdID for class: " + cd.getName());
          ex.setLocationInfo(cd.getFile(), cd.getLineNumber());
          throw(ex);
        }

        if (cd.getDefinedIn() == null){
          ResultException ex = new ResultException("definedIn missing for class: " + cd.getName());
          ex.setLocationInfo(cd.getFile(), cd.getLineNumber());
          throw(ex);
        }
        else{
          if (performIDChecks){
            if ( (cd.getDefinedIn().getSchemaBaseID()  == null) ||
               (cd.getDefinedIn().getSchemaIDRange() == null) ){
                ResultException ex = new ResultException("schemaBaseID or schemaIDRange missing for schema: " + cd.getDefinedIn().getName());
                throw(ex);
            }
          }
         
        }
       
        if (performIDChecks){
          // Bump up the DMD ID by the amount of schemaBaseID
          int base = cd.getDefinedIn().getSchemaBaseID();
          int range = cd.getDefinedIn().getSchemaIDRange();
          int current = cd.getDmdID();
         
          if (current >= range){
            ResultException ex = new ResultException("Number of classes exceeds schema ID range: " + cd.getName());
            throw(ex);         
          }
         
          cd.setDmdID(base + current);
        }
       
        if (classesByID.get(cd.getDmdID()) != null){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(cd.getDmdID(),cd,classesByID,"dmdID"));
          throw(ex);
        }
        classesByID.put(cd.getDmdID(), cd);
       
        ///////////////////////////////////////////////////////////////////////

        if (cd.getObjectName().getNameString().length() > longestClassName)
            longestClassName = cd.getObjectName().getNameString().length();

        // Another bit of trickiness here. We don't resolve references for the entire schema
        // until we've loaded the whole thing, but, in this case, we need to pre-resolve
        // the ClassDefinition - which should be okay, because classes are the last things
        // that're loaded.
        try {
      cd.resolveReferences(this);
    } catch (DmcValueExceptionSet e) {     
      ResultException ex = new ResultException();
      ex.addError("Unresolved references in ClassDefinition: " + cd.getName());
//      ex.setLocationInfo(cd.getFile(), cd.getLineNumber());
     
      for(DmcValueException dve : e.getExceptions()){
        ex.moreMessages(dve.getMessage());
      }
      throw(ex);
    }
       
        if (cd.getDerivedFrom() != null){
            cd.getDerivedFrom().updateDerived(cd);
        }
       
        cd.setDmoImport(cd.getDefinedIn().getSchemaPackage() + ".generated.dmo." + cd.getName() + "DMO");
        cd.setDmoClass(cd.getName() + "DMO");
       
        cd.setDmwImport(cd.getDefinedIn().getDmwPackage() + ".generated.dmw." + cd.getName() + "DMW");
        cd.setDmwClass(cd.getName() + "DMW");
       
        cd.setDmwIteratorImport(cd.getDefinedIn().getDmwPackage() + ".generated.dmw." + cd.getName() + "IterableDMW");
        cd.setDmwIteratorClass(cd.getName() + "IterableDMW");
       
        cd.setDmtImport(cd.getDefinedIn().getSchemaPackage() + ".generated.types.DmcType" + cd.getName() + "REF");
        cd.setDmtREFImport(cd.getDefinedIn().getSchemaPackage() + ".generated.types." + cd.getName() + "REF");
        cd.setDmtClass(cd.getName() + "REF");
       
        if (cd.getUseWrapperType() == WrapperTypeEnum.EXTENDED){
          if (cd.getSubpackage() == null)
              cd.setDmeImport(cd.getDefinedIn().getDmwPackage() + ".extended." + cd.getName());           
          else
              cd.setDmeImport(cd.getDefinedIn().getDmwPackage() + ".extended." + cd.getSubpackage() + "." + cd.getName());
            cd.setDmeClass(cd.getName());
        }
        else{
            cd.setDmeImport("THE WRAPPER FOR " + cd.getName() + " ISN'T EXTENDED - YOU'VE GOT A CODE GENERATION ERROR! DWEEB!");           
            cd.setDmeClass("THE WRAPPER FOR " + cd.getName() + " ISN'T EXTENDED - YOU'VE GOT A CODE GENERATION ERROR! DWEEB!");
        }
       
        if (cd.getClassType() == ClassTypeEnum.AUXILIARY){
          cd.setDmoAuxClass(cd.getName() + "DMO");
          cd.setDmoAuxClassImport(cd.getDefinedIn().getSchemaPackage() + ".generated.auxw." + cd.getName() + "DMO");
         
          if (cd.getDefinedIn().getDmwPackage() != null){
              cd.setDmwAuxClass(cd.getName());
              cd.setDmwAuxClassImport(cd.getDefinedIn().getDmwPackage() + ".generated.auxw." + cd.getName());
          }
        }
       
//        cd.updateImplemented();

        // And now, set the java class that will be used with the DmwObjectFactory
        if (cd.getJavaClass() == null){
          if (cd.getUseWrapperType() == WrapperTypeEnum.BASE)
            cd.setJavaClass(cd.getDmwImport());
          else if (cd.getUseWrapperType() == WrapperTypeEnum.EXTENDED){
//            DebugInfo.debug("    --- JAVA CLASS  " + cd.getDmeImport());
            cd.setJavaClass(cd.getDmeImport());
          }
        }
       
        // Add the class to our java class to class definition map
        classesByJavaClass.put(cd.getJavaClass(), cd);
       
        Iterator<AttributeDefinition> adit = null;
        if ( (adit = cd.getMay()) != null){
            while(adit.hasNext()){
                AttributeDefinition ad = adit.next();
                ad.addUsingClass(cd);
            }
        }

        if ( (adit = cd.getMust()) != null){
            while(adit.hasNext()){
                AttributeDefinition ad = adit.next();
                ad.addUsingClass(cd);
            }
        }
       

//        Iterator<ClassDefinition> cdit = null;
//        if ( (cdit = cd.getAllowedParents()) != null){
//            while(cdit.hasNext()){
//                ClassDefinition p = cdit.next();
//                p.updateAllowedSubcomps(cd);
//            }
//        }
//
//        if ( (cdit = cd.getAllowedChildren()) != null){
//            while(cdit.hasNext()){
//                ClassDefinition c = cdit.next();
//                cd.updateAllowedSubcomps(c);
//            }
//        }

        Iterator<ActionDefinition> acdit = null;
        if ( (acdit = cd.getActions()) != null){
            while(acdit.hasNext()){
                ActionDefinition ad = acdit.next();
                ad.addUsingClass(cd);
            }
        }
       
      ////////////////////////////////////////////////////////////////////////////////
      // CREATE INTERNAL TYPE FOR REFERENCES
       
        if (cd.getClassType() != ClassTypeEnum.AUXILIARY){
          // Things get a little tricky here - we want to be able to refer to objects without
          // having to manually define wrapper types for them, so we create internal TypeDefinitions
          // for them. The internal type is DmcType<classname>REF.
         
          TypeDefinition td  = new TypeDefinition();
//          td.addObjectClass(MetaSchemaAG._TypeDefinition);
         
          td.setInternallyGenerated(true);
          td.setName(cd.getName());
          td.setDescription("This is an internally generated type to allow references to " + cd.getName() + " values.");
          td.setIsEnumType(false);
          td.setIsRefType(true);
         
          if (cd.getIsNamedBy() != null){
            // We only need a help class when we have named objects - regular old object references
            // can get by without this
            td.setHelperClassName(cd.getDefinedIn().getSchemaPackage() + ".generated.types." + cd.getName() + "REF");
           
            if (cd.getIsNamedBy().getValueType() != ValueTypeEnum.SINGLE){
              ResultException ex = new ResultException();
              ex.addError("The naming attribute: " + cd.getIsNamedBy().getName() + " for class: " + cd.getName() + " must be valueType SINGLE");
              ex.result.lastResult().fileName(cd.getIsNamedBy().getFile());
              ex.result.lastResult().lineNumber(cd.getIsNamedBy().getLineNumber());
              throw(ex);
            }
          }
View Full Code Here

     * @throws DmcValueException
     */
    void addAttribute(AttributeDefinition ad) throws ResultException, DmcValueException {
     
        if (checkAndAdd(ad.getObjectName(),ad,attrDefs) == false){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(ad.getObjectName(),ad,attrDefs,"attribute names"));
          throw(ex);
        }
        if (checkAndAdd(ad.getObjectName(),ad,allDefs) == false){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(ad.getObjectName(),ad,allDefs,"definition names"));
          throw(ex);
        }
       
        if (ad.getDmdID() == null){
          ResultException ex = new ResultException("Missing dmdID for attribute: " + ad.getName());
          throw(ex);
        }
       
        if (ad.getDefinedIn() == null){
          ResultException ex = new ResultException("definedIn missing for attribute: " + ad.getName());
          throw(ex);
        }
        else{
          if (performIDChecks){
            if ( (ad.getDefinedIn().getSchemaBaseID()  == null) ||
               (ad.getDefinedIn().getSchemaIDRange() == null) ){
                ResultException ex = new ResultException("schemaBaseID or schemaIDRange missing for schema: " + ad.getDefinedIn().getName());
                throw(ex);
            }
          }
         
        }
       
        if (performIDChecks){
          // Bump up the DMD ID by the amount of schemaBaseID
          int base = ad.getDefinedIn().getSchemaBaseID();
          int range = ad.getDefinedIn().getSchemaIDRange();
          int current = ad.getDmdID();
         
          if (current >= range){
            ResultException ex = new ResultException("Number of attributes exceeds schema ID range: " + ad.getName());
            throw(ex);         
          }
         
          ad.setDmdID(base + current);
        }
       
      if (attrByID.get(ad.getDmdID()) != null){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(ad.getDmdID(),ad,attrByID,"dmdID"));
          throw(ex);
        }
        attrByID.put(ad.getDmdID(), ad);
       
        if (ad.getAbbrev() != null){
            // We have an abbreviation - so it must also be unique and
            // added to the appropriate maps
          StringName abbrevName = new StringName(ad.getAbbrev());
            if (checkAndAdd(abbrevName,ad,attrDefs) == false){
              ResultException ex = new ResultException();
              ex.addError(clashMsg(ad.getObjectName(),ad,attrDefs,"attribute abbreviation"));
              throw(ex);
            }
            if (checkAndAdd(abbrevName,ad,allDefs) == false){
              ResultException ex = new ResultException();
              ex.addError(clashMsg(ad.getObjectName(),ad,allDefs,"definition names"));
              throw(ex);
            }
            attrAbbrevs.put(abbrevName,ad);
        }
       
View Full Code Here

//      }
     
//      DebugInfo.debugWithTrace("addType() - " + td.getObjectName());
     
        if (checkAndAdd(td.getObjectName(),td,typeDefs) == false){
          ResultException ex = new ResultException();
            ex.addError(clashMsg(td.getObjectName(),td,typeDefs,"type names"));
            throw(ex);
        }
        if (checkAndAdd(td.getObjectName(),td,allDefs) == false){
          ResultException ex = new ResultException();
          ex.addError(clashMsg(td.getObjectName(),td,allDefs,"definition names"));
            throw(ex);
        }

        if (td.getObjectName().getNameString().length() > longestTypeName)
            longestTypeName = td.getObjectName().getNameString().length();
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.