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