use of org.kie.workbench.common.screens.datamodeller.client.handlers.jpadomain.util.SequenceGeneratorValueHandler in project kie-wb-common by kiegroup.
the class JPADataObjectFieldEditor method updateSequenceGeneratorField.
private void updateSequenceGeneratorField(Annotation annotation) {
clearSequenceGeneratorField();
if (annotation != null) {
SequenceGeneratorValueHandler valueHandler = new SequenceGeneratorValueHandler(annotation);
DataModelerPropertyEditorFieldInfo fieldInfo = getField(JPADataObjectFieldEditorView.SEQUENCE_GENERATOR_FIELD);
fieldInfo.setCurrentValue(SequenceGeneratorValueHandler.NAME, valueHandler.getName());
fieldInfo.setCurrentValue(SequenceGeneratorValueHandler.SEQUENCE_NAME, valueHandler.getSequenceName());
fieldInfo.setCurrentValue(SequenceGeneratorValueHandler.INITIAL_VALUE, valueHandler.getInitialValue());
fieldInfo.setCurrentValue(SequenceGeneratorValueHandler.ALLOCATION_SIZE, valueHandler.getAllocationSize());
updatePropertyEditorField(JPADataObjectFieldEditorView.SEQUENCE_GENERATOR_FIELD, annotation, valueHandler.getName());
}
}
use of org.kie.workbench.common.screens.datamodeller.client.handlers.jpadomain.util.SequenceGeneratorValueHandler in project kie-wb-common by kiegroup.
the class JPADataObjectFieldEditor method onSequenceGeneratorFieldChange.
@Override
public void onSequenceGeneratorFieldChange(DataModelerPropertyEditorFieldInfo fieldInfo, String newValue) {
if (getObjectField() != null) {
Annotation oldGenerator = getObjectField().getAnnotation(JPADomainAnnotations.JAVAX_PERSISTENCE_SEQUENCE_GENERATOR_ANNOTATION);
SequenceGeneratorValueHandler oldGeneratorHandler = oldGenerator != null ? new SequenceGeneratorValueHandler(oldGenerator) : null;
Annotation newGenerator = null;
// and add the new one. This may alter the annotations order for the given field, but it's not a problem.
if (oldGeneratorHandler != null) {
commandBuilder.buildFieldAnnotationRemoveCommand(getContext(), getName(), getDataObject(), getObjectField(), oldGeneratorHandler.getClassName()).execute();
}
String name = DataModelerUtils.nullTrim((String) fieldInfo.getCurrentValue(SequenceGeneratorValueHandler.NAME));
String sequenceName = DataModelerUtils.nullTrim((String) fieldInfo.getCurrentValue(SequenceGeneratorValueHandler.SEQUENCE_NAME));
Integer initialValue = (Integer) fieldInfo.getCurrentValue(SequenceGeneratorValueHandler.INITIAL_VALUE);
Integer allocationSize = (Integer) fieldInfo.getCurrentValue(SequenceGeneratorValueHandler.ALLOCATION_SIZE);
if (name != null && !"".equals(name.trim())) {
newGenerator = SequenceGeneratorValueHandler.createAnnotation(name, sequenceName, initialValue, allocationSize, getContext().getAnnotationDefinitions());
commandBuilder.buildFieldAnnotationAddCommand(getContext(), getName(), getDataObject(), getObjectField(), newGenerator).execute();
}
}
}
Aggregations