Package org.dmd.dms

Examples of org.dmd.dms.AttributeDefinition


   * @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()){
      String n = names.next();
      ad = schema.adef(n);
     
      if (ad == null){
            ResultException ex = new ResultException();
              ex.result.addResult(Result.ERROR,"Unknown attribute: " + n);
              throw(ex);
      }
     
      DmcAttributeInfo ai = dmo.getAttributeInfo(n);
      if (ai == null){
        ai = ad.getAttributeInfo();
      }
     
//      DmcAttributeInfo ai = DmcOmni.instance().getInfo(ad.getDmdID());
     
      if (ai == null)
        throw(new IllegalStateException("Unknown attribute id: " + ad.getDmdID() + " for attribute: " + ad.getName()));
     
      NamedStringArray values = null;
     
      switch(ad.getValueType()){
      case SINGLE:
        values = uco.get(n);
       
        try {
          // Try to get the attribute
//          DmcAttribute<?> attr = dmo.get(ad.getName().getNameString());
          DmcAttribute<?> attr = dmo.get(ai);
         
          // If we can't find the attribute container, create it
          if (attr == null)
            attr = ad.getType().getAttributeHolder(ai);
         
          // Set the value
          attr.set(values.get(0));
         
          // Store the attribute
          dmo.set(ai, attr);
        } catch (InstantiationException e) {
          e.printStackTrace();
        } catch (IllegalAccessException e) {
          e.printStackTrace();
        } catch (DmcValueException e) {
          throw(e);
        }
        break;
      case MULTI:
      case HASHMAPPED:
      case TREEMAPPED:
      case HASHSET:
      case TREESET:
        values = uco.get(n);
       
        for (String attrVal: values){
          try {
            // Try to get the attribute
//            DmcAttribute<?> attr = dmo.get(ad.getName().getNameString());
            DmcAttribute<?> attr = dmo.get(ai);
           
            // If we can't find the attribute container, create it
            if (attr == null)
              attr = ad.getType().getAttributeHolder(ai);
                       
            // Add the value to the container
            attr.add(attrVal);
         
            // Store the attribute
View Full Code Here


        dumpHeader(out,sd);
       
        Iterator<AttributeDefinition> ads = sd.getAttributeDefList();
    if (ads != null){
      while(ads.hasNext()){
        AttributeDefinition ad = ads.next();
        if (ad.getType().getIsNameType()){
          attributes.put(ad.getName().getNameString(), ad);
         
          TypeAndAttr ta = new TypeAndAttr(ad.getType(), ad.getValueType(), ad.getIndexSize());
          typeAndAttr.put(ta.name, ta);
         
          DebugInfo.debug(ad.getName().getNameString());
        }
      }
     
      out.write("import java.util.HashMap;\n");

      for(TypeAndAttr ta: typeAndAttr.values()){
        out.write("import " + ta.getImport() + ";\n");
      }
     
          out.write("\n");

          out.write("public class " + factoryName + " {\n\n");

          for(AttributeDefinition ad: attributes.values()){
        //     public final static DmcAttributeInfo __monitoredBy = new DmcAttributeInfo("monitoredBy",2202,"DashboardPrefs",ValueTypeEnum.MULTI,false);
        out.write("    public final static DmcAttributeInfo __" + ad.getName().getNameString() + " = new DmcAttributeInfo(");
        out.write("\"" + ad.getName().getNameString() + "\"");
        out.write(", " + ad.getDmdID());
        out.write(", \"" + ad.getType().getName().getNameString() + "\"");
        out.write(", ValueTypeEnum." + ad.getValueType());
        out.write(", true");
        out.write(");\n");
      }
         
          out.write("\n");
          out.write("    static  HashMap<String ,DmcAttributeInfo> _SmAp;\n");
          out.write("\n");
         
          out.write("    static {\n");
          out.write("        _SmAp = new HashMap<String ,DmcAttributeInfo>();\n");
         
          for(AttributeDefinition ad: attributes.values()){
              // _SmAp.put(__jobName.name,__jobName);
        out.write("        _SmAp.put(__" + ad.getName().getNameString() + ".name,__" + ad.getName().getNameString() + ");\n");
      }
         
          out.write("\n");
          out.write("    }\n");


          out.write("\n");
          out.write("    public DmcAttributeInfo getAttributeInfo(String nameClass){\n");
          out.write("        return(_SmAp.get(nameClass));\n");
          out.write("    }\n");
          out.write("\n");
         
          out.write("\n");
         
          for(AttributeDefinition ad: attributes.values()){
            String tn = GeneratorUtils.getClassNameFromImport(ad.getType().getTypeClassName());
        out.write("    public static " + tn + suffix(ad.getValueType()) + " get" + GeneratorUtils.dotNameToCamelCase(ad.getName().getNameString()) + "(){\n");
        out.write("        " + tn + suffix(ad.getValueType()) + " rc = new " + tn + suffix(ad.getValueType()) +"();\n");
        out.write("        rc .setAttributeInfo(__" + ad.getName().getNameString() + ");\n");
        out.write("        return(rc);\n");
        out.write("    }\n\n");
      }
         
    }
View Full Code Here

        dumpHeaderASAG(out,sd.getSchemaPackage(), sd, nameBuilders);
       
        Iterator<AttributeDefinition> ads = sd.getAttributeDefList();
    if (ads != null){
      while(ads.hasNext()){
        AttributeDefinition ad = ads.next();
          attributes.put(ad.getName().getNameString(), ad);
      }
     
          out.write("\n");

      out.write("// Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
          out.write("public class " + schemaName + " implements DmcAttributeSchemaIF {\n\n");

          out.write("\n");
          out.write("    static String schemaName = \"" + sd.getName().getNameString() + "\";\n");
          out.write("\n");

          for(AttributeDefinition ad: attributes.values()){
        //     public final static DmcAttributeInfo __monitoredBy = new DmcAttributeInfo("monitoredBy",2202,"DashboardPrefs",ValueTypeEnum.MULTI,false);
        out.write("    public final static DmcAttributeInfo __" + ad.getName().getNameString() + " = new DmcAttributeInfo(");
        out.write("\"" + ad.getName().getNameString() + "\"");
        out.write(", " + ad.getDmdID());
        out.write(", \"" + ad.getType().getName().getNameString() + "\"");
        out.write(", ValueTypeEnum." + ad.getValueType());
        out.write(", DataTypeEnum." + ad.getDataType());
        out.write(", true");
        out.write(");\n");
      }
         
          out.write("\n");
          for(SliceDefinition slice: sd.getSliceDefList()){
        out.write("    public final static DmcSliceInfo __" + slice.getName() + " = new DmcSliceInfo(\"" + slice.getName() + "\");\n");
          }
         
          writeCommonPart1(out);
         
          // Inside the static initializer
         
          for(AttributeDefinition ad: attributes.values()){
              // _SmAp.put(__jobName.name,__jobName);
        out.write("        _SmAp.put(__" + ad.getName().getNameString() + ".id,__" + ad.getName().getNameString() + ");\n");
      }
         
          out.write(nameBuilders.toString());
         
          for(SliceDefinition slice: sd.getSliceDefList()){
            out.write("\n");
              // _SmAp.put(__jobName.name,__jobName);
            for(AttributeDefinition ad: slice.getSelectAttribute()){
          out.write("        __" + slice.getName().getNameString() + ".addAttributeID(" + ad.getDmdID() + ");\n");
            }
           
        out.write("        _SImAp.put(\"" + slice.getName() + "\",__" + slice.getName().getNameString() + ");\n");
      }
         
View Full Code Here

        // If the value is a single valued type, we'll want the primitive type.
       
        boolean shouldAddType = true;
       
        anyAttributes = true;
        AttributeDefinition ad = may.next();
        TypeDefinition td = ad.getType();
       
        if (ad.getGenericArgs() != null){
          if (ad.getGenericArgs().equals("<DmcObjectName>"))
            needDmwOmni = true;
        }
       
        switch(ad.getValueType()){
        case SINGLE:
          anySVAttributes =  true;
          break;
        case HASHMAPPED:
        case TREEMAPPED:
          anyMVAttributes = true;
          if (ad.getType().getIsRefType())
            anyMVRefs = true;
         
          iterables.put(td.getName(),td);
          break;
        case MULTI:
        case HASHSET:
        case TREESET:
          anyMVAttributes = true;
         
          if (ad.getType().getIsRefType())
            anyMVRefs = true;
         
          iterables.put(td.getName(),td);
         
          break;
        }
       
        if (shouldAddType){
          types.put(td.getName(), td);
          TypeAndAttr ta = new TypeAndAttr(td,ad.getValueType(),ad.getIndexSize());
          typeAndAttr.put(ta.name, ta);
        }
       
        appendAttributeInfo(attributeInfo, ad.getName().getNameString(), ad.getDmdID(), ad.getType().getName().getNameString(), ad.getValueType(), ad.getDataType());

        if (ad.getGenericArgsImport() != null)
          genericImports.add(ad.getGenericArgsImport());

        addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");

        allAttr.add(ad);
      }
    }
   
    Iterator<AttributeDefinition> must = cd.getMust();
    if (must != null){
      while(must.hasNext()){
        // NOTE: COMPLICATED! We always add the type of the attribute to our global types
        // map EXCEPT IF the type is a non-referential, MULTI/SET attribute. Gaa!
        //
        // This is because WE DON'T want the primitive type any more, just the TYPEIterableDMW.
        // If the value is a single valued type, we'll want the primitive type.
       
        boolean shouldAddType = true;
        anyAttributes = true;
        AttributeDefinition ad = must.next();
        TypeDefinition td = ad.getType();
       
        if (ad.getGenericArgs() != null){
          if (ad.getGenericArgs().equals("<DmcObjectName>"))
            needDmwOmni = true;
        }
       
        switch(ad.getValueType()){
        case SINGLE:
          anySVAttributes =  true;
          break;
        case HASHMAPPED:
        case TREEMAPPED:
          anyMVAttributes = true;
          if (ad.getType().getIsRefType())
            anyMVRefs = true;

          iterables.put(td.getName(),td);
          break;
        case MULTI:
        case HASHSET:
        case TREESET:
          anyMVAttributes = true;
          if (ad.getType().getIsRefType())
            anyMVRefs = true;

          iterables.put(td.getName(),td);
          break;
        }

        if (shouldAddType){
          types.put(td.getName(), td);
          TypeAndAttr ta = new TypeAndAttr(td,ad.getValueType(),ad.getIndexSize());
          typeAndAttr.put(ta.name, ta);
        }
       
        appendAttributeInfo(attributeInfo, ad.getName().getNameString(), ad.getDmdID(), ad.getType().getName().getNameString(), ad.getValueType(), ad.getDataType());

        if (ad.getGenericArgsImport() != null)
          genericImports.add(ad.getGenericArgsImport());

        addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");

        allAttr.add(ad);
      }
    }
   
    if (cd.getIsNamedBy() != null){
      AttributeDefinition isNamedBy = cd.getIsNamedBy();
      String nameAttributeType = isNamedBy.getType().getPrimitiveType();
     
      addImport(uniqueImports, longestImport, nameAttributeType, "Is named by");
    }
       
    addImport(uniqueImports, longestImport, "org.dmd.dms.*", "Always 2");
View Full Code Here

  String getAccessFunctions(ClassDefinition cd){
    StringBuffer sb  = new StringBuffer();
   
    // provide the getObjectName() method to support DmcNamedObjectIF
    if (cd.getIsNamedBy() != null){
      AttributeDefinition isNamedBy = cd.getIsNamedBy();
      String nameType = isNamedBy.getType().getName().getNameString();
     
        StringBuffer   attrNameCapped   = new StringBuffer();
        attrNameCapped.append(cd.getIsNamedBy().getName());
        attrNameCapped.setCharAt(0,Character.toUpperCase(attrNameCapped.charAt(0)));
       
View Full Code Here

  String getAccessFunctions(ClassDefinition cd){
    StringBuffer sb  = new StringBuffer();
   
    // provide the getObjectName() method to support DmcNamedObjectIF
    if (cd.getIsNamedBy() != null){
      AttributeDefinition isNamedBy = cd.getIsNamedBy();
      String nameType = isNamedBy.getType().getName().getNameString();
     
        StringBuffer   attrNameCapped   = new StringBuffer();
        attrNameCapped.append(cd.getIsNamedBy().getName());
        attrNameCapped.setCharAt(0,Character.toUpperCase(attrNameCapped.charAt(0)));
       
View Full Code Here

    }
   
    Iterator<AttributeDefinition> attributes = schema.getAttributeDefList();
    if (attributes != null){
      while(attributes.hasNext()){
        AttributeDefinition ad = attributes.next();
        sb.append("    public static AttributeDefinition _" + ad.getName() + ";\n");
        allVars.add(new VarToObject("_" + ad.getName(), ad, "AttributeDefinition"));
        attributeVars.add(new VarToObject("_" + ad.getName(), ad, "AttributeDefinition"));
      }
      sb.append("\n");
      allVars.add(new VarToObject("", null,null));
    }
   
    Iterator<TypeDefinition> types = schema.getTypeDefList();
    if (types != null){
      while(types.hasNext()){
        TypeDefinition td = types.next();
        sb.append("    public static TypeDefinition _" + td.getName() + ";\n");
        allVars.add(new VarToObject("_" + td.getName(), td, "TypeDefinition"));
        typeVars.add(new VarToObject("_" + td.getName(), td, "TypeDefinition"));
      }
      sb.append("\n");
      allVars.add(new VarToObject("", null,null));
    }
   
    Iterator<ComplexTypeDefinition> complextypes = schema.getComplexTypeDefList();
    if (complextypes != null){
      while(complextypes.hasNext()){
        ComplexTypeDefinition td = complextypes.next();
        sb.append("    public static ComplexTypeDefinition _" + td.getName() + ";\n");
        allVars.add(new VarToObject("_" + td.getName(), td, "ComplexTypeDefinition"));
        complexTypeVars.add(new VarToObject("_" + td.getName(), td, "ComplexTypeDefinition"));
      }
      sb.append("\n");
      allVars.add(new VarToObject("", null,null));
    }
   
    Iterator<ActionDefinition> actions = schema.getActionDefList();
    if (actions != null){
      while(actions.hasNext()){
        ActionDefinition ad = actions.next();
        sb.append("    public static ActionDefinition _" + ad.getName() + ";\n");
        allVars.add(new VarToObject("_" + ad.getName(), ad, "ActionDefinition"));
        actionVars.add(new VarToObject("_" + ad.getName(), ad, "ActionDefinition"));
      }
      sb.append("\n");
      allVars.add(new VarToObject("", null,null));
    }
   
View Full Code Here

      String an = GeneratorUtils.dotNameToCamelCase(attr.getName());
     
      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
View Full Code Here

    }
   
    Iterator<AttributeDefinition> may = cd.getMay();
    if (may != null){
      while(may.hasNext()){
        AttributeDefinition ad = may.next();
        TypeDefinition td = ad.getType();
        types.put(td.getName(), td);
       
        switch(ad.getValueType()){
        case SINGLE:
          break;
        case MULTI:
          needJavaUtil.set(true);
          break;
        case HASHMAPPED:
          break;
        case TREEMAPPED:
          break;
        }
       
//        if (ad.getIsMultiValued())
//          needJavaUtil.set(true);
       
        allAttr.put(ad.getName(),ad);
      }
    }
   
    Iterator<AttributeDefinition> must = cd.getMust();
    if (must != null){
      while(must.hasNext()){
        AttributeDefinition ad = must.next();
        TypeDefinition td = ad.getType();
        types.put(td.getName(), td);
       
        switch(ad.getValueType()){
        case SINGLE:
          break;
        case MULTI:
          needJavaUtil.set(true);
          break;
        case HASHMAPPED:
          break;
        case TREEMAPPED:
          break;
        }

//        if (ad.getIsMultiValued())
//          needJavaUtil.set(true);
       
        allAttr.put(ad.getName(),ad);
      }
    }

  }
View Full Code Here

        // If the value is a single valued type, we'll want the primitive type.
       
        boolean shouldAddType = true;
       
        anyAttributes = true;
        AttributeDefinition ad = may.next();
        TypeDefinition td = ad.getType();
       
        if (ad.getGenericArgs() != null){
          if (ad.getGenericArgs().equals("<DmcObjectName>"))
            needDmwOmni = true;
        }
       
        switch(ad.getValueType()){
        case SINGLE:
          anySVAttributes =  true;
          break;
        case HASHMAPPED:
        case TREEMAPPED:
          anyMVAttributes = true;
          if (ad.getType().getIsRefType())
            anyMVRefs = true;
         
          iterables.put(td.getName(),td);
          break;
        case MULTI:
        case HASHSET:
        case TREESET:
          anyMVAttributes = true;
         
          if (ad.getType().getIsRefType())
            anyMVRefs = true;
         
          iterables.put(td.getName(),td);
         
          break;
        }
       
        if (shouldAddType){
          types.put(td.getName(), td);
          TypeAndAttr ta = new TypeAndAttr(td,ad.getValueType(),ad.getIndexSize());
          typeAndAttr.put(ta.name, ta);
        }
       
        appendAttributeInfo(attributeInfo, ad.getName().getNameString(), ad.getDmdID(), ad.getType().getName().getNameString(), ad.getValueType(), ad.getDataType());

        if (ad.getGenericArgsImport() != null)
          genericImports.add(ad.getGenericArgsImport());

        if (ad.getValueType() != ValueTypeEnum.SINGLE){
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");
        }

        allAttr.add(ad);
      }
    }
   
    Iterator<AttributeDefinition> must = cd.getMust();
    if (must != null){
      while(must.hasNext()){
        // NOTE: COMPLICATED! We always add the type of the attribute to our global types
        // map EXCEPT IF the type is a non-referential, MULTI/SET attribute. Gaa!
        //
        // This is because WE DON'T want the primitive type any more, just the TYPEIterableDMW.
        // If the value is a single valued type, we'll want the primitive type.
       
        boolean shouldAddType = true;
        anyAttributes = true;
        AttributeDefinition ad = must.next();
        TypeDefinition td = ad.getType();
       
        if (ad.getGenericArgs() != null){
          if (ad.getGenericArgs().equals("<DmcObjectName>"))
            needDmwOmni = true;
        }
       
        switch(ad.getValueType()){
        case SINGLE:
          anySVAttributes =  true;
          break;
        case HASHMAPPED:
        case TREEMAPPED:
          anyMVAttributes = true;
          if (ad.getType().getIsRefType())
            anyMVRefs = true;

          iterables.put(td.getName(),td);
          break;
        case MULTI:
        case HASHSET:
        case TREESET:
          anyMVAttributes = true;
          if (ad.getType().getIsRefType())
            anyMVRefs = true;

          iterables.put(td.getName(),td);
          break;
        }

        if (shouldAddType){
          types.put(td.getName(), td);
          TypeAndAttr ta = new TypeAndAttr(td,ad.getValueType(),ad.getIndexSize());
          typeAndAttr.put(ta.name, ta);
        }
       
        appendAttributeInfo(attributeInfo, ad.getName().getNameString(), ad.getDmdID(), ad.getType().getName().getNameString(), ad.getValueType(), ad.getDataType());

        if (ad.getGenericArgsImport() != null)
          genericImports.add(ad.getGenericArgsImport());

        if (ad.getValueType() != ValueTypeEnum.SINGLE){
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");
        }
       
        allAttr.add(ad);
      }
    }
   
    if (cd.getIsNamedBy() != null){
      AttributeDefinition isNamedBy = cd.getIsNamedBy();
      String nameAttributeType = isNamedBy.getType().getPrimitiveType();
     
      addImport(uniqueImports, longestImport, nameAttributeType, "Is named by");
    }
     
    if (useWrappedObjectRefs)
View Full Code Here

TOP

Related Classes of org.dmd.dms.AttributeDefinition

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.