Package org.dmd.dms

Examples of org.dmd.dms.AttributeDefinition


                 out.write("," + parentRef);
             }
             if (cd.getIsNamedBy() == null)
               out.write(",null");
             else{
               AttributeDefinition ad = cd.getIsNamedBy();
               String schema = ad.getDefinedIn().getDMSASGName();
               out.write("," + schema + ".__" + ad.getName());
             }
          out.write(");\n");
        }
       
        for(ClassNode cn: derived.values()){
View Full Code Here


    // Value: comment
    TreeMap<String,String>  uniqueImports = new TreeMap<String, String>();
   
    if (may != null){
      while(may.hasNext()){
        AttributeDefinition ad = may.next();
        anyAttributes = true;
       
        TypeDefinition td = ad.getType();
        types.put(td.getName(), td);
       
        TypeAndAttr ta = new TypeAndAttr(td,ad.getValueType(),ad.getIndexSize());
        typeAndAttr.put(ta.name, ta);
       
        switch(ad.getValueType()){
        case SINGLE:
          anySVAttributes.set(true);;
          break;
        case MULTI:
          if (ad.getIndexSize() == null){
            anyMVAttributes.set(true);
          }
          else{
            if (td.getIsRefType() == false)
              anyMVAttributes.set(true);
          }
          break;
        case HASHMAPPED:
        case TREEMAPPED:
        case HASHSET:
        case TREESET:
          anyMVAttributes.set(true);
          break;
        }
       
        if (ad.getGenericArgsImport() != null)
          genericImports.add(ad.getGenericArgsImport());
       
        if (attributeInfo != null)
          appendAttributeInfo(attributeInfo, ad.getName().getNameString(), ad.getDmdID(), ad.getType().getName().getNameString(), ad.getValueType(), "true");

        if ((cd != null) && (cd.getClassType() == ClassTypeEnum.AUXILIARY))
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");
         
        if ((cd != null) && (ad.getDefinedIn() != cd.getDefinedIn()))
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");
         
        if ((act != null) && (ad.getDefinedIn() != act.getDefinedIn()))
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");
         
        allAttr.add(ad);
      }
    }
   
    if (must != null){
      while(must.hasNext()){
        AttributeDefinition ad = must.next();
        anyAttributes = true;
       
        TypeDefinition td = ad.getType();
        types.put(td.getName(), td);
       
        TypeAndAttr ta = new TypeAndAttr(td,ad.getValueType(),ad.getIndexSize());
        typeAndAttr.put(ta.name, ta);
       
//        if (interested){
//          if (ad.getName().getNameString().equals("wlanConfigProfiles")){
//            DebugInfo.debug("The type is: " + ta.name);
//            theType = ta.name;
//          }
//        }
       
        switch(ad.getValueType()){
        case SINGLE:
          anySVAttributes.set(true);
          break;
        case MULTI:
          // We don't need java.util with indexed multi-values
          if (ad.getIndexSize() == null){
            anyMVAttributes.set(true);
          }
          else{
            if (td.getIsRefType() == false)
              anyMVAttributes.set(true);
          }
          break;
        case HASHMAPPED:
        case TREEMAPPED:
        case HASHSET:
        case TREESET:
          anyMVAttributes.set(true);
          break;
        }
               
        if (ad.getGenericArgsImport() != null)
          genericImports.add(ad.getGenericArgsImport());

        if (attributeInfo != null)
          appendAttributeInfo(attributeInfo, ad.getName().getNameString(), ad.getDmdID(), ad.getType().getName().getNameString(), ad.getValueType(), "true");

        if ((cd != null) && (cd.getClassType() == ClassTypeEnum.AUXILIARY))
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");

        if ((cd != null) && (ad.getDefinedIn() != cd.getDefinedIn()))
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");
         
        if ((act != null) && (ad.getDefinedIn() != act.getDefinedIn()))
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");
         
        allAttr.add(ad);
      }
    }
   
   
    anyAttributesAtThisLevel = anyAttributes;
   
    if ( (cd != null) && (cd.getFullAttrMap().size() > 0) )
      anyAttributes = true;
   
    if (cd == null){
      if (anyMVAttributes.booleanValue())
        addImport(uniqueImports, longestImport, "java.util.*", "Always required if we have any MV attributes");
    }
    else{
      if (cd.getClassType() != ClassTypeEnum.AUXILIARY){
        if (anyMVAttributes.booleanValue())
          addImport(uniqueImports, longestImport, "java.util.*", "Always required if we have any MV attributes");
      }
    }
     
    if ( (cd != null) && (cd.getClassType() != ClassTypeEnum.AUXILIARY))
      addImport(uniqueImports, longestImport, "java.io.Serializable", "Always required");
     
    if ( (cd != null) && (cd.getClassType() != ClassTypeEnum.ABSTRACT) && (cd.getClassType() != ClassTypeEnum.AUXILIARY)){
      addImport(uniqueImports, longestImport, "org.dmd.dms.generated.types.DmcTypeModifierMV", "Required for MODREC constructor");
      addImport(uniqueImports, longestImport, "org.dmd.dms.generated.dmo.MetaDMSAG", "Required for MODREC constructor");
      addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcSliceInfo", "Required for object slicing");
    }
     
//    if (anyAttributes){
//      addImport(uniqueImports, longestImport, "org.dmd.dms.generated.enums.ValueTypeEnum", "Required if we have any attributes");
//      addImport(uniqueImports, longestImport, "org.dmd.dms.generated.enums.DataTypeEnum", "Required if we have any attributes");
//    }
//
//    addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcAttributeInfo", "Always required");
   
    if (anyAttributesAtThisLevel){
      addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcAttribute", "Any attributes");
      addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcValueException", "Any attributes");
    }
   
    for(String s: genericImports){
      addImport(uniqueImports, longestImport, s, "Generic args import");
    }

//    DebugInfo.debug("For class: " + cd.getName());
   
    for(TypeAndAttr ta: typeAndAttr.values()){
     
      TypeDefinition td = ta.td;
     
//      if (interested && ta.name.startsWith(theType)){
//        DebugInfo.debug("HERE");
//      }

      if ( (td.getPrimitiveType() != null) && (cd != null) && (cd.getClassType() != ClassTypeEnum.AUXILIARY) ){
        if (td.getInternallyGenerated() && td.getIsRefType()){
          // We have an internally generated reference type, only import if
          // the definition is from a different schema, otherwise, we're
          // already in the same package and don't need to import it
          if (cd.getDefinedIn() != td.getDefinedIn()){
            // NOTE: GetRequest has an unneeded ClassDefinitionDMO import because of this
            // need to figure out the right criteria
           
//            addImport(uniqueImports, longestImport, td.getPrimitiveType(), "Primitive type and !auxiliary - internally generated reference type");
          }
        }
        else{
          addImport(uniqueImports, longestImport, td.getPrimitiveType(), "Primitive type and !auxiliary class");
        }
      }
     
      if ( (td.getPrimitiveType() != null) && (act != null) ){
        if (td.getInternallyGenerated() && td.getIsRefType()){
          // We have an internally generated reference type, only import if
          // the definition is from a different schema, otherwise, we're
          // already in the same package and don't need to import it
          if (act.getDefinedIn() != td.getDefinedIn()){
            // NOTE: GetRequest has an unneeded ClassDefinitionDMO import because of this
            // need to figure out the right criteria
           
//            addImport(uniqueImports, longestImport, td.getPrimitiveType(), "Primitive type and !auxiliary - internally generated reference type");
          }
        }
        else{
          addImport(uniqueImports, longestImport, td.getPrimitiveType(), "Primitive type and !auxiliary class");
        }
      }

     
      if (td.getAltType() != null){
        if (td.getAltTypeImport() != null)
          addImport(uniqueImports, longestImport, td.getAltTypeImport(), "Alternative type for " + td.getName() + " values");
      }
     
     
      if (td.getIsRefType() && !td.getIsExtendedRefType()){
        addImport(uniqueImports, longestImport, ta.getImport(), "Reference type");
       
        if (ta.valueType == ValueTypeEnum.TREEMAPPED){
          if (td.getOriginalClass().getIsNamedBy() != null)
            addImport(uniqueImports, longestImport, td.getOriginalClass().getIsNamedBy().getType().getPrimitiveType(),"Name attribute type");
        }
       
        addImport(uniqueImports, longestImport, td.getOriginalClass().getDmoImport(), "Type specific set/add");
       
//        addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcNamedObjectIF", "Named object reference");

        if (td.getOriginalClass().getInternalTypeRef().getHelperClassName() == null){
//          DebugInfo.debug("\n\n*** PROBABLY MISSING isNamedBy FQN on a hierarchic object: " + td.getName() + " ***\n\n");
        }
        else{
         
//          DebugInfo.debug(td.toOIF(20));
          addImport(uniqueImports, longestImport, td.getOriginalClass().getInternalTypeRef().getHelperClassName(), "Reference type helper class");
         
          if ( (cd != null) && (cd.getClassType() != ClassTypeEnum.AUXILIARY))
            addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcOmni", "Lazy resolution");
                   
        }
      }
      else{
        if (td.getIsExtendedRefType())
          addImport(uniqueImports, longestImport, td.getPrimitiveType(), "Extended reference type");

        addImport(uniqueImports, longestImport, ta.getImport(), "Required type");
      }
     
      if (td.getIsExtendedRefType())
        addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcOmni", "Lazy resolution");
     
      if (td.getHelperClassName() != null){
        addImport(uniqueImports, longestImport, td.getHelperClassName(), "Helper class");
      }
     
      if (td.getKeyImport() != null){
        addImport(uniqueImports, longestImport, td.getKeyImport(), "Key class");
      }
    }
   
    if (cd != null){
      if (cd.getDerivedFrom() == null){
        if (cd.getClassType() == ClassTypeEnum.AUXILIARY){
          addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcObject", "Auxiliary class");
          addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcAttributeInfo", "Auxiliary class");
        }
        else{
//          addImport(uniqueImports, longestImport, "org.dmd.dms.generated.dmo.DmwWrapperDMO", "Structural class");
          addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcObject", "Structural class");
        }
      }
      else{
        addImport(uniqueImports, longestImport, cd.getDerivedFrom().getDmoImport(), "Base class");
      }
     
      if (cd.getIsNamedBy() != null){
        AttributeDefinition isNamedBy = cd.getIsNamedBy();
        String nameAttributeType = isNamedBy.getType().getPrimitiveType();
       
        if (nameAttributeType == null){
          ResultException ex = new ResultException("Naming attribute for class " + cd.getName() + " must be a complex type.");
          ex.result.lastResult().moreMessages("Check the type of attribute " + isNamedBy.getName().getNameString());
          ex.result.lastResult().fileName(isNamedBy.getFile());
          ex.result.lastResult().lineNumber(isNamedBy.getLineNumber());
          throw(ex);
        }
       
        addImport(uniqueImports, longestImport, nameAttributeType, "Naming attribute type");
       
        if (isNamedBy.getType().getIsHierarchicName())
          addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcHierarchicNamedObjectIF", "Named object");
       
        addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcNamedObjectIF", "Named object");
      }
    }
View Full Code Here

    }
   
    if (may != null){
      anyAttributes = true;
      while(may.hasNext()){
        AttributeDefinition ad = may.next();
        TypeDefinition td = ad.getType();
        types.put(td.getName(), td);
       
        switch(ad.getValueType()){
        case SINGLE:
          anySVAttributes.set(true);
          break;
        case MULTI:
        case HASHMAPPED:
        case TREEMAPPED:
        case HASHSET:
        case TREESET:
          anyMVAttributes.set(true);
          needJavaUtil = true;
          break;
        }

        appendAttributeInfo(attributeInfo, ad.getName().getNameString(), ad.getDmdID(), ad.getType().getName().getNameString(), ad.getValueType(), "true");
       
        if (ad.getGenericArgsImport() != null)
          genericImports.add(ad.getGenericArgsImport());
       
        allAttr.add(ad);
      }
    }
   
    if (must != null){
      anyAttributes = true;
      while(must.hasNext()){
        AttributeDefinition ad = must.next();
        TypeDefinition td = ad.getType();
        types.put(td.getName(), td);
       
        switch(ad.getValueType()){
        case SINGLE:
          anySVAttributes.set(true);
          break;
        case MULTI:
        case HASHMAPPED:
        case TREEMAPPED:
        case HASHSET:
        case TREESET:
          anyMVAttributes.set(true);
          needJavaUtil = true;
          break;
        }

        appendAttributeInfo(attributeInfo, ad.getName().getNameString(), ad.getDmdID(), ad.getType().getName().getNameString(), ad.getValueType(), "false");

        if (ad.getGenericArgsImport() != null)
          genericImports.add(ad.getGenericArgsImport());
       
        allAttr.add(ad);
      }
    }
   
View Full Code Here

      out.write("      <td class=\"label\">Used in:</td>\n");
      out.write("      <td>\n");
     
      for(DmwWrapper wrapper: referring){
        if (wrapper instanceof AttributeDefinition){
          AttributeDefinition ad = (AttributeDefinition) wrapper;
          attributes.put(ad.getName(), ad);
        }
      }
     
//      for(AttributeDefinition ad: attributes.values()){
//        String ref = "<a href=\"" + ad.getDefinedIn().getName() + ".html#" + ad.getName() + "\">" + ad.getDefinedIn().getName() + "</a>";
View Full Code Here

    }
  }
 
  static void namedBy(BufferedWriter out, ClassDefinition cd) throws IOException{
    if (cd.getIsNamedBy() != null){
      AttributeDefinition na = cd.getIsNamedBy();
      String schema = na.getDefinedIn().getName().getNameString();

      out.write("<!-- " + DebugInfo.getWhereWeAreNow() + " -->\n\n");
      out.write("    <tr>\n");
      out.write("      <td class=\"spacer\"> </td>\n");
      out.write("      <td>Named by</td>\n");
     
      out.write("      <td colspan=\"2\"> <a href=\"" + schema + ".html#" + na.getName() + "\">" + na.getName() + "</a> </td>\n");
      out.write("    </tr>\n\n");
    }
  }
View Full Code Here

//    if (referring != null){
      TreeMap<StringName,AttributeDefinition>  attributes = new TreeMap<StringName, AttributeDefinition>();
     
      for(DmwWrapper wrapper: referring){
        if (wrapper instanceof AttributeDefinition){
          AttributeDefinition ad = (AttributeDefinition) wrapper;
          attributes.put(ad.getName(), ad);
        }
      }
     
      if (attributes.size() > 0){
        out.write("    <tr>\n");
View Full Code Here

//    if (referring != null){
      TreeMap<StringName,AttributeDefinition>  attributes = new TreeMap<StringName, AttributeDefinition>();
     
      for(DmwWrapper wrapper: referring){
        if (wrapper instanceof AttributeDefinition){
          AttributeDefinition ad = (AttributeDefinition) wrapper;
          attributes.put(ad.getName(), ad);
        }
      }
     
      if (attributes.size() > 0){
        out.write("    <tr>\n");
View Full Code Here

   */
  public DmwWrapper createWrapper(DmcUncheckedObject uco) throws ResultException, DmcValueException, ClassNotFoundException {
    DmwWrapper       rc = null;
    DmcObject      dmo  = null;
    ClassDefinition    cd  = null;
    AttributeDefinition  ad  = null;
   
    if ((cd = schema.isClass((String)uco.classes.get(0))) == null){
      DebugInfo.debug("UncheckedObject:\n\n" + uco.toOIF());
          ResultException ex = new ResultException();
            ex.result.addResult(Result.ERROR,"Unknown class: " + uco.classes.get(0));
            throw(ex);
    }
   
   
    rc  = cd.newInstance();
    dmo = rc.getDmcObject();
           
    // 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){
        DebugInfo.debug("UncheckedObject AUX:\n\n" + uco.toOIF());
            ResultException ex = new ResultException();
              ex.result.addResult(Result.ERROR,"Unknown class: " + uco.classes.get(i));
              throw(ex);
      }
      rc.addAux(cd);
    }
       
    Iterator<String> names = uco.getAttributeNames();
    while(names.hasNext()){
      String n = names.next();
      DmcAttributeInfo ai = dmo.getAttributeInfo(n);
     
      ad = schema.adef(n);
     
      if (ad == null){
            ResultException ex = new ResultException();
              ex.result.addResult(Result.ERROR,"Unknown attribute: " + n);
              throw(ex);
      }
     
      // If the DMO doesn't directly support the attribute i.e. it's not in it
      // attribute info map, the attribute must be associated with an auxiliary class.
      // So, we have to get the DmcAttributeInfo from the attribute definition.
      if (ai == null){
        ai = DmcOmni.instance().getInfo(ad.getDmdID());
        if (ai == null){
              ResultException ex = new ResultException();
                ex.result.addResult(Result.ERROR,"Could not retrieve DmcAttributeInfo for: " + n);
                throw(ex);
        }
      }
     
      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());
         
          // 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) {
          e.setAttributeName(ad.getName().getNameString());
          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());
           
            // 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

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.