Package gap.service.od

Examples of gap.service.od.ODStateException


    public final static String ClassName(ClassDescriptor cd)
        throws ODStateException
    {
        String className = cd.getName();
        if (null == className || 0 == className.length())
            throw new ODStateException(cd,"The object data model requires a class name.");
        else
            return Camel(className);
    }
View Full Code Here


                            }
                        }
                    }
                }
            }
            throw new ODStateException(child,"Child relation field not found in parent.");
        }
        else
            throw new IllegalArgumentException();
    }
View Full Code Here

            case ListLong:
                return false;
            case ListShort:
                return true;
            default:
                throw new ODStateException(child,"Unrecognized list type.");
            }
        }
        else {
            gap.data.Map.Type mapType = gap.data.Map.Type.For(parentFieldType);
            if (null != mapType){
                switch (mapType){
                case MapPrimitive:
                    return false;
                case MapLong:
                    return false;
                case MapShort:
                    return true;
                default:
                    throw new ODStateException(child,"Unrecognized map type.");
                }
            }
            else
                throw new ODStateException(child,"Unrecognized field type.");
        }
    }
View Full Code Here

                        this.keyType = gap.Primitive.valueOf(this.childKeyFieldType);
                        this.childKeyFieldName = childKeyField.substring(idx+1);
                        this.fieldTypeName = this.mapType.dotName+'<'+this.childKeyFieldType+','+this.childValueClassName+'>';
                    }
                    catch (IllegalArgumentException notPrimitive){
                        throw new ODStateException(field,"Map type parameter key '"+this.childKeyFieldType+"' not primitive.",notPrimitive);
                    }
                }
                else
                    throw new ODStateException(field,"Map type requires key component 'type:fieldName' as in 'Map.Short<String:name,TableClass>'.");
            }
            else
                throw new ODStateException(field,"Map type parameters not found.");
        }
View Full Code Here

                    lxl.List<File> files = Main.ProcessFiles(odlFile.getFile(),src,beans,servlets);

                    products.addAll(files);
                }
                catch (ODStateException ODStateException){
                    throw new ODStateException("In '"+odlFile+"'",ODStateException);
                }
            }
        }
        return products;
    }
View Full Code Here

        File webXml = new File("ver/web/WEB-INF/web.xml");
        try {
            OD.GenerateWebXml(TemplateNames.WebXml,servlets,webXml);
        }
        catch (ODStateException ODStateException){
            throw new ODStateException("In '"+servlets.getServiceName()+"'",ODStateException);
        }
        return webXml;
    }
View Full Code Here


            TemplateDataDictionary child = top.addSection(new TemplateName(prefix,"class_re_child"));

            if (null == classRelationParent)
                throw new ODStateException(cd,"The object data model requires a parent class name.");
            else {

                top.setVariable(new TemplateName(prefix,"parent_class_name"),classRelationParent);

                parent = Classes.For(classRelationParent);
                if (null == parent)
                    throw new ODStateException(cd,String.format("Parent class '%s' of '%s' not found.",classRelationParent,className));
            }
        }
        else
            throw new IllegalStateException("Unrecognized class relation "+classRelation.name());

        cd.setDefinitionClassName(packageName+'.'+className);

        /*
         * Imports
         */
        DefineImports(top,imports,prefix);

        /*
         * Interfaces
         */
        String[] interfaces = ClassImplements(cd);
        for (String inf : interfaces){
            TemplateDataDictionary ind = top.addSection(new TemplateName(prefix,"implements"));
            ind.setVariable(TemplateNames.InterfaceClass,inf);
        }

        /*
         * Fields
         */
        FieldDescriptor key = null;

        TemplateDataDictionary field_unique = null;

        if (cd.hasFields()){


            for (FieldDescriptor field : cd.getFields()){

                final String fieldName = field.getName();

                if (IsFieldNameIllegal(fieldName))
                    throw new ODStateException(field,String.format("Reserved field name '%s'",fieldName));

                final String fieldNameCamel = Camel(fieldName);
                final String fieldType = OD.MapChild.Type(ToString(field.getType()));
                final String fieldTypeClean = CleanTypeName(fieldType);
                final String fieldTypeCleanClean = CleanCleanTypeName(fieldType);
                final ClassDescriptor fieldTypeClassDescriptor = Classes.For(fieldType);
                final Class fieldTypeClass = FieldClass(packageName,fieldType,imports);
                final boolean isBigTable = IsTypeClassBigTable(fieldTypeClassDescriptor,fieldTypeClass);
                final boolean isBigTableInterface;
                if (isBigTable)
                    isBigTableInterface = IsTypeClassBigTableInterface(fieldTypeClassDescriptor);
                else
                    isBigTableInterface = false;

                final boolean isCollection = IsTypeClassCollection(field,fieldTypeClass);

                final boolean isEnumerated = IsFieldEnumerated(field,fieldTypeClassDescriptor,fieldTypeClass);
                final Primitive fieldTypePrimitive = Primitive.For(fieldTypeClass,isEnumerated,isBigTable,isCollection);
                final String[] fieldTypeParameters = FieldTypeParameters(ToString(field.getType()));

                final gap.data.List.Type listType;
                if (IsTypeClassList(fieldTypeClass))
                    listType = gap.data.List.Type.For(fieldTypeClean);
                else
                    listType = null;

                final OD.MapChild mapChild;
                if (IsTypeClassMap(fieldTypeClass))
                    mapChild = new OD.MapChild(field);
                else
                    mapChild = null;

                final boolean isNumber = (null != fieldTypePrimitive && fieldTypePrimitive.isNumber());

                TemplateDataDictionary dataField = null;
                boolean isPersistent = false;
                boolean isInheritable = true;
                boolean isRelation = false;
                boolean isTransient = false;
                boolean isUnique = false;



                if (IsFieldDefaultSortBy(field))
                    defaultSortBy = fieldName;

                /*
                 * Create dataField section with field kind booleans
                 */
                if (IsFieldPersistent(field,fieldTypeClass)){
                    isPersistent = true;

                    dataField = top.addSection(new TemplateName(prefix,"pfield"));
                    top.addSection(new TemplateName(prefix,"field"), dataField);

                    /*
                     * Populate 'pfield' section
                     */
                    if (IsFieldUnique(field)){
                        if (isCollection)
          throw new ODStateException(field,"Unique field '"+fieldName+"' of collection type.");
                        else {
                            isUnique = true;

                            isInheritable = false;

                            defaultSortByOpt = fieldName;

                            dataField.addSection(TemplateNames.FieldIsUnique);
                            dataField.addSection(TemplateNames.FieldIsNotCollection);
                            dataField.addSection(TemplateNames.FieldIsNotPrimitiveCollection);
                            /*
                             * Global section 'field_unique'
                             */
                            if (null == field_unique){

                                top.addSection(new TemplateName(prefix,"field_unique"), dataField);
                            }
                        }
                    }
                    else {
                        dataField.addSection(TemplateNames.FieldIsNotUnique);

                        if (isCollection){
                            dataField.addSection(TemplateNames.FieldIsCollection);
                            if (null != listType){

                                if (ListPrimitive == listType){
                                    dataField.addSection(TemplateNames.FieldIsPrimitiveCollection);
                                }
                                else {
                                    dataField.addSection(TemplateNames.FieldIsNotPrimitiveCollection);
                                    dataField.addSection(TemplateNames.FieldIsCollectionNotPrimitive);
                                }
                            }
                            else if (null != mapChild){

                                if (MapPrimitive == mapChild.mapType){
                                    dataField.addSection(TemplateNames.FieldIsPrimitiveCollection);
                                }
                                else {
                                    dataField.addSection(TemplateNames.FieldIsNotPrimitiveCollection);
                                    dataField.addSection(TemplateNames.FieldIsCollectionNotPrimitive);
                                }
                            }
                            else
                                throw new ODStateException(field,"Collection field '"+fieldName+"' is neither list nor map.");
                        }
                        else {
                            dataField.addSection(TemplateNames.FieldIsNotCollection);
                            dataField.addSection(TemplateNames.FieldIsNotPrimitiveCollection);
                        }
                    }
                    dataField.addSection(TemplateNames.FieldIsNotTransient);
                    dataField.addSection(TemplateNames.FieldIsNotRelation);
                }
                else if (isCollection){

                    dataField = top.addSection(new TemplateName(prefix,"cfield"));
                    top.addSection(new TemplateName(prefix,"field"), dataField);
                    /*
                     * Populate 'cfield' section
                     */
                    dataField.addSection(TemplateNames.FieldIsCollection);
                    dataField.addSection(TemplateNames.FieldIsNotUnique);
                    dataField.addSection(TemplateNames.FieldIsNotTransient);
                    dataField.addSection(TemplateNames.FieldIsNotRelation);

                    if (null != listType){

                        if (ListPrimitive == listType){
                            dataField.addSection(TemplateNames.FieldIsPrimitiveCollection);
                        }
                        else {
                            dataField.addSection(TemplateNames.FieldIsNotPrimitiveCollection);
                            dataField.addSection(TemplateNames.FieldIsCollectionNotPrimitive);
                        }
                    }
                    else if (null != mapChild){

                        if (MapPrimitive == mapChild.mapType){
                            dataField.addSection(TemplateNames.FieldIsPrimitiveCollection);
                        }
                        else {
                            dataField.addSection(TemplateNames.FieldIsNotPrimitiveCollection);
                            dataField.addSection(TemplateNames.FieldIsCollectionNotPrimitive);
                        }
                    }
                    else
                        throw new ODStateException(field,"Collection field '"+fieldName+"' is neither list nor map.");
                }
                else if (IsFieldRelation(field)){
                    isRelation = true;

                    dataField = top.addSection(new TemplateName(prefix,"rfield"));
                    top.addSection(new TemplateName(prefix,"field"), dataField);
                    /*
                     * Populate 'rfield' section
                     */
                    if ((!IsTypeClassKey(fieldTypeClass)) && null != fieldTypeClass && IsNotTypeClassBigTable(fieldTypeClass))
                        throw new ODStateException(field,"Relation field '"+fieldName+"' is not a subclass of 'gap.data.BigTable'.");
                    else {
                        dataField.addSection(TemplateNames.FieldIsNotCollection);
                        dataField.addSection(TemplateNames.FieldIsNotPrimitiveCollection);
                        dataField.addSection(TemplateNames.FieldIsNotUnique);
                        dataField.addSection(TemplateNames.FieldIsNotTransient);
                        dataField.addSection(TemplateNames.FieldIsNotRelation);
                    }
                }
                else {
                    isTransient = true;

                    dataField = top.addSection(new TemplateName(prefix,"tfield"));
                    top.addSection(new TemplateName(prefix,"field"), dataField);
                    /*
                     * Populate 'tfield' section
                     */
                    dataField.addSection(TemplateNames.FieldIsNotCollection);
                    dataField.addSection(TemplateNames.FieldIsNotPrimitiveCollection);
                    dataField.addSection(TemplateNames.FieldIsNotUnique);
                    dataField.addSection(TemplateNames.FieldIsTransient);
                    dataField.addSection(TemplateNames.FieldIsNotRelation);
                }

                /*
                 * Field common properties
                 */
                dataField.setVariable(TemplateNames.FieldName,fieldName);
                dataField.setVariable(TemplateNames.FieldNameCamel,fieldNameCamel);
                dataField.setVariable(TemplateNames.FieldClass,fieldType);
                dataField.setVariable(TemplateNames.FieldClassClean,fieldTypeClean);
                dataField.setVariable(TemplateNames.FieldClassCleanClean,fieldTypeCleanClean);

                /*
                 * I/O functions ToString, FromString, FromObject
                 * and Is/IsNot selectors
                 */
                if (null != fieldTypePrimitive){

                    dataField.addSection(TemplateNames.FieldIsPrimitive);
                    dataField.addSection(TemplateNames.FieldIsNotBigTable);
                    dataField.addSection(TemplateNames.FieldIsNotBigTableInterface);

                    dataField.addSection(TemplateNames.FieldIsNotMap);
                    dataField.addSection(TemplateNames.FieldIsNotMapPrimitive);
                    dataField.addSection(TemplateNames.FieldIsNotMapLong);
                    dataField.addSection(TemplateNames.FieldIsNotMapLongOrShort);
                    dataField.addSection(TemplateNames.FieldIsNotMapShort);
                    dataField.addSection(TemplateNames.FieldIsNotList);
                    dataField.addSection(TemplateNames.FieldIsNotListPrimitive);
                    dataField.addSection(TemplateNames.FieldIsNotListLongOrShort);
                    dataField.addSection(TemplateNames.FieldIsNotListLong);
                    dataField.addSection(TemplateNames.FieldIsNotListShort);

                    if (isNumber){
                        dataField.addSection(TemplateNames.FieldIsNumber);
                        switch(fieldTypePrimitive){
                        case Short:
                            dataField.setVariable(TemplateNames.FieldNumberValue,"shortValue");
                            break;
                        case Integer:
                            dataField.setVariable(TemplateNames.FieldNumberValue,"intValue");
                            break;
                        case Long:
                            dataField.setVariable(TemplateNames.FieldNumberValue,"longValue");
                            break;
                        case Float:
                            dataField.setVariable(TemplateNames.FieldNumberValue,"floatValue");
                            break;
                        case Double:
                            dataField.setVariable(TemplateNames.FieldNumberValue,"doubleValue");
                            break;
                        default:
                            throw new ODStateException(field,"Number field '"+fieldName+"' type not recognized.");
                        }
                    }
                    else
                        dataField.addSection(TemplateNames.FieldIsNotNumber);

                    switch(fieldTypePrimitive){
                    case Key:
                        isInheritable = false;
                        dataField.setVariable(TemplateNames.FieldToStringPrefix,"gap.Strings.KeyToString(");
                        dataField.setVariable(TemplateNames.FieldToStringSuffix,")");

                        dataField.setVariable(TemplateNames.FieldFromStringPrefix,"gap.Strings.KeyFromString(");
                        dataField.setVariable(TemplateNames.FieldFromStringSuffix,")");

                        dataField.setVariable(TemplateNames.FieldFromObjectPrefix,"gap.Objects.KeyFromObject(");
                        dataField.setVariable(TemplateNames.FieldFromObjectSuffix,")");

                        dataField.addSection(TemplateNames.FieldIsKey);
                        dataField.addSection(TemplateNames.FieldIsNotBoolean);
                        dataField.addSection(TemplateNames.FieldIsNotCharacter);
                        dataField.addSection(TemplateNames.FieldIsNotEnum);
                        dataField.addSection(TemplateNames.FieldIsNotBigInteger);
                        dataField.addSection(TemplateNames.FieldIsNotBigDecimal);
                        dataField.addSection(TemplateNames.FieldIsNotSerializable);
                        break;
                    case Enum:
                        dataField.setVariable(TemplateNames.FieldToStringPrefix,"gap.Strings.EnumToString(");
                        dataField.setVariable(TemplateNames.FieldToStringSuffix,")");

                        dataField.setVariable(TemplateNames.FieldFromStringPrefix,"("+fieldType+")gap.Strings.EnumFromString(");
                        dataField.setVariable(TemplateNames.FieldFromStringSuffix,")");

                        dataField.setVariable(TemplateNames.FieldFromObjectPrefix,"("+fieldType+")gap.Objects.EnumFromObject(");
                        dataField.setVariable(TemplateNames.FieldFromObjectSuffix,")");

                        dataField.addSection(TemplateNames.FieldIsNotKey);
                        dataField.addSection(TemplateNames.FieldIsNotBoolean);
                        dataField.addSection(TemplateNames.FieldIsNotCharacter);
                        dataField.addSection(TemplateNames.FieldIsEnum);
                        dataField.addSection(TemplateNames.FieldIsNotBigInteger);
                        dataField.addSection(TemplateNames.FieldIsNotBigDecimal);
                        dataField.addSection(TemplateNames.FieldIsNotSerializable);
                        break;
                    case Boolean:
                        dataField.setVariable(TemplateNames.FieldToStringPrefix,"gap.Strings.BooleanToString(");
                        dataField.setVariable(TemplateNames.FieldToStringSuffix,")");

                        dataField.setVariable(TemplateNames.FieldFromStringPrefix,"gap.Strings.BooleanFromString(");
                        dataField.setVariable(TemplateNames.FieldFromStringSuffix,")");

                        dataField.setVariable(TemplateNames.FieldFromObjectPrefix,"gap.Objects.BooleanFromObject(");
                        dataField.setVariable(TemplateNames.FieldFromObjectSuffix,")");

                        dataField.addSection(TemplateNames.FieldIsNotKey);
                        dataField.addSection(TemplateNames.FieldIsBoolean);
                        dataField.addSection(TemplateNames.FieldIsNotCharacter);
                        dataField.addSection(TemplateNames.FieldIsNotEnum);
                        dataField.addSection(TemplateNames.FieldIsNotBigInteger);
                        dataField.addSection(TemplateNames.FieldIsNotBigDecimal);
                        dataField.addSection(TemplateNames.FieldIsNotSerializable);
                        break;
                    case Character:
                        dataField.setVariable(TemplateNames.FieldToStringPrefix,"gap.Strings.CharacterToString(");
                        dataField.setVariable(TemplateNames.FieldToStringSuffix,")");

                        dataField.setVariable(TemplateNames.FieldFromStringPrefix,"gap.Strings.CharacterFromString(");
                        dataField.setVariable(TemplateNames.FieldFromStringSuffix,")");

                        dataField.setVariable(TemplateNames.FieldFromObjectPrefix,"gap.Objects.CharacterFromObject(");
                        dataField.setVariable(TemplateNames.FieldFromObjectSuffix,")");

                        dataField.addSection(TemplateNames.FieldIsNotKey);
                        dataField.addSection(TemplateNames.FieldIsNotBoolean);
                        dataField.addSection(TemplateNames.FieldIsCharacter);
                        dataField.addSection(TemplateNames.FieldIsNotEnum);
                        dataField.addSection(TemplateNames.FieldIsNotBigInteger);
                        dataField.addSection(TemplateNames.FieldIsNotBigDecimal);
                        dataField.addSection(TemplateNames.FieldIsNotSerializable);
                        break;
                    case String:
                        dataField.setVariable(TemplateNames.FieldToStringPrefix,"");
                        dataField.setVariable(TemplateNames.FieldToStringSuffix,"");

                        dataField.setVariable(TemplateNames.FieldFromStringPrefix,"");
                        dataField.setVariable(TemplateNames.FieldFromStringSuffix,"");

                        dataField.setVariable(TemplateNames.FieldFromObjectPrefix,"gap.Objects.StringFromObject(");
                        dataField.setVariable(TemplateNames.FieldFromObjectSuffix,")");

                        dataField.addSection(TemplateNames.FieldIsNotKey);
                        dataField.addSection(TemplateNames.FieldIsNotBoolean);
                        dataField.addSection(TemplateNames.FieldIsNotCharacter);
                        dataField.addSection(TemplateNames.FieldIsNotEnum);
                        dataField.addSection(TemplateNames.FieldIsNotBigInteger);
                        dataField.addSection(TemplateNames.FieldIsNotBigDecimal);
                        dataField.addSection(TemplateNames.FieldIsNotSerializable);
                        break;
                    case BigInteger:
                        dataField.setVariable(TemplateNames.FieldToStringPrefix,"gap.Strings.BigIntegerToString(");
                        dataField.setVariable(TemplateNames.FieldToStringSuffix,")");

                        dataField.setVariable(TemplateNames.FieldFromStringPrefix,"gap.Strings.BigIntegerFromString(");
                        dataField.setVariable(TemplateNames.FieldFromStringSuffix,")");

                        dataField.setVariable(TemplateNames.FieldFromObjectPrefix,"gap.Objects.BigIntegerFromObject(");
                        dataField.setVariable(TemplateNames.FieldFromObjectSuffix,")");

                        dataField.addSection(TemplateNames.FieldIsNotKey);
                        dataField.addSection(TemplateNames.FieldIsNotBoolean);
                        dataField.addSection(TemplateNames.FieldIsNotCharacter);
                        dataField.addSection(TemplateNames.FieldIsNotEnum);
                        dataField.addSection(TemplateNames.FieldIsBigInteger);
                        dataField.addSection(TemplateNames.FieldIsNotBigDecimal);
                        dataField.addSection(TemplateNames.FieldIsNotSerializable);
                        break;
                    case BigDecimal:
                        dataField.setVariable(TemplateNames.FieldToStringPrefix,"gap.Strings.BigDecimalToString(");
                        dataField.setVariable(TemplateNames.FieldToStringSuffix,")");

                        dataField.setVariable(TemplateNames.FieldFromStringPrefix,"gap.Strings.BigDecimalFromString(");
                        dataField.setVariable(TemplateNames.FieldFromStringSuffix,")");

                        dataField.setVariable(TemplateNames.FieldFromObjectPrefix,"gap.Objects.BigDecimalFromObject(");
                        dataField.setVariable(TemplateNames.FieldFromObjectSuffix,")");

                        dataField.addSection(TemplateNames.FieldIsNotKey);
                        dataField.addSection(TemplateNames.FieldIsNotBoolean);
                        dataField.addSection(TemplateNames.FieldIsNotCharacter);
                        dataField.addSection(TemplateNames.FieldIsNotEnum);
                        dataField.addSection(TemplateNames.FieldIsNotBigInteger);
                        dataField.addSection(TemplateNames.FieldIsBigDecimal);
                        dataField.addSection(TemplateNames.FieldIsNotSerializable);
                        break;
                    case Serializable:
                        dataField.setVariable(TemplateNames.FieldToStringPrefix,"gap.Strings.SerializableToString(");
                        dataField.setVariable(TemplateNames.FieldToStringSuffix,")");

                        dataField.setVariable(TemplateNames.FieldFromStringPrefix,"("+fieldType+")gap.Strings.SerializableFromString(");
                        dataField.setVariable(TemplateNames.FieldFromStringSuffix,")");

                        dataField.setVariable(TemplateNames.FieldFromObjectPrefix,"("+fieldType+")gap.Objects.SerializableFromObject(");
                        dataField.setVariable(TemplateNames.FieldFromObjectSuffix,")");

                        dataField.addSection(TemplateNames.FieldIsNotKey);
                        dataField.addSection(TemplateNames.FieldIsNotBoolean);
                        dataField.addSection(TemplateNames.FieldIsNotCharacter);
                        dataField.addSection(TemplateNames.FieldIsNotEnum);
                        dataField.addSection(TemplateNames.FieldIsNotBigInteger);
                        dataField.addSection(TemplateNames.FieldIsNotBigDecimal);
                        dataField.addSection(TemplateNames.FieldIsSerializable);
                        break;
                    default:
                        dataField.setVariable(TemplateNames.FieldToStringPrefix,"gap.Strings."+fieldTypeCleanClean+"ToString(");
                        dataField.setVariable(TemplateNames.FieldToStringSuffix,")");

                        dataField.setVariable(TemplateNames.FieldFromStringPrefix,"gap.Strings."+fieldTypeCleanClean+"FromString(");
                        dataField.setVariable(TemplateNames.FieldFromStringSuffix,")");

                        dataField.setVariable(TemplateNames.FieldFromObjectPrefix,"gap.Objects."+fieldTypeCleanClean+"FromObject(");
                        dataField.setVariable(TemplateNames.FieldFromObjectSuffix,")");

                        dataField.addSection(TemplateNames.FieldIsNotKey);
                        dataField.addSection(TemplateNames.FieldIsNotBoolean);
                        dataField.addSection(TemplateNames.FieldIsNotCharacter);
                        dataField.addSection(TemplateNames.FieldIsNotEnum);
                        dataField.addSection(TemplateNames.FieldIsNotBigInteger);
                        dataField.addSection(TemplateNames.FieldIsNotBigDecimal);
                        dataField.addSection(TemplateNames.FieldIsNotSerializable);
                        break;
                    }
                }
                else {

                    if (isBigTable){
                        dataField.setVariable(TemplateNames.FieldToStringPrefix,"gap.Strings.KeyToString(");
                        dataField.setVariable(TemplateNames.FieldToStringSuffix,")");

                        dataField.setVariable(TemplateNames.FieldFromStringPrefix,"gap.Strings.KeyFromString(");
                        dataField.setVariable(TemplateNames.FieldFromStringSuffix,")");

                        dataField.setVariable(TemplateNames.FieldFromObjectPrefix,FullClassName(fieldTypeClassDescriptor,fieldTypeClass)+".FromObject(");
                        dataField.setVariable(TemplateNames.FieldFromObjectSuffix,")");
                        /*
                         */
                        dataField.addSection(TemplateNames.FieldIsBigTable);
                        if (isBigTableInterface)
                            dataField.addSection(TemplateNames.FieldIsBigTableInterface);
                        else
                            dataField.addSection(TemplateNames.FieldIsNotBigTableInterface);

                        if (IsFieldShort(cd,field,fieldTypeClassDescriptor))
                            dataField.addSection(TemplateNames.FieldIsShort);
                        else
                            dataField.addSection(TemplateNames.FieldIsLong);

                        dataField.addSection(TemplateNames.FieldIsNotPrimitive);
                        dataField.addSection(TemplateNames.FieldIsNotKey);
                        dataField.addSection(TemplateNames.FieldIsNotEnum);
                        dataField.addSection(TemplateNames.FieldIsNotBoolean);
                        dataField.addSection(TemplateNames.FieldIsNotNumber);
                        dataField.addSection(TemplateNames.FieldIsNotCharacter);
                        dataField.addSection(TemplateNames.FieldIsNotBigInteger);
                        dataField.addSection(TemplateNames.FieldIsNotBigDecimal);
                        dataField.addSection(TemplateNames.FieldIsNotSerializable);

                        dataField.addSection(TemplateNames.FieldIsNotMap);
                        dataField.addSection(TemplateNames.FieldIsNotMapPrimitive);
                        dataField.addSection(TemplateNames.FieldIsNotMapLong);
                        dataField.addSection(TemplateNames.FieldIsNotMapLongOrShort);
                        dataField.addSection(TemplateNames.FieldIsNotMapShort);
                        dataField.addSection(TemplateNames.FieldIsNotList);
                        dataField.addSection(TemplateNames.FieldIsNotListPrimitive);
                        dataField.addSection(TemplateNames.FieldIsNotListLongOrShort);
                        dataField.addSection(TemplateNames.FieldIsNotListLong);
                        dataField.addSection(TemplateNames.FieldIsNotListShort);
                    }
                    else {
                        dataField.addSection(TemplateNames.FieldIsNotBigTable);
                        dataField.addSection(TemplateNames.FieldIsNotBigTableInterface);
                        /*
                         */
                        if (null != listType){
                            dataField.addSection(TemplateNames.FieldIsNotMap);

                            dataField.setVariable(TemplateNames.FieldFromObjectPrefix,"("+fieldType+')');
                            dataField.setVariable(TemplateNames.FieldFromObjectSuffix,"");

                            dataField.addSection(TemplateNames.FieldIsNotPrimitive);
                            dataField.addSection(TemplateNames.FieldIsNotKey);
                            dataField.addSection(TemplateNames.FieldIsNotEnum);
                            dataField.addSection(TemplateNames.FieldIsNotBoolean);
                            dataField.addSection(TemplateNames.FieldIsNotNumber);
                            dataField.addSection(TemplateNames.FieldIsNotCharacter);
                            dataField.addSection(TemplateNames.FieldIsNotBigInteger);
                            dataField.addSection(TemplateNames.FieldIsNotBigDecimal);
                            dataField.addSection(TemplateNames.FieldIsNotSerializable);

                            dataField.addSection(TemplateNames.FieldIsNotMap);
                            dataField.addSection(TemplateNames.FieldIsNotMapPrimitive);
                            dataField.addSection(TemplateNames.FieldIsNotMapLong);
                            dataField.addSection(TemplateNames.FieldIsNotMapLongOrShort);
                            dataField.addSection(TemplateNames.FieldIsNotMapShort);

                            if (1 == fieldTypeParameters.length){

                                dataField.addSection(TemplateNames.FieldIsList);

                                switch(listType){
                                case ListPrimitive:
                                    dataField.addSection(TemplateNames.FieldIsListPrimitive);
                                    dataField.addSection(TemplateNames.FieldIsNotListLongOrShort);
                                    dataField.addSection(TemplateNames.FieldIsNotListLong);
                                    dataField.addSection(TemplateNames.FieldIsNotListShort);
                                    break;
                                case ListShort:
                                    dataField.addSection(TemplateNames.FieldIsNotListPrimitive);
                                    dataField.addSection(TemplateNames.FieldIsListLongOrShort);
                                    dataField.addSection(TemplateNames.FieldIsNotListLong);
                                    dataField.addSection(TemplateNames.FieldIsListShort);
                                    break;
                                case ListLong:
                                    dataField.addSection(TemplateNames.FieldIsNotListPrimitive);
                                    dataField.addSection(TemplateNames.FieldIsListLongOrShort);
                                    dataField.addSection(TemplateNames.FieldIsListLong);
                                    dataField.addSection(TemplateNames.FieldIsNotListShort);
                                    break;
                                default:
                                    throw new ODStateException(field,"List field '"+fieldName+"' has list type '"+listType+"'.");
                                }

                                String typeParameter = fieldTypeParameters[0];
                                dataField.setVariable(TemplateNames.FieldListComponent,typeParameter);

                                if (IsTypeOf(typeParameter,"HasName"))
                                    dataField.addSection(TemplateNames.FieldListComponentNamed);

                                ClassDescriptor component = Classes.For(typeParameter);
                                if (null != component){
                                    String componentKind = ClassKind(component);
                                    if (null != componentKind)
                                        dataField.setVariable(TemplateNames.FieldListComponentKind,componentKind);

                                    dataField.setVariable(TemplateNames.FieldImplClassName,ListImplClassName(fieldTypeClean,className,component));
                                }
                                else if (ListPrimitive == listType){

                                    Class componentClass = FieldClass(pkg,typeParameter,imports);
                                    if (null != componentClass){
                                        Primitive componentPrimitive = Primitive.For(componentClass);

                                        dataField.setVariable(TemplateNames.FieldImplClassName,ListPrimitiveClassName(componentPrimitive));
                                    }
                                    else
                                        throw new ODStateException(field,"In field '"+fieldType+" "+fieldName+"', require pre-compilation for class analysis of component type '"+typeParameter+"'.");
                                }
                                else
                                    throw new ODStateException(field,"In field '"+fieldType+" "+fieldName+"', expecting List.Primitive for component type '"+typeParameter+"'.");
                            }
                            else
                                throw new ODStateException(field,"Field '"+fieldName+"' type list missing type parameter.");
                        }
                        else if (null != mapChild){

                            dataField.addSection(TemplateNames.FieldIsNotList);

                            dataField.setVariable(TemplateNames.FieldFromObjectPrefix,"("+fieldType+')');
                            dataField.setVariable(TemplateNames.FieldFromObjectSuffix,"");

                            dataField.addSection(TemplateNames.FieldIsNotPrimitive);
                            dataField.addSection(TemplateNames.FieldIsNotKey);
                            dataField.addSection(TemplateNames.FieldIsNotEnum);
                            dataField.addSection(TemplateNames.FieldIsNotBoolean);
                            dataField.addSection(TemplateNames.FieldIsNotNumber);
                            dataField.addSection(TemplateNames.FieldIsNotCharacter);
                            dataField.addSection(TemplateNames.FieldIsNotBigInteger);
                            dataField.addSection(TemplateNames.FieldIsNotBigDecimal);
                            dataField.addSection(TemplateNames.FieldIsNotSerializable);

                            dataField.addSection(TemplateNames.FieldIsNotList);
                            dataField.addSection(TemplateNames.FieldIsNotListPrimitive);
                            dataField.addSection(TemplateNames.FieldIsNotListLongOrShort);
                            dataField.addSection(TemplateNames.FieldIsNotListLong);
                            dataField.addSection(TemplateNames.FieldIsNotListShort);

                            if (2 == fieldTypeParameters.length){

                                dataField.addSection(TemplateNames.FieldIsMap);

                                switch(mapChild.mapType){
                                case MapPrimitive:
                                    dataField.addSection(TemplateNames.FieldIsMapPrimitive);
                                    dataField.addSection(TemplateNames.FieldIsNotMapLongOrShort);
                                    dataField.addSection(TemplateNames.FieldIsNotMapLong);
                                    dataField.addSection(TemplateNames.FieldIsNotMapShort);
                                    break;
                                case MapShort:

                                    dataField.addSection(TemplateNames.FieldIsNotMapPrimitive);
                                    dataField.addSection(TemplateNames.FieldIsMapLongOrShort);
                                    dataField.addSection(TemplateNames.FieldIsNotMapLong);
                                    dataField.addSection(TemplateNames.FieldIsMapShort);
                                    break;
                                case MapLong:
                                    dataField.addSection(TemplateNames.FieldIsNotMapPrimitive);
                                    dataField.addSection(TemplateNames.FieldIsMapLongOrShort);
                                    dataField.addSection(TemplateNames.FieldIsMapLong);
                                    dataField.addSection(TemplateNames.FieldIsNotMapShort);
                                    break;
                                }


                                String typeComponentFrom = mapChild.childKeyFieldType;
                                String typeComponentFromName = mapChild.childKeyFieldName;
                                String typeComponentTo = mapChild.childValueClassName;
                                dataField.setVariable(TemplateNames.FieldMapComponentFrom,typeComponentFrom);
                                dataField.setVariable(TemplateNames.FieldMapComponentFromName,typeComponentFromName);
                                dataField.setVariable(TemplateNames.FieldMapComponentFromNameCamel,Camel(typeComponentFromName));
                                dataField.setVariable(TemplateNames.FieldMapComponentTo,typeComponentTo);
                                dataField.setVariable(TemplateNames.FieldMapComponent,typeComponentTo);

                                if (IsTypeOf(typeComponentTo,"HasName"))
                                    dataField.addSection(TemplateNames.FieldMapComponentNamed);

                                ClassDescriptor componentTo = Classes.For(typeComponentTo);
                                if (null != componentTo){
                                    String componentToKind = ClassKind(componentTo);
                                    if (null != componentToKind)
                                        dataField.setVariable(TemplateNames.FieldMapComponentKind,componentToKind);
                                }

                                dataField.setVariable(TemplateNames.FieldImplClassName,MapClassName(fieldTypeClean,className,typeComponentFrom,typeComponentTo));
                            }
                            else
                                throw new ODStateException(field,"Field '"+fieldName+"' type map missing type parameter.");
                        }
                        else {
                            throw new ODStateException(field,"Invalid table or collection type of field '"+fieldType+" "+fieldName+"'.");
                        }
                    }
                }

                /*
                 * Field inheritance
                 */
                if (isPersistent && isInheritable)
                    dataField.addSection(TemplateNames.FieldIsInheritable);
                else
                    dataField.addSection(TemplateNames.FieldIsNotInheritable);
            }
        }

        if (null == field_unique)
            top.showSection(new TemplateName(prefix,"not_field_unique"));


        if (null != defaultSortBy)
            top.setVariable(new TemplateName(prefix,"class_defaultSortBy"), defaultSortBy);
        else if (null != defaultSortByOpt)
            top.setVariable(new TemplateName(prefix,"class_defaultSortBy"), defaultSortByOpt);
        else
            throw new ODStateException(cd,"The object data model requires a default sort by.");

        /*
         * Methods
         */
        if (cd.hasMethods()){
View Full Code Here

        if (cd instanceof ClassDescriptor.Path){
            ClassDescriptor.Path cdp = (ClassDescriptor.Path)cd;
            if (cdp.hasPath())
                return cdp.getPath();
            else
                throw new ODStateException(cd,"OD Model requires 'path' field of class.");
        }
        else
            return null;
    }
View Full Code Here

        if (container.isFieldShort(field)){

            if (isShort)
                return true;
            else
                throw new ODStateException(field,"Field class '"+gap.Objects.StringFromObject(field.getType())+"' is used in a short relation from class '"+GetPackageClassName(container)+"', but is not declared 'child'.  This redundancy is required for type integrity.");
        }
        else if (isShort){

            throw new ODStateException(field,"Field class '"+gap.Objects.StringFromObject(field.getType())+"' is declared 'child' but not declared 'child' in class '"+GetPackageClassName(container)+"'.  This redundancy is required for type integrity.");
        }
        else
            return false;
    }
View Full Code Here

                catch (ClassNotFoundException exc){
                    return null;
                }
            }
            else
                throw new ODStateException(imp,"Import descriptor package spec missing dot-star suffix '"+packageSpec+"'.");
        }
        else if (imp.hasClassName()){
            String packageClassName = imp.getClassName();
            if (packageClassName.endsWith("."+cleanTypeName)){
                try {
View Full Code Here

TOP

Related Classes of gap.service.od.ODStateException

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.