Package org.dmd.dmc

Examples of org.dmd.dmc.DmcNamedObjectREF


          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());
              }
          }
        }
      }
     
View Full Code Here

TOP

Related Classes of org.dmd.dmc.DmcNamedObjectREF

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.