Search in sources :

Example 21 with DataObject

use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.

the class DroolsDataObjectFieldEditor method loadDataObjectField.

@Override
protected void loadDataObjectField(DataObject dataObject, ObjectProperty objectField) {
    clear();
    setReadonly(true);
    if (dataObject != null && objectField != null) {
        this.dataObject = dataObject;
        this.objectField = objectField;
        Annotation annotation = objectField.getAnnotation(DroolsDomainAnnotations.KEY_ANNOTATION);
        if (annotation != null) {
            view.setEquals(Boolean.TRUE);
        }
        annotation = objectField.getAnnotation(DroolsDomainAnnotations.POSITION_ANNOTATION);
        if (annotation != null) {
            Object positionValue = annotation.getValue(DroolsDomainAnnotations.VALUE_PARAM);
            String position = positionValue != null ? positionValue.toString() : "";
            view.setPosition(position);
        }
        setReadonly(getContext() == null || getContext().isReadonly());
    }
}
Also used : DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) Annotation(org.kie.workbench.common.services.datamodeller.core.Annotation)

Example 22 with DataObject

use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.

the class ValidatorService method isUniqueEntityName.

public void isUniqueEntityName(String packageName, String name, DataModel model, ValidatorCallback callback) {
    Boolean b = Boolean.TRUE;
    String className = assembleClassName(packageName, name);
    for (DataObject d : model.getDataObjects()) {
        if (d.getClassName().equals(className)) {
            b = Boolean.FALSE;
            break;
        }
    }
    if (b) {
        callback.onSuccess();
    } else {
        callback.onFailure();
    }
}
Also used : DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject)

Example 23 with DataObject

use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.

the class DataModelHelper method reset.

// Todo can be improved if required for performance reasons
// Brute force recalculate all
private void reset() {
    referencedBy.clear();
    references.clear();
    classNames.clear();
    labelledClassNames.clear();
    offspringMap.clear();
    if (dataModel != null) {
        for (DataObject extClassName : dataModel.getExternalClasses()) {
            classNames.put(extClassName.getClassName(), null);
            labelledClassNames.put(extClassName.getClassName(), extClassName.getClassName());
        }
        for (DataObject object : dataModel.getDataObjects()) {
            String className = object.getClassName();
            classNames.put(className, AnnotationValueHandler.getStringValue(object, MainDomainAnnotations.LABEL_ANNOTATION));
            labelledClassNames.put(DataModelerUtils.getDataObjectFullLabel(object), className);
            String superClassName = object.getSuperClassName();
            if (superClassName != null && !"".equals(superClassName))
                objectExtended(superClassName, className, true);
            for (ObjectProperty prop : object.getProperties()) {
                if (!prop.isBaseType()) {
                    objectReferenced(prop.getClassName(), object.getClassName());
                }
            }
        }
    }
}
Also used : ObjectProperty(org.kie.workbench.common.services.datamodeller.core.ObjectProperty) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject)

Example 24 with DataObject

use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.

the class DataModelerScreenPresenter method rename.

private void rename(final boolean saveCurrentChanges) {
    final DataObject[] modifiedDataObject = new DataObject[1];
    if (saveCurrentChanges) {
        if (isDirty()) {
            if (context.isEditorChanged()) {
                // at save time the source has always priority over the model.
                // If the source was properly parsed and the editor has changes, we need to send the DataObject
                // to the server in order to let the source to be updated prior to save.
                modifiedDataObject[0] = context.getDataObject();
            } else {
                // if the source has changes, no update form the UI to the source will be performed.
                // instead the parsed DataObject must be returned from the server.
                modifiedDataObject[0] = null;
            }
        }
    }
    renamePopUpPresenter.show(versionRecordManager.getPathToLatest(), javaAssetUpdateValidator, new CommandWithFileNameAndCommitMessage() {

        @Override
        public void execute(final FileNameAndCommitMessage details) {
            view.showBusyIndicator(org.kie.workbench.common.widgets.client.resources.i18n.CommonConstants.INSTANCE.Renaming());
            modelerService.call(getRenameSuccessCallback(renamePopUpPresenter.getView()), getRenameErrorCallback(renamePopUpPresenter.getView())).rename(versionRecordManager.getPathToLatest(), details.getNewFileName(), details.getCommitMessage(), true, saveCurrentChanges, getSource(), modifiedDataObject[0], metadata);
        }
    });
}
Also used : FileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.FileNameAndCommitMessage) CommandWithFileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.CommandWithFileNameAndCommitMessage) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) CommandWithFileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.CommandWithFileNameAndCommitMessage)

Example 25 with DataObject

use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.

the class DataModelerInnerTypesWeldTest method dataModelerShouldIgnoreEnumFieldsOfInnerClasses.

@Test
public void dataModelerShouldIgnoreEnumFieldsOfInnerClasses() throws Exception {
    KieModule module = loadProjectFromResources("/TestInnerTypes");
    DataModel dataModel = dataModelService.loadModel(module);
    DataObject dataObject = dataModel.getDataObject("test.Outer");
    assertNotNull("DataObject test.Outer should be loaded", dataObject);
    assertEquals("Enum fields of inner classes of test.Outer DataObject should be ignored", 0, dataObject.getProperties().size());
}
Also used : DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) DataModel(org.kie.workbench.common.services.datamodeller.core.DataModel) KieModule(org.kie.workbench.common.services.shared.project.KieModule) Test(org.junit.Test)

Aggregations

DataObject (org.kie.workbench.common.services.datamodeller.core.DataObject)95 Test (org.junit.Test)45 ObjectProperty (org.kie.workbench.common.services.datamodeller.core.ObjectProperty)40 DataModel (org.kie.workbench.common.services.datamodeller.core.DataModel)29 Annotation (org.kie.workbench.common.services.datamodeller.core.Annotation)28 DataObjectImpl (org.kie.workbench.common.services.datamodeller.core.impl.DataObjectImpl)21 ArrayList (java.util.ArrayList)17 AnnotationValuesAnnotation (org.kie.workbench.common.services.datamodeller.annotations.AnnotationValuesAnnotation)17 ClassAnnotation (org.kie.workbench.common.services.datamodeller.annotations.ClassAnnotation)17 EnumsAnnotation (org.kie.workbench.common.services.datamodeller.annotations.EnumsAnnotation)17 MarkerAnnotation (org.kie.workbench.common.services.datamodeller.annotations.MarkerAnnotation)17 PrimitivesAnnotation (org.kie.workbench.common.services.datamodeller.annotations.PrimitivesAnnotation)17 TestAnnotation (org.kie.workbench.common.services.datamodeller.parser.test.TestAnnotation)17 AnnotationImpl (org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl)16 DomainEditorBaseTest (org.kie.workbench.common.screens.datamodeller.client.widgets.DomainEditorBaseTest)15 MethodImpl (org.kie.workbench.common.services.datamodeller.core.impl.MethodImpl)12 List (java.util.List)11 TypeImpl (org.kie.workbench.common.services.datamodeller.core.impl.TypeImpl)11 Method (org.kie.workbench.common.services.datamodeller.core.Method)10 Generated (javax.annotation.Generated)8