Package org.objectweb.jorm.metainfo.api

Examples of org.objectweb.jorm.metainfo.api.TypedElement


            // Fields with this persistent modifier shouldn't stay in JDO Metadata
            if (field.persistenceStatus == SpeedoField.NONE)
                continue;

            TypedElement tElem = classJorm.getTypedElement(fieldName);
            if (tElem == null) {
                throw new SpeedoXMLError("Field '" + fieldName
                    + "' not defined in JORM metadata of the class '"
                    + clas.getFQName() + "'");
            }

            // for application identity key fields have to be compared
            if (field.primaryKey) {
                boolean found = false;
                for (Iterator it = pName.iterateField(); it.hasNext() && !found;) {
                    found = fieldName.equals(it.next());
                }
                if (!found) {
                    throw new SpeedoXMLError("Field '" + fieldName
                        + "' not defined in Class NameDef's Fields of the class '"
                        + clas.getFQName() + "'");
                }
            }

            if (tElem instanceof GenClassRef && field.jdoTuple == null)
                throw new SpeedoXMLError("field '" + fieldName + "' should be a tuple in JDO metadata of the class '" + clas.getFQName() + "'");
        }

        // Comparison from JORM
        for (Iterator jormfield = classJorm.getFields().iterator(); jormfield.hasNext();) {
            TypedElement te = (TypedElement) jormfield.next();
            String fieldName = te.getName();
            if (!clas.fields.containsKey(fieldName)
                    && !isContainerIdField(classJorm, te, clas))
                throw new SpeedoXMLError("Field '" + fieldName + "' of the class '"
                            + clas.getFQName() + "' is not defined in the '"
                            + clas.moPackage.xmlDescriptor.xmlFile
View Full Code Here


                SpeedoInheritedField sif = (SpeedoInheritedField) it.next();
        if (debug) {
          logger.log(BasicLevel.DEBUG, "Map the inherited field '"
            + sif.name + "'.");
        }
                TypedElement te = sif.inheritedField.moClass.jormclass.getTypedElement(sif.inheritedField.name);
                if (te == null) {
                    throw new SpeedoException("No inherited field '"
                            + sif.name + "' found from "
                            + sc.getSourceDesc());
                } else if (te instanceof PrimitiveElement) {
View Full Code Here

  implements NamingManager {

  private final static String SINGLE_USER_ID = "suid";

    private int getCodingType(String fn, MetaObject mo) {
        TypedElement te = null;
        if (mo instanceof Class) {
            te = ((Class) mo).getTypedElement(fn);
        } else if (mo instanceof GenClassRef) {
            te = ((GenClassRef) mo).getHiddenField(fn);
        } else {
            return -1;
        }
        return CTHelper.ptc2ct(te.getType().getTypeCode());
    }
View Full Code Here

                SpeedoField sp,
                int nbField,
                Map ctx) throws SpeedoException {
    SpeedoClass moClass = sp.moClass;
    f.name = sp.name;
    TypedElement te = moClass.jormclass.getTypedElement(f.name);
    f.type = sp.type();
        f.jvmType = sp.type;
    f.nameUpperFirst = Character.toUpperCase(f.name.charAt(0))
      + f.name.substring(1);
    f.number = sp.number;
    f.getter = NamingRules.getterName(sp.moClass, sp.name);
    f.setter = NamingRules.setterName(sp.moClass, sp.name);
    f.isClassical = isClassicalType(sp.type());
    f.modifier = sp.modifier();
    f.isKey = sp.primaryKey;
    f.jormmeth = jormTools.upperFL(te.getName());
    f.jormfield = te.getName();
    f.isNotauthorizedToBeNull = (sp.nullValue == SpeedoNullValue.EXCEPTION);
    f.declaration = sp.publicSignature();
    f.defaultFetchGroup = sp.defaultFetchGroup;
    String cacheName = sp.getExtensionValueByKey(SpeedoProperties.USER_CACHE);
    if (cacheName != null) {
        f.userCacheNames = Collections.singleton(cacheName);
    } else {
        f.userCacheNames = Collections.EMPTY_SET;
    }

    // looks for identity type of the field and tests if it is an array
    Type fieldType = Type.getReturnType(sp.type);
    if (!f.isClassical && fieldType.getSort() == Type.OBJECT) {
      SpeedoClass jdoclass = scp.smi.getSpeedoClass(
        fieldType.getClassName(),
        sp.moClass.moPackage.xmlDescriptor);
      if (jdoclass != null) {
        f.isContainerId = jdoclass.identity.isDataStore();
      } else {
        f.isContainerId = true;
      }
      f.isArray = false;
    } else {
      f.isArray = sp.jdoTuple instanceof SpeedoArray;
    }

    f.jormMeth = jormTools.upperFL(f.name);

    //Field Id
    f.jormFieldIdLongPos = sp.number / 64;
    f.jormFieldId = 1L << (sp.number % 64);
    f.jormFielIdDecl = "new long[]{";
    String sep = "";
    for (int i = 0; i <= (nbField / 64); i++) {
      f.jormFielIdDecl += sep + (i == f.jormFieldIdLongPos
        ? f.jormFieldId + "L" : "0L");
      sep = ", ";
    }
    f.jormFielIdDecl += "}";

    f.isReference = jormTools.isReference(te);
    if (f.isReference) { //reference field
      fillReferenceInfo(f, sp, te, ctx, fieldType);
    } else { //primitive field
      f.jormType = te.getType().getJavaName();
      f.memoryType = sp.type();
      f.jormcast = sp.type();
        f.toMemory = "val";
      if (te.getType().getTypeCode() == PType.TYPECODE_SERIALIZED) {
          f.toMemory = "(" + f.memoryType + ")" + f.toMemory;
      }
      f.toStorage = f.name;
      fillUserFieldMappingInfo(f, sp);
    }
View Full Code Here

        ArrayList fields = new ArrayList();
        Iterator it = sc.fields.values().iterator();
        while(it.hasNext()) {
            SpeedoField sf = (SpeedoField) it.next();
            if (sf.primaryKey) {
                TypedElement te = sc.jormclass.getTypedElement(sf.name);
                Field f = new Field(sf.name, te.getType().getJavaName());
                String encode = f.name;
                String decode = "current.substring("
                        + (f.name.length() + 1) + " ,(idx = current.indexOf(\";\")))";
                f.next = "current = current.substring(idx+1);";
                switch(te.getType().getTypeCode()) {
                case PType.TYPECODE_BOOLEAN:
                    f.defaultValue = "false";
                    f.decode = "Boolean.getBoolean(" + decode + ")";
                    break;
                case PType.TYPECODE_CHAR:
View Full Code Here

TOP

Related Classes of org.objectweb.jorm.metainfo.api.TypedElement

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.