Package org.kie.workbench.common.screens.datamodeller.model

Examples of org.kie.workbench.common.screens.datamodeller.model.DataModelTO


            Project project = projectService.resolveProject(path);

            Map<String, AnnotationDefinitionTO> annotationDefs = modelerService.getAnnotationDefinitions();

            DataModelTO dataModel = modelerService.loadModel(project);

            String parentName = "A3";
            String parentPackage = "a";
            DataObjectTO parent = new DataObjectTO(parentName, parentPackage, null);
            dataModel.getDataObjects().add(parent);

            String parentFieldName = "a3_1";
            String parentFieldClass = "java.lang.String";
            ObjectPropertyTO parentProp = new ObjectPropertyTO(parentFieldName, parentFieldClass, false, true);
            parent.setProperties(Arrays.asList(parentProp));

            String extendingName = "B3";
            String extendingPackage = "a.b";
            DataObjectTO extending = new DataObjectTO(extendingName, extendingPackage, null);
            // Extend B from A
            extending.setSuperClassName(parent.getClassName());
            dataModel.getDataObjects().add(extending);

            String extendingFieldName = "b3_1";
            String extendingFieldClass = "java.lang.String";
            ObjectPropertyTO extendingProp = new ObjectPropertyTO(extendingFieldName, extendingFieldClass, false, true);
            extending.setProperties(Arrays.asList(extendingProp));

            GenerationResult result = modelerService.saveModel(dataModel, project);
            assertNotNull(result);
            logger.info("**************************** -> Model saved in " + result.getGenerationTimeSeconds() + " seconds");

            invalidateDMOProjectCache.fire(new InvalidateDMOProjectCacheEvent(null, null, path));
            DataModelTO reloadedModel = modelerService.loadModel(project);
            assertNotNull(reloadedModel);

            ProjectDataModelOracle projectDataModelOracle = dataModelService.getProjectDataModel(path);

            // TODO for the ProjectDataModelOracle, in fact, the getModelFields() method should only return the declared
View Full Code Here


            Project project = projectService.resolveProject(path);

            Map<String, AnnotationDefinitionTO> annotationDefs = modelerService.getAnnotationDefinitions();

            DataModelTO dataModel = modelerService.loadModel(project);

            String objectName = "GeneratedBean";
            String objectPackage = "a.b.c";
            String objectLabelValue = "Generated Bean";
            String objectDescriptionValue = "This is a programmatically added bean";
            String objectRoleValue = "EVENT";
            DataObjectTO dataObject = new DataObjectTO(objectName, objectPackage, null);
            dataObject.addAnnotation(annotationDefs.get(AnnotationDefinitionTO.LABEL_ANNOTATION), AnnotationDefinitionTO.VALUE_PARAM, objectLabelValue);
            dataObject.addAnnotation(annotationDefs.get(AnnotationDefinitionTO.DESCRIPTION_ANNOTATION), AnnotationDefinitionTO.VALUE_PARAM, objectDescriptionValue);
            dataObject.addAnnotation(annotationDefs.get(AnnotationDefinitionTO.ROLE_ANNOTATION), AnnotationDefinitionTO.VALUE_PARAM, objectRoleValue);
            dataModel.getDataObjects().add(dataObject);

            String fieldName = "simpleProperty";
            String fieldClass = "java.lang.String";
            String fieldLabelValue = "Simple Property";
            String fieldDescriptionValue = "This is a programmatically added String property";
            int fieldPositionValue = 1;
            ObjectPropertyTO baseTypeProp = new ObjectPropertyTO(fieldName, fieldClass, false, true);
            baseTypeProp.addAnnotation(annotationDefs.get(AnnotationDefinitionTO.LABEL_ANNOTATION), AnnotationDefinitionTO.VALUE_PARAM, fieldLabelValue);
            baseTypeProp.addAnnotation(annotationDefs.get(AnnotationDefinitionTO.DESCRIPTION_ANNOTATION), AnnotationDefinitionTO.VALUE_PARAM, fieldDescriptionValue);
            baseTypeProp.addAnnotation(annotationDefs.get(AnnotationDefinitionTO.POSITION_ANNOTATON), AnnotationDefinitionTO.VALUE_PARAM, fieldPositionValue);
            dataObject.setProperties(Arrays.asList(baseTypeProp));

            GenerationResult result = modelerService.saveModel(dataModel, project);
            assertNotNull(result);
            logger.info("**************************** -> Model saved in " + result.getGenerationTimeSeconds() + " seconds");

            invalidateDMOProjectCache.fire(new InvalidateDMOProjectCacheEvent(null, null, path));
            DataModelTO reloadedModel = modelerService.loadModel(project);
            assertNotNull(reloadedModel);

            ProjectDataModelOracle projectDataModelOracle = dataModelService.getProjectDataModel(path);
            String types[] = ProjectDataModelOracleUtils.getFactTypes(projectDataModelOracle);
            if (types != null) {
View Full Code Here

            Project project = projectService.resolveProject(path);

            Map<String, AnnotationDefinitionTO> annotationDefs = modelerService.getAnnotationDefinitions();

            DataModelTO dataModel = modelerService.loadModel(project);

            String parentName = "A";
            String parentPackage = "a";
            DataObjectTO parent = new DataObjectTO(parentName, parentPackage, null);
            dataModel.getDataObjects().add(parent);

            String parentFieldName = "a_1";
            String parentFieldClass = "java.lang.String";
            ObjectPropertyTO parentProp = new ObjectPropertyTO(parentFieldName, parentFieldClass, false, true);
            parent.setProperties(Arrays.asList(parentProp));

            String extendingName = "B";
            String extendingPackage = "a.b";
            DataObjectTO extending = new DataObjectTO(extendingName, extendingPackage, null);
            // Extend B from A
            extending.setSuperClassName(parent.getClassName());
            dataModel.getDataObjects().add(extending);

            String extendingFieldName = "b_1";
            String extendingFieldClass = "java.lang.String";
            ObjectPropertyTO extendingProp = new ObjectPropertyTO(extendingFieldName, extendingFieldClass, false, true);
            extending.setProperties(Arrays.asList(extendingProp));

            GenerationResult result = modelerService.saveModel(dataModel, project);
            assertNotNull(result);
            logger.info("**************************** -> Model saved in " + result.getGenerationTimeSeconds() + " seconds");

            invalidateDMOProjectCache.fire(new InvalidateDMOProjectCacheEvent(null, null, path));
            DataModelTO reloadedModel = modelerService.loadModel(project);
            assertNotNull(reloadedModel);

        } catch (Throwable e) {
            logger.error("Test failed : " + e.getMessage(), e);
            fail();
View Full Code Here

            Project project = projectService.resolveProject(path);

            Map<String, AnnotationDefinitionTO> annotationDefs = modelerService.getAnnotationDefinitions();

            DataModelTO dataModel = modelerService.loadModel(project);

            String parentName = "A2";
            String parentPackage = "a";
            String parentLabelValue = "Parent";
            String parentDescriptionValue = "This is the parent object";
            String parentRoleValue = "EVENT";
            DataObjectTO parent = new DataObjectTO(parentName, parentPackage, null);
            parent.addAnnotation(annotationDefs.get(AnnotationDefinitionTO.LABEL_ANNOTATION), AnnotationDefinitionTO.VALUE_PARAM, parentLabelValue);
            parent.addAnnotation(annotationDefs.get(AnnotationDefinitionTO.DESCRIPTION_ANNOTATION), AnnotationDefinitionTO.VALUE_PARAM, parentDescriptionValue);
            parent.addAnnotation(annotationDefs.get(AnnotationDefinitionTO.ROLE_ANNOTATION), AnnotationDefinitionTO.VALUE_PARAM, parentRoleValue);
            dataModel.getDataObjects().add(parent);

            String parentFieldName = "a2_1";
            String parentFieldClass = "java.lang.String";
            String parentFieldLabelValue = "Attribute A2.1";
            String parentFieldDescriptionValue = "First attribute of A2";
            int parentFieldPositionValue = 1;
            ObjectPropertyTO parentProp = new ObjectPropertyTO(parentFieldName, parentFieldClass, false, true);
            parentProp.addAnnotation(annotationDefs.get(AnnotationDefinitionTO.LABEL_ANNOTATION), AnnotationDefinitionTO.VALUE_PARAM, parentFieldLabelValue);
            parentProp.addAnnotation(annotationDefs.get(AnnotationDefinitionTO.DESCRIPTION_ANNOTATION), AnnotationDefinitionTO.VALUE_PARAM, parentFieldDescriptionValue);
            parentProp.addAnnotation(annotationDefs.get(AnnotationDefinitionTO.POSITION_ANNOTATON), AnnotationDefinitionTO.VALUE_PARAM, parentFieldPositionValue);
            parent.setProperties(Arrays.asList(parentProp));

            String extendingName = "B2";
            String extendingPackage = "a.b";
            String extendingLabelValue = "Extending";
            String extendingDescriptionValue = "This is the extending object";
            String extendingRoleValue = "EVENT";
            DataObjectTO extending = new DataObjectTO(extendingName, extendingPackage, null);
            // Extend B from A
            extending.setSuperClassName(parent.getClassName());
            extending.addAnnotation(annotationDefs.get(AnnotationDefinitionTO.LABEL_ANNOTATION), AnnotationDefinitionTO.VALUE_PARAM, extendingLabelValue);
            extending.addAnnotation(annotationDefs.get(AnnotationDefinitionTO.DESCRIPTION_ANNOTATION), AnnotationDefinitionTO.VALUE_PARAM, extendingDescriptionValue);
            extending.addAnnotation(annotationDefs.get(AnnotationDefinitionTO.ROLE_ANNOTATION), AnnotationDefinitionTO.VALUE_PARAM, extendingRoleValue);
            dataModel.getDataObjects().add(extending);

            String extendingFieldName = "b2_1";
            String extendingFieldClass = "java.lang.String";
            String extendingFieldLabelValue = "Attribute B2.1";
            String extendingFieldDescriptionValue = "First attribute of B2";
            int extendingFieldPositionValue = 1;
            ObjectPropertyTO extendingProp = new ObjectPropertyTO(extendingFieldName, extendingFieldClass, false, true);
            extendingProp.addAnnotation(annotationDefs.get(AnnotationDefinitionTO.LABEL_ANNOTATION), AnnotationDefinitionTO.VALUE_PARAM, extendingFieldLabelValue);
            extendingProp.addAnnotation(annotationDefs.get(AnnotationDefinitionTO.DESCRIPTION_ANNOTATION), AnnotationDefinitionTO.VALUE_PARAM, extendingFieldDescriptionValue);
            extendingProp.addAnnotation(annotationDefs.get(AnnotationDefinitionTO.POSITION_ANNOTATON), AnnotationDefinitionTO.VALUE_PARAM, extendingFieldPositionValue);
            extending.setProperties(Arrays.asList(extendingProp));

            GenerationResult result = modelerService.saveModel(dataModel, project);
            assertNotNull(result);
            logger.info("**************************** -> Model saved in " + result.getGenerationTimeSeconds() + " seconds");

            invalidateDMOProjectCache.fire(new InvalidateDMOProjectCacheEvent(null, null, path));
            DataModelTO reloadedModel = modelerService.loadModel(project);
            assertNotNull(reloadedModel);

        } catch (Throwable e) {
            logger.error("Test failed : " + e.getMessage(), e);
            fail();
View Full Code Here

            Project project = projectService.resolveProject(path);

            Map<String, AnnotationDefinitionTO> annotationDefs = modelerService.getAnnotationDefinitions();

            DataModelTO dataModel = modelerService.loadModel(project);

            String parentName = "A3";
            String parentPackage = "a";
            DataObjectTO parent = new DataObjectTO(parentName, parentPackage, null);
            dataModel.getDataObjects().add(parent);

            String parentFieldName = "a3_1";
            String parentFieldClass = "java.lang.String";
            ObjectPropertyTO parentProp = new ObjectPropertyTO(parentFieldName, parentFieldClass, false, true);
            parent.setProperties(Arrays.asList(parentProp));

            String extendingName = "B3";
            String extendingPackage = "a.b";
            DataObjectTO extending = new DataObjectTO(extendingName, extendingPackage, null);
            // Extend B from A
            extending.setSuperClassName(parent.getClassName());
            dataModel.getDataObjects().add(extending);

            String extendingFieldName = "b3_1";
            String extendingFieldClass = "java.lang.String";
            ObjectPropertyTO extendingProp = new ObjectPropertyTO(extendingFieldName, extendingFieldClass, false, true);
            extending.setProperties(Arrays.asList(extendingProp));

            GenerationResult result = modelerService.saveModel(dataModel, project);
            assertNotNull(result);
            logger.info("**************************** -> Model saved in " + result.getGenerationTimeSeconds() + " seconds");

            invalidateDMOProjectCache.fire(new InvalidateDMOProjectCacheEvent(null, null, path));
            DataModelTO reloadedModel = modelerService.loadModel(project);
            assertNotNull(reloadedModel);

            ProjectDataModelOracle projectDataModelOracle = dataModelService.getProjectDataModel(path);

            // TODO for the ProjectDataModelOracle, in fact, the getModelFields() method should only return the declared
View Full Code Here

        try {
            Asset jcrAsset = jcrRepositoryAssetService.loadRuleAsset( jcrAssetItem.getUUID() );

            FactModels factModels = ( (FactModels) jcrAsset.getContent() );
            DataModelTO dataModelTO = new DataModelTO();

            String packageName = getPackageName( jcrModule );
            packageName = migrationPathManager.normalizePackageName( packageName );
            AnnotationDefinitionTO positionAnnotationDef = getPositionAnnotationDefinition();

            for ( FactMetaModel factMetaModel : factModels.models ) {
                DataObjectTO dataObjectTO = createDataObject( packageName, factMetaModel.getName(), factMetaModel.getSuperType() );
                List<AnnotationMetaModel> annotationMetaModel = factMetaModel.getAnnotations();
                addAnnotations( dataObjectTO, annotationMetaModel );
                List<FieldMetaModel> fields = factMetaModel.getFields();

                int position = 0;
                for ( FieldMetaModel fieldMetaModel : fields ) {
                    String filedName = fieldMetaModel.name;
                    String fildType = fieldMetaModel.type;
                    //Guvnor 5.5 (and earlier) does not have MultipleType
                    boolean isMultiple = false;
                    boolean isBaseType = isBaseType( fildType );
                    ObjectPropertyTO property = new ObjectPropertyTO( filedName,
                                                                      fildType,
                                                                      isMultiple,
                                                                      isBaseType );
                    property.addAnnotation( positionAnnotationDef, AnnotationDefinitionTO.VALUE_PARAM, position + "" );
                    position++;
                    //field has no annotation in Guvnor 5.5 (and earlier)
                    dataObjectTO.getProperties().add( property );
                }

                dataModelTO.getDataObjects().add( dataObjectTO );
            }

            modelerService.saveModel( dataModelTO, project );

        } catch ( SerializationException e ) {
View Full Code Here

        final Project project = projectService.resolveProject( context );

        for ( String declaredType : declaredTypes ) {
            final FactModels factModels = FactModelPersistence.unmarshal( declaredType );
            final String packageName = factModels.getPackageName();
            final DataModelTO dataModelTO = new DataModelTO();

            for ( FactMetaModel factMetaModel : factModels.getModels() ) {
                final DataObjectTO dataObjectTO = new DataObjectTO( factMetaModel.getName(),
                                                                    packageName,
                                                                    factMetaModel.getSuperType() );
                final List<AnnotationMetaModel> annotationMetaModel = factMetaModel.getAnnotations();
                addAnnotations( dataObjectTO,
                                annotationMetaModel );

                final List<FieldMetaModel> fields = factMetaModel.getFields();

                for ( FieldMetaModel fieldMetaModel : fields ) {
                    final String fieldName = fieldMetaModel.name;
                    final String fieldType = fieldMetaModel.type;
                    //Guvnor 5.5 (and earlier) does not have MultipleType
                    boolean isMultiple = false;
                    boolean isBaseType = orderedBaseTypes.containsValue( fieldType );
                    ObjectPropertyTO property = new ObjectPropertyTO( fieldName,
                                                                      fieldType,
                                                                      isMultiple,
                                                                      isBaseType );
                    //field has no annotation in Guvnor 5.5 (and earlier)
                    dataObjectTO.getProperties().add( property );

                    result.addMessage( "Created Java Type " + getJavaTypeFQCN( dataObjectTO ),
                                       ConversionMessageType.INFO );
                }

                dataModelTO.getDataObjects().add( dataObjectTO );
            }

            modellerService.saveModel( dataModelTO,
                                       project );
        }
View Full Code Here

  
        try {
            Asset jcrAsset = jcrRepositoryAssetService.loadRuleAsset(jcrAssetItem.getUUID());
           
            FactModels factModels = ((FactModels) jcrAsset.getContent());
            DataModelTO dataModelTO  = new DataModelTO();
           
            String packageName = getPackageName(jcrModule);
           
            for ( FactMetaModel factMetaModel : factModels.models ) {
                DataObjectTO dataObjectTO = createDataObject(packageName, factMetaModel.getName(), factMetaModel.getSuperType());
              List<AnnotationMetaModel> annotationMetaModel = factMetaModel.getAnnotations();               
              addAnnotations(dataObjectTO, annotationMetaModel);
                List<FieldMetaModel> fields = factMetaModel.getFields();
               
                for(FieldMetaModel fieldMetaModel : fields) {
                  String filedName = fieldMetaModel.name;
                  String fildType = fieldMetaModel.type;
                  //Guvnor 5.5 (and earlier) does not have MultipleType
                  boolean isMultiple = false;
                  boolean isBaseType = isBaseType(fildType);
                    ObjectPropertyTO property = new ObjectPropertyTO(filedName,
                        fildType,
                            isMultiple,
                            isBaseType);             
                  //field has no annotation in Guvnor 5.5 (and earlier)
                    dataObjectTO.getProperties().add(property);
                }
               
                dataModelTO.getDataObjects().add(dataObjectTO);
            }
           
            modelerService.saveModel(dataModelTO, project);

        } catch (SerializationException e) {
View Full Code Here

        final Project project = projectService.resolveProject( context );

        for ( String declaredType : declaredTypes ) {
            final FactModels factModels = FactModelPersistence.unmarshal( declaredType );
            final String packageName = factModels.getPackageName();
            final DataModelTO dataModelTO = new DataModelTO();

            for ( FactMetaModel factMetaModel : factModels.getModels() ) {
                final DataObjectTO dataObjectTO = new DataObjectTO( factMetaModel.getName(),
                                                                    packageName,
                                                                    factMetaModel.getSuperType() );
                final List<AnnotationMetaModel> annotationMetaModel = factMetaModel.getAnnotations();
                addAnnotations( dataObjectTO,
                                annotationMetaModel );

                final List<FieldMetaModel> fields = factMetaModel.getFields();

                for ( FieldMetaModel fieldMetaModel : fields ) {
                    final String fieldName = fieldMetaModel.name;
                    final String fieldType = fieldMetaModel.type;
                    //Guvnor 5.5 (and earlier) does not have MultipleType
                    boolean isMultiple = false;
                    boolean isBaseType = orderedBaseTypes.containsValue( fieldType );
                    ObjectPropertyTO property = new ObjectPropertyTO( fieldName,
                                                                      fieldType,
                                                                      isMultiple,
                                                                      isBaseType );
                    //field has no annotation in Guvnor 5.5 (and earlier)
                    dataObjectTO.getProperties().add( property );

                    result.addMessage( "Created Java Type " + getJavaTypeFQCN( dataObjectTO ),
                                       ConversionMessageType.INFO );
                }

                dataModelTO.getDataObjects().add( dataObjectTO );
            }

            modellerService.saveModel( dataModelTO,
                                       project );
        }
View Full Code Here

TOP

Related Classes of org.kie.workbench.common.screens.datamodeller.model.DataModelTO

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.