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;
}
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;
}
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]);
}
};
}
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));
}
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());
}
Aggregations