use of org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl in project kie-wb-common by kiegroup.
the class SequenceGeneratorValueHandler method createAnnotation.
public static Annotation createAnnotation(String name, String sequenceName, Integer initialValue, Integer allocationSize, Map<String, AnnotationDefinition> annotationDefinitions) {
SequenceGeneratorValueHandler valueHandler = new SequenceGeneratorValueHandler(new AnnotationImpl(annotationDefinitions.get(JPADomainAnnotations.JAVAX_PERSISTENCE_SEQUENCE_GENERATOR_ANNOTATION)));
valueHandler.setName(name);
valueHandler.setSequenceName(sequenceName);
valueHandler.setInitialValue(initialValue);
valueHandler.setAllocationSize(allocationSize);
return valueHandler.getAnnotation();
}
use of org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl in project kie-wb-common by kiegroup.
the class SequenceGeneratorValueHandler method createAnnotation.
public static Annotation createAnnotation(String name, String sequenceName, Map<String, AnnotationDefinition> annotationDefinitions) {
SequenceGeneratorValueHandler valueHandler = new SequenceGeneratorValueHandler(new AnnotationImpl(annotationDefinitions.get(JPADomainAnnotations.JAVAX_PERSISTENCE_SEQUENCE_GENERATOR_ANNOTATION)));
valueHandler.setName(name);
valueHandler.setSequenceName(sequenceName);
return valueHandler.getAnnotation();
}
use of org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl in project kie-wb-common by kiegroup.
the class MethodAddAnnotationCommand method execute.
@Override
public void execute() {
if (annotation == null) {
annotation = new AnnotationImpl(context.getAnnotationDefinition(annotationClassName));
if (valuePairs != null) {
for (ValuePair valuePair : valuePairs) {
annotation.setValue(valuePair.getName(), valuePair.getValue());
}
}
}
Annotation existingAnnotation = method.getAnnotation(annotation.getClassName());
if (existingAnnotation != null) {
method.removeAnnotation(annotation.getClassName());
}
method.addAnnotation(annotation);
DataModelerEvent event = new DataObjectChangeEvent().withChangeType(ChangeType.METHOD_ANNOTATION_ADD_CHANGE).withOldValue(null).withNewValue(this.annotation).withContextId(getContext().getContextId()).withSource(getSource()).withCurrentDataObject(getDataObject()).withCurrentMethod(method);
notifyChange(event);
}
use of org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl in project kie-wb-common by kiegroup.
the class DataObjectAnnotationValueChangeCommand method execute.
@Override
public void execute() {
Object oldValue = null;
Annotation annotation = dataObject.getAnnotation(annotationClassName);
if (annotation != null) {
oldValue = annotation.getValue(valuePair);
if (newValue != null && !newValue.equals(oldValue)) {
// notify annotation value change
annotation.setValue(valuePair, newValue);
notifyObjectChange(ChangeType.TYPE_ANNOTATION_VALUE_CHANGE, context, source, dataObject, annotationClassName, valuePair, oldValue, newValue);
} else if (newValue == null && oldValue != null) {
if (removeAnnotationIfValueIsNull) {
dataObject.removeAnnotation(annotationClassName);
// notify annotation removed
notifyObjectChange(ChangeType.TYPE_ANNOTATION_REMOVE_CHANGE, context, source, dataObject, annotationClassName, valuePair, oldValue, newValue);
} else {
annotation.setValue(valuePair, newValue);
// notify annotation value change
notifyObjectChange(ChangeType.TYPE_ANNOTATION_VALUE_CHANGE, context, source, dataObject, annotationClassName, valuePair, oldValue, newValue);
}
}
} else if (newValue != null) {
annotation = new AnnotationImpl(context.getAnnotationDefinitions().get(annotationClassName));
annotation.setValue(valuePair, newValue);
dataObject.addAnnotation(annotation);
// notify annotation added
notifyObjectChange(ChangeType.TYPE_ANNOTATION_ADD_CHANGE, context, source, dataObject, annotationClassName, valuePair, oldValue, newValue);
}
}
use of org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl in project kie-wb-common by kiegroup.
the class FieldAddAnnotationCommand method execute.
@Override
public void execute() {
if (annotation == null) {
annotation = new AnnotationImpl(context.getAnnotationDefinition(annotationClassName));
if (valuePairs != null) {
for (ValuePair valuePair : valuePairs) {
annotation.setValue(valuePair.getName(), valuePair.getValue());
}
}
}
field.addAnnotation(annotation);
notifyFieldChange(ChangeType.FIELD_ANNOTATION_ADD_CHANGE, context, source, dataObject, field, annotation.getClassName(), null, null, null);
}
Aggregations