Package org.dmd.dms

Examples of org.dmd.dms.ClassDefinition


   * @throws ClassNotFoundException
   * @throws ClassNotFoundException 
   */
  public DmcObject createObject(DmcUncheckedObject uco) throws ResultException, DmcValueException, ClassNotFoundException {
    DmcObject      dmo  = null;
    ClassDefinition    cd  = null;
    AttributeDefinition  ad  = null;
   
    if ((cd = schema.isClass((String)uco.classes.get(0))) == null){
          ResultException ex = new ResultException();
            ex.result.addResult(Result.ERROR,"Unknown class: " + uco.classes.get(0));
            throw(ex);
    }
   
//    DebugInfo.debug(uco.toOIF(15));
   
    dmo = cd.newDMOInstance();
   
    // Add the object class
    DmcTypeClassDefinitionREFMV cref = new DmcTypeClassDefinitionREFMV();
    cref.add(cd.getObjectName());
   
    dmo.add(DmcObject.__objectClass, cref);
   
    // And add any auxiliary classes if we have them
    for(int i=1; i<uco.classes.size(); i++){
      if ((cd = schema.isClass((String)uco.classes.get(i))) == null){
            ResultException ex = new ResultException();
              ex.result.addResult(Result.ERROR,"Unknown class: " + uco.classes.get(i));
              throw(ex);
      }
      cref.add(cd.getObjectName());
      dmo.add("objectClass", cref);
    }
   
    Iterator<String> names = uco.getAttributeNames();
    while(names.hasNext()){
View Full Code Here


   
    // READ: the construction class ID
    int classID = dis.readInt();
   
    // Try to find the class in the schema
    ClassDefinition cd = schema.isClass(classID);
   
    if (cd == null)
      throw new IllegalStateException("Unknown class ID: " + classID + " ensure that you have loaded the required schemas.");
   
    // Instantiate the object
    rc = cd.newInstance();
    dmo = rc.getDmcObject();
       
    // Add the auxiliary classes if they exist
    if (classCount > 1){
      for(int i=1; i<classCount; i++){
        classID = dis.readInt();
        cd = schema.isClass(classID);
        dmo.addAux(new ClassDefinitionREF(cd.getDMO()));
      }
    }
   
    // READ: the number of attributes
    int     attrCount = dis.readAttributeCount();
View Full Code Here

    Iterator<ClassDefinition>  classes = sd.getClassDefList();
    if (classes != null){
      // We only generate the iterators for unnamed classes. Named classes will have their
      // Iterable generated along with the types because internal types are generated for them
      while(classes.hasNext()){
        ClassDefinition cd = classes.next();
       
        if (cd.getClassType() == ClassTypeEnum.AUXILIARY)
          continue;
       
        if (cd.getIsNamedBy() == null){
          String dmwImport = cd.getDmwImport();
          if (cd.getUseWrapperType() == WrapperTypeEnum.EXTENDED)
            dmwImport = cd.getDmeImport();
         
          GenUtility.dumpObjectIterable(dmwdir, sd.getDmwPackage(), cd.getDmoImport(), cd.getName().getNameString(), dmwImport, "", fileHeader, progress);
        }
      }
     
    }
   
View Full Code Here

    SchemaDefinition sd = sm.isSchema(config.getSchemaToLoad());
    Iterator<ClassDefinition> cdefs = sd.getClassDefList();
   
    if (cdefs != null){
      while(cdefs.hasNext()){
        ClassDefinition cd = cdefs.next();
        cd.adjustJavaClass();
       
        if (cd.getDMWPackage() == null){
          ResultException ex = new ResultException();
          ex.addError("The " + cd.getDefinedIn().getName() + " schema must define the dmwPackage attribute to facilitate wrapper creation.");
          ex.result.lastResult().fileName(cd.getDefinedIn().getFile());
          throw(ex);
        }
       
        if (cd.getClassType() == ClassTypeEnum.AUXILIARY){
          dumpAUX(cd, auxwdir);
        }
        else
         
          if (cd.getJavaClass() == null){
            ResultException ex = new ResultException();
            ex.addError("The " + cd.getName() + " class must define the javaClass attribute to facilitate wrapper creation.");
            ex.result.lastResult().fileName(cd.getFile());
            ex.result.lastResult().lineNumber(cd.getLineNumber());
            throw(ex);
          }
         
          dumpWrapper(config, loc, f, sm, cd);
        }
      }
    }
   
   
    Iterator<TypeDefinition>  tdefs = sd.getInternalTypeDefList();
    while(tdefs.hasNext()){
      TypeDefinition td = tdefs.next();
     
      ClassDefinition cd = td.getOriginalClass();
      if (cd != null){
        dumpIterable(config, loc, f, sm, cd, sd);
      }
    }
View Full Code Here

   
    Iterator<ClassDefinition> cdefs = sd.getClassDefList();
   
    if (cdefs != null){
      while(cdefs.hasNext()){
        ClassDefinition cd = cdefs.next();
       
        if (cd.generateWrapper(genContext) == false){
//          DebugInfo.debug("Skipping " + cd.getName() + " for context " + genContext);
          continue;
        }
       
        cd.adjustJavaClass(genContext,genSuffix);
       
        if (cd.getClassType() == ClassTypeEnum.AUXILIARY){
          createIfRequired(auxwdir);
          dumpAUX(cd, auxwdir);
        }
        else
         
          if (cd.getJavaClass() == null){
            ResultException ex = new ResultException();
            ex.addError("The " + cd.getName() + " class must define the javaClass attribute to facilitate wrapper creation.");
            ex.result.lastResult().fileName(cd.getFile());
            ex.result.lastResult().lineNumber(cd.getLineNumber());
            throw(ex);
          }
         
          dumpWrapper(config, loc, f, sm, cd);
        }
      }
    }
   
    if (useWrappedObjectRefs){
      Iterator<TypeDefinition>  tdefs = sd.getInternalTypeDefList();
      while(tdefs.hasNext()){
        TypeDefinition td = tdefs.next();
       
        ClassDefinition cd = td.getOriginalClass();
        if (cd != null){
          dumpIterable(config, loc, f, sm, cd, sd);
        }
      }
     
      Iterator<ExtendedReferenceTypeDefinition> extrefs = sd.getExtendedReferenceTypeDefList();
      while(extrefs.hasNext()){
        ExtendedReferenceTypeDefinition ertd = extrefs.next();
        ClassDefinition cd = ertd.getExtendedReferenceClass();
        dumpExtendedReferenceIterable(config, loc, f, sm, cd, sd, ertd);
      }
    }
   
View Full Code Here

    String asagName    = GeneratorUtils.dotNameToCamelCase(schema.getName().getNameString()) + "DMSAG";
   
    Iterator<ClassDefinition> classes = schema.getClassDefList();
    if (classes != null){
      while(classes.hasNext()){
        ClassDefinition cd = classes.next();
        sb.append("    public static ClassDefinition _" + cd.getName() + ";\n");
        allVars.add(new VarToObject("_" + cd.getName(), cd, "ClassDefinition", asagName));
        classVars.add(new VarToObject("_" + cd.getName(), cd, "ClassDefinition", asagName));
      }
      sb.append("\n");
      allVars.add(new VarToObject("", null,null));
    }
   
View Full Code Here

     
      if (skip.get(attr.getName()) != null)
        continue;
     
      AttributeDefinition ad = schemaManager.isAttribute(attr.getName());
      ClassDefinition aux = isAuxAttribute(var.def, ad);
     
      if (aux == null){
        if (attr.getMVSize() > 0){
          // Multi-value attribute
          Iterator<?> vals = attr.getMV();
          while(vals.hasNext()){
            sb.append(indent + obj + ".add" + an + "(\"" + vals.next().toString() + "\");\n");
          }
        }
        else{
          // HACK HACK HACK
          // In order to handle the concept of the empty string as a nullReturn value, we have to check
          // to see if the nullReturnValue attribute is "" because if we don't, we wind up with
          //             _ATTRDEF.setNullReturnValue("""");
          boolean doubleQuotes = false;
          if (attr.getName().equals("nullReturnValue")){
            if (attr.getSV().toString().startsWith("\"")){
              doubleQuotes = true;
            }
          }

          // The definedIn attribute must be "pre-resolved"
          if (attr.getName().equals(MetaDMSAG.__definedIn.name)){
            sb.append(indent + var.name + ".set" + an + "(this);\n");
          }
          else{
            if (doubleQuotes)
              sb.append(indent + obj + ".set" + an + "(" + attr.getSV().toString() + ");\n");
            else
              sb.append(indent + obj + ".set" + an + "(\"" + attr.getSV().toString() + "\");\n");
          }
        }
      }
      else{
//        String schemaName = ad.getDefinedIn().getStaticRefName();
       
        if (attr.getSV() == null){
          // Multi-value attribute
          Iterator<?> vals = attr.getMV();
          while(vals.hasNext()){
            sb.append(indent + aux.getDmwAuxClass() + ".add" + an + "(" + var.name + ", \"" + vals.next().toString() + "\");\n");
//            sb.append(indent + aux.getDmoAuxClass() + ".add" + an + "(" + obj + ", \"" + vals.next().toString() + "\");\n");
          }
        }
        else{
          // HACK HACK HACK
          // In order to handle the concept of teh empty string as a nullReturn value, we have to check
          // to see if the nullReturnValue attribute is "" because if we don't, we wind up with
          //             _ATTRDEF.setNullReturnValue("""");
          boolean doubleQuotes = false;
          if (attr.getName().equals("nullReturnValue")){
            if (attr.getSV().toString().startsWith("\"")){
              doubleQuotes = true;
            }
          }
           
          if (doubleQuotes)
            sb.append(indent + aux.getDmwAuxClass() + ".set" + an + "(" + var.name + ", " + attr.getSV().toString() + ");\n");
          else
            sb.append(indent + aux.getDmwAuxClass() + ".set" + an + "(" + var.name + ", \"" + attr.getSV().toString() + "\");\n");
//          sb.append(indent + aux.getDmoAuxClass() + ".set" + an + "(" + obj + ", \"" + attr.getSV().toString() + "\");\n");
        }
      }
    }
  }
View Full Code Here

   * @param def The definition.
   * @param ad  The attribute.
   * @return null if the attribute is standard member of the definition or the AUX class it's part of.
   */
  ClassDefinition isAuxAttribute(DmsDefinition def, AttributeDefinition ad){
    ClassDefinition rc = null;
   
//    if (ad.getName().equals("namingAttribute")){
//      System.out.println("Here");
//    }
//DebugInfo.debug(def.getName() + "  " + ad.getName());

    Iterator<ClassDefinition> oc = def.getObjectClass();
   
    if (oc == null){
      DebugInfo.debug("No class info for " + def.getName());
      DebugInfo.debug(def.toOIF(15));
    }
   
    while(oc.hasNext()){
      ClassDefinition cd = oc.next();
     
      if (cd.hasAttribute(ad.getName()) != null){
        rc = cd;
        break;
      }
    }
   
View Full Code Here

          imports.addImport(field.getEditorDef().getUseClass(), "Editor");
         
          imports.addImport(field.getAttrDef().getDefinedIn().getDMSASGImport(),"Required schema");
        }
       
        ClassDefinition cd = (ClassDefinition) binding.getEditObject();
       
        imports.addImport(cd.getDefinedIn().getSchemaPackage() + ".generated.dmo." + cd.getName() + "DMO", "For the object we're editting");
       
        out.write("package " + genPackage + ".generated.mvw.forms;\n\n");
       
        out.write(imports.getFormattedImports() + "\n");
       
        out.write("// " + DebugInfo.getWhereWeAreNow() + "\n");
        out.write("public class " + name + " {\n\n");
       
        out.write("    " + cd.getName() + "DMO dmo;\n\n");
       
        out.write("    // If the object set on the binding doesn't have a name, it is considered a new object\n");
        out.write("    boolean isNewObject;\n\n");
       
        out.write("    DmcPresentationTrackerIF  tracker;\n\n");
       
        for(EditField field: binding.getEditFieldIterable()){
          out.write(getDeclaration(field));
        }
       
        out.write("\n");
        out.write("    // " + DebugInfo.getWhereWeAreNow() + "\n");
        out.write("    public " + name + "(){\n");
        out.write("\n");
       
        out.write("        isNewObject = false;\n\n");
       
        for(EditField field: binding.getEditFieldIterable()){
          out.write(getInstantiation(field));
        }
       
        out.write("    }\n\n");
       
       
        ///////////////////////////////////////////////////////////////////////
        if (binding.getEditObject().getIsNamedBy() != null){
          out.write("    // " + DebugInfo.getWhereWeAreNow() + "\n");
          out.write("    public boolean isNewObject(){\n");
          out.write("        return(isNewObject);\n");
          out.write("    }\n\n");
        }
       
        ///////////////////////////////////////////////////////////////////////
        out.write("    // " + DebugInfo.getWhereWeAreNow() + "\n");
        out.write("    public void setObject(" + cd.getName() + "DMO obj){\n");
        out.write("        dmo = obj;\n\n");
       
        if (binding.getEditObject().getIsNamedBy() != null){
          out.write("        if (obj instanceof DmcNamedObjectIF){\n");
          out.write("            if (((DmcNamedObjectIF)obj).getObjectName() == null)\n");
          out.write("                isNewObject = true;\n");
          out.write("        }\n");
        }

        for(EditField field: binding.getEditFieldIterable()){
          out.write(getSetDMO(field));
        }
        out.write("\n");
       
        for(EditField field: binding.getEditFieldIterable()){
          out.write(getSetAdapter(field));
        }
       
        out.write("\n");
        out.write("        tracker.reset();\n");
       
        out.write("    }\n\n");

        ///////////////////////////////////////////////////////////////////////
        out.write("    // " + DebugInfo.getWhereWeAreNow() + "\n");
        out.write("    public void setTracker(DmcPresentationTrackerIF t){\n");
        out.write("        tracker = t;\n");
        out.write("\n");
        for(EditField field: binding.getEditFieldIterable()){
          out.write(getSetTracker(field));
        }
       
        out.write("    }\n\n");

        ///////////////////////////////////////////////////////////////////////
        out.write("    // " + DebugInfo.getWhereWeAreNow() + "\n");
        out.write("    public void setEnabledAll(boolean enabled){\n");
        for(EditField field: binding.getEditFieldIterable()){
          out.write(getSetEnabled(field));
        }
       
        out.write("    }\n\n");

        ///////////////////////////////////////////////////////////////////////
        if (binding.getEditObject().getIsNamedBy() == null){
          out.write("    // " + DebugInfo.getWhereWeAreNow() + "\n");
          out.write("    public " + cd.getName() + "DMO getModifiedObject(){\n");
          out.write("        if (dmo == null)\n");
          out.write("            return(null);\n\n");
         
          out.write("        " + cd.getName() + "DMO modrec = (" + cd.getName() + "DMO) dmo.getNew();\n");
          out.write("        modrec.setModifier(new DmcTypeModifierMV(MetaDMSAG.__modify));\n");
          out.write("\n");
          out.write("        if (dmo instanceof DmcNamedObjectIF){\n");
          out.write("            DmcNamedObjectIF origObj  = (DmcNamedObjectIF) dmo;\n");
          out.write("            try {\n");
          out.write("                modrec.set(origObj.getObjectNameAttribute().getAttributeInfo(), origObj.getObjectNameAttribute());\n");
          out.write("            } catch (DmcValueException e) {\n");
          out.write("                e.printStackTrace();\n");
          out.write("            }\n");
          out.write("        }\n\n");

          for(EditField field: binding.getEditFieldIterable()){
            out.write(getAddMods(field));//          out.write("        " + field.getAttribute() + "Adapter.addMods(modrec.getModifier());\n");
          }
          out.write("\n");
          out.write("        " + cd.getName() + "DMO rc = (" + cd.getName() + "DMO) dmo.cloneIt();\n");
          out.write("\n");
          out.write("        try {\n");
          out.write("            rc.applyModifier(modrec.getModifier());\n");
          out.write("        } catch(Exception ex){\n");
          out.write("            throw(new IllegalStateException(\"Shouldn't thrown an exception when modifying an object.\", ex));\n");
          out.write("        }\n");
          out.write("        \n");
         
          out.write("        return(rc);\n");
          out.write("    }\n\n");
        }
        else{
          out.write("    // " + DebugInfo.getWhereWeAreNow() + "\n");
          out.write("    public " + cd.getName() + "DMO getModRec(){\n");
          out.write("        if (dmo == null)\n");
          out.write("            return(null);\n");
          out.write("\n");
          out.write("        if (isNewObject)\n");
          out.write("            throw(new IllegalStateException(\"You are dealing with a new object, call getModifiedObject(), not getModRec()\"));\n");
          out.write("\n");
          out.write("        " + cd.getName() + "DMO modrec = dmo.getModificationRecorder();\n");
          out.write("\n");
         
          for(EditField field: binding.getEditFieldIterable()){
            out.write(getAddMods(field));//          out.write("        " + field.getAttribute() + "Adapter.addMods(modrec.getModifier());\n");
          }
          out.write("\n");
          out.write("        return(modrec);\n");
          out.write("    }\n\n");
         
          ///////////////////////////////////////////////////////////////////
         
          out.write("    // " + DebugInfo.getWhereWeAreNow() + "\n");
          out.write("    public " + cd.getName() + "DMO getModifiedObject(){\n");
          out.write("        if (dmo == null)\n");
          out.write("            return(null);\n");
          out.write("\n");
          out.write("        " + cd.getName() + "DMO modrec = (" + cd.getName() + "DMO) dmo.getNew();\n");
          out.write("        modrec.setModifier(new DmcTypeModifierMV(MetaDMSAG.__modify));\n\n");
          for(EditField field: binding.getEditFieldIterable()){
            out.write(getAddMods(field));//          out.write("        " + field.getAttribute() + "Adapter.addMods(modrec.getModifier());\n");
          }
          out.write("\n");
          out.write("        " + cd.getName() + "DMO rc = (" + cd.getName() + "DMO) dmo.cloneIt();\n");
          out.write("\n");
          out.write("        try {\n");
          out.write("            rc.applyModifier(modrec.getModifier());\n");
          out.write("        } catch(DmcValueExceptionSet ex){\n");
          out.write("            throw(new IllegalStateException(\"Your form should not permit invalid data\", ex));\n");
View Full Code Here

   
    // READ: the construction class ID
    int classID = dis.readInt();
   
    // Try to find the class in the schema
    ClassDefinition cd = schema.isClass(classID);
   
    if (cd == null)
      throw new IllegalStateException("Unknown class ID: " + classID + " ensure that you have loaded the required schemas.");
   
    // Tricky stuff: we always try to instantiate the wrapper for the object so that
    // we can support the DMW environment i.e. the DMO will have a handle to its
    // container. If something goes wrong, we fall back to directly instantiating
    // the DMO.
    DmwWrapper wrapper = null;
    try {
      wrapper = cd.newInstance();
    }
    catch(Exception ex){
      // Just fall back to instantiating the DMO
    }
   
    if (wrapper == null)
      rc = cd.newDMOInstance();
    else
      rc = wrapper.getDmcObject();
   
    // Add the auxiliary classes if they exist
    if (classCount > 1){
      for(int i=1; i<classCount; i++){
        classID = dis.readInt();
        cd = schema.isClass(classID);
        rc.addAux(new ClassDefinitionREF(cd.getDMO()));
      }
    }
   
    return(rc);
  }
View Full Code Here

TOP

Related Classes of org.dmd.dms.ClassDefinition

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.