Search in sources :

Example 1 with DataObject

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

the class NestedFormsBPMNVFSFormDefinitionGeneratorServiceTest method getLineDataObject.

protected DataObject getLineDataObject() {
    DataObject expense = new DataObjectImpl(Line.class.getPackage().toString(), Line.class.getSimpleName());
    expense.addProperty("id", Long.class.getName(), false, null);
    expense.addProperty("date", Date.class.getName(), false, null);
    expense.addProperty("product", String.class.getName(), false, null);
    expense.addProperty("price", Double.class.getName(), false, null);
    return expense;
}
Also used : DataObjectImpl(org.kie.workbench.common.services.datamodeller.core.impl.DataObjectImpl) Line(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.model.Line) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) Matchers.anyString(org.mockito.Matchers.anyString) Date(java.util.Date)

Example 2 with DataObject

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

the class NestedFormsBPMNVFSFormDefinitionGeneratorServiceTest method getClientDataObject.

protected DataObject getClientDataObject() {
    DataObject client = new DataObjectImpl(Client.class.getPackage().toString(), Client.class.getSimpleName());
    client.addProperty("id", Long.class.getName(), false, null);
    client.addProperty("name", String.class.getName(), false, null);
    client.addProperty("lastName", String.class.getName(), false, null);
    return client;
}
Also used : DataObjectImpl(org.kie.workbench.common.services.datamodeller.core.impl.DataObjectImpl) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) Matchers.anyString(org.mockito.Matchers.anyString) Client(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.model.Client)

Example 3 with DataObject

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

the class DataModelerScreenPresenter method onValidate.

protected Command onValidate() {
    return new Command() {

        @Override
        public void execute() {
            // at validation time we must do the same calculation as if we were about to save.
            final DataObject[] modifiedDataObject = new DataObject[1];
            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;
                }
            }
            modelerService.call(new RemoteCallback<List<org.guvnor.common.services.shared.validation.model.ValidationMessage>>() {

                @Override
                public void callback(final List<org.guvnor.common.services.shared.validation.model.ValidationMessage> results) {
                    if (results == null || results.isEmpty()) {
                        notification.fire(new NotificationEvent(org.kie.workbench.common.widgets.client.resources.i18n.CommonConstants.INSTANCE.ItemValidatedSuccessfully(), NotificationEvent.NotificationType.SUCCESS));
                    } else {
                        validationPopup.showMessages(results);
                    }
                }
            }).validate(getSource(), versionRecordManager.getCurrentPath(), modifiedDataObject[0]);
        }
    };
}
Also used : ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) List(java.util.List)

Example 4 with DataObject

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

the class RemovePropertyCommandTest method execute.

@Test
public void execute() {
    DataObject dataObject = new DataObjectImpl("org.test", "TestDataObject");
    dataObject.addProperty(new ObjectPropertyImpl("testProperty", Integer.class.getName(), false));
    DataModelChangeNotifier notifier = mock(DataModelChangeNotifier.class);
    RemovePropertyCommand command = new RemovePropertyCommand(new DataModelerContext(), "source", dataObject, "testProperty", notifier);
    command.execute();
    assertNull(dataObject.getProperty("testProperty"));
    verify(notifier, times(1)).notifyChange(any(DataObjectFieldDeletedEvent.class));
}
Also used : DataObjectImpl(org.kie.workbench.common.services.datamodeller.core.impl.DataObjectImpl) ObjectPropertyImpl(org.kie.workbench.common.services.datamodeller.core.impl.ObjectPropertyImpl) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) DataObjectFieldDeletedEvent(org.kie.workbench.common.screens.datamodeller.events.DataObjectFieldDeletedEvent) DataModelerContext(org.kie.workbench.common.screens.datamodeller.client.DataModelerContext) Test(org.junit.Test)

Example 5 with DataObject

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

the class DataObjectBrowserTest method removePropertyTest.

@Test
public void removePropertyTest() {
    DataObjectBrowser objectBrowser = createBrowser();
    DataModelerContext context = createContext();
    // the dataObject has fields: field1, field2 and field3
    DataObject dataObject = context.getDataObject();
    ObjectProperty objectProperty = dataObject.getProperty("field3");
    int count = dataObject.getProperties().size();
    context.getEditorModelContent().setPath(dummyPath);
    objectBrowser.setContext(context);
    when(assetsUsageService.getAssetPartUsages(any(), any(), any(), any())).thenReturn(new ArrayList<>());
    // field3 is on position 2 by construction.
    objectBrowser.onDeleteProperty(objectProperty, 2);
    verify(showAssetUsagesDisplayer).showAssetPartUsages(anyString(), any(), any(), any(), any(), any(), any());
    // if field3 was removed, then field2 should have been selected.
    verify(view).setSelectedRow(dataObject.getProperty("field2"), true);
    // an even should have been fired with the notification of the just removed property.
    verify(dataModelerEvent, times(1)).fire(any(DataModelerEvent.class));
    verify(view, times(1)).setTableHeight(DataObjectBrowser.DataObjectBrowserHelper.calculateTableHeight(count));
    verify(view, times(2)).setTableHeight(DataObjectBrowser.DataObjectBrowserHelper.calculateTableHeight(count - 1));
    // the dataObject should now have one less property.
    assertEquals((count - 1), dataObject.getProperties().size());
}
Also used : ObjectProperty(org.kie.workbench.common.services.datamodeller.core.ObjectProperty) DataModelerEvent(org.kie.workbench.common.screens.datamodeller.events.DataModelerEvent) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) DataModelerContext(org.kie.workbench.common.screens.datamodeller.client.DataModelerContext) DomainEditorBaseTest(org.kie.workbench.common.screens.datamodeller.client.widgets.DomainEditorBaseTest) 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