本文整理汇总了Java中org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition类的典型用法代码示例。如果您正苦于以下问题:Java AnnotationDefinition类的具体用法?Java AnnotationDefinition怎么用?Java AnnotationDefinition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnnotationDefinition类属于org.kie.workbench.common.services.datamodeller.core包,在下文中一共展示了AnnotationDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onClearValuePair
import org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition; //导入依赖的package包/类
protected void onClearValuePair(Annotation annotation,
String valuePair) {
AnnotationDefinition annotationDefinition = annotation.getAnnotationDefinition();
AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair(valuePair);
if (valuePairDefinition.getDefaultValue() == null) {
//if the value pair has no default value, it should be applied wherever the annotation is applied, if not
//the resulting code won't compile.
String message = Constants.INSTANCE.advanced_domain_annotation_list_editor_message_value_pair_has_no_default_value(valuePair,
annotation.getClassName());
view.showYesNoDialog(message,
getNoActionCommand());
} else if (clearValuePairHandler != null) {
clearValuePairHandler.onClearValuePair(annotation,
valuePair);
}
}
示例2: createTestContext
import org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition; //导入依赖的package包/类
public static DataModelerContext createTestContext() {
DataModelerContext context = new DataModelerContext("123456789");
context.init(PropertyTypeFactoryImpl.getInstance().getBasePropertyTypes());
List<AnnotationDefinition> commonAnnotations = CommonAnnotations.getCommonAnnotations();
Map<String, AnnotationDefinition> annotationDefinitions = new HashMap<String, AnnotationDefinition>();
for (AnnotationDefinition annotationDefinition : commonAnnotations) {
annotationDefinitions.put(annotationDefinition.getClassName(), annotationDefinition);
}
context.setAnnotationDefinitions(annotationDefinitions);
EditorModelContent content = new EditorModelContent();
content.setDataModel(createTestModel());
content.setCurrentModule(new KieModule());
context.setEditorModelContent(content);
return context;
}
示例3: testPageInitialization
import org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition; //导入依赖的package包/类
@Test
public void testPageInitialization() {
modelerServiceCaller = new CallerMock<DataModelerService>(modelerService);
ValuePairEditorPage editorPage = new ValuePairEditorPage(view,
valuePairEditorProvider,
modelerServiceCaller,
wizardPageStatusChangeEvent);
editorPage.prepareView();
AnnotationDefinition annotationDefinition = DriverUtils.buildAnnotationDefinition(Entity.class);
AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair("name");
when(valuePairEditorProvider.getValuePairEditor(valuePairDefinition)).thenReturn(valuePairEditor);
editorPage.init(annotationDefinition, valuePairDefinition, ElementType.FIELD,
kieModule);
//the view should be properly initialized with the corresponding editor.
verify(view, times(1)).setValuePairEditor(valuePairEditor);
WizardTestUtil.assertPageComplete(true, editorPage); //the "name" value pair is not mandatory, so the page is completed.
}
示例4: createAnnotationDefinition
import org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition; //导入依赖的package包/类
protected AnnotationDefinition createAnnotationDefinition( NumberType numberType ) {
AnnotationDefinition annotationDefinition = null;
switch ( numberType ) {
case BYTE:
annotationDefinition = createAnnotationDefinition( ByteParamsAnnotation.class );
break;
case SHORT:
annotationDefinition = createAnnotationDefinition( ShortParamsAnnotation.class );
break;
case INT:
annotationDefinition = createAnnotationDefinition( IntParamsAnnotation.class );
break;
case LONG:
annotationDefinition = createAnnotationDefinition( LongParamsAnnotation.class );
break;
case FLOAT:
annotationDefinition = createAnnotationDefinition( FloatParamsAnnotation.class );
break;
case DOUBLE:
annotationDefinition = createAnnotationDefinition( DoubleParamsAnnotation.class );
break;
}
return annotationDefinition;
}
示例5: resolveDefinitionRequest
import org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition; //导入依赖的package包/类
@Override
public AnnotationDefinitionResponse resolveDefinitionRequest(AnnotationDefinitionRequest definitionRequest,
KieModule kieModule) {
JavaRoasterModelDriver modelDriver = new JavaRoasterModelDriver();
ClassLoader classLoader = classLoaderHelper.getModuleClassLoader(kieModule);
ClassTypeResolver classTypeResolver = DriverUtils.createClassTypeResolver(classLoader);
AnnotationDefinitionResponse definitionResponse = new AnnotationDefinitionResponse();
try {
AnnotationDefinition annotationDefinition = modelDriver.buildAnnotationDefinition(definitionRequest.getClassName(),
classTypeResolver);
definitionResponse.withAnnotationDefinition(annotationDefinition);
} catch (ModelDriverException e) {
DriverError driverError = new DriverError(e.getMessage());
definitionResponse.addError(driverError);
}
return definitionResponse;
}
示例6: buildAnnotation
import org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition; //导入依赖的package包/类
@Override
public Annotation buildAnnotation(AnnotationDefinition annotationDefinition, Object annotationToken) throws ModelDriverException {
org.kie.soup.project.datamodel.oracle.Annotation oracleAnnotationToken = (org.kie.soup.project.datamodel.oracle.Annotation)annotationToken;
AnnotationImpl annotation = new AnnotationImpl(annotationDefinition);
if (annotationDefinition.isMarker()) {
return annotation;
} else if (oracleAnnotationToken.getParameters() != null) {
Object currentAttributeValue;
for (AnnotationValuePairDefinition annotationMember : annotationDefinition.getValuePairs()) {
currentAttributeValue = oracleAnnotationToken.getParameters().get(annotationMember.getName());
if (currentAttributeValue != null) {
annotation.setValue(annotationMember.getName(), currentAttributeValue);
}
}
}
return annotation;
}
示例7: createAnnotation
import org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition; //导入依赖的package包/类
private Annotation createAnnotation(AnnotationSource annotationToken,
ClassTypeResolver classTypeResolver) throws ModelDriverException {
AnnotationDefinition annotationDefinition;
Annotation annotation = null;
annotationDefinition = buildAnnotationDefinition(annotationToken,
classTypeResolver);
if (annotationDefinition != null) {
AnnotationDriver annotationDriver = new DefaultJavaRoasterModelAnnotationDriver();
annotation = annotationDriver.buildAnnotation(annotationDefinition,
annotationToken);
} else {
logger.warn("Annotation: " + annotationToken.getName() + " is not configured for this ModelDriver driver.");
}
return annotation;
}
示例8: buildAnnotationDefinition
import org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition; //导入依赖的package包/类
public AnnotationDefinition buildAnnotationDefinition(String annotationClassName,
ClassTypeResolver classTypeResolver) throws ModelDriverException {
try {
String resolvedClassName = resolveTypeName(classTypeResolver,
annotationClassName);
Class annotationClass = classTypeResolver.resolveType(resolvedClassName);
return DriverUtils.buildAnnotationDefinition(annotationClass);
} catch (ClassNotFoundException e) {
logger.error(errorMessage(ANNOTATION_LOAD_ERROR,
annotationClassName),
e);
throw new ModelDriverException(errorMessage(ANNOTATION_LOAD_ERROR,
annotationClassName),
e);
}
}
示例9: addAnnotation
import org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition; //导入依赖的package包/类
public AnnotationSource<?> addAnnotation(AnnotationTargetSource annotationTargetSource,
Annotation annotation) {
AnnotationSource<?> newAnnotationSource = annotationTargetSource.addAnnotation();
newAnnotationSource.setName(annotation.getClassName());
AnnotationDefinition annotationDefinition = annotation.getAnnotationDefinition();
if (!annotationDefinition.isMarker()) {
for (AnnotationValuePairDefinition memberDefinition : annotationDefinition.getValuePairs()) {
Object value = annotation.getValue(memberDefinition.getName());
if (value != null) {
addMemberValue(newAnnotationSource,
memberDefinition,
value);
}
}
}
return newAnnotationSource;
}
示例10: createAnnotation
import org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition; //导入依赖的package包/类
private org.kie.workbench.common.services.datamodeller.core.Annotation createAnnotation(Annotation annotationToken) throws ModelDriverException {
AnnotationDefinition annotationDefinition = getConfiguredAnnotation(annotationToken.getQualifiedTypeName());
org.kie.workbench.common.services.datamodeller.core.Annotation annotation = null;
if (annotationDefinition != null) {
AnnotationDriver annotationDriver = getAnnotationDriver(annotationDefinition.getClassName());
if (annotationDriver != null) {
annotation = annotationDriver.buildAnnotation(annotationDefinition, annotationToken);
} else {
logger.warn("AnnotationDriver for annotation: " + annotationToken.getQualifiedTypeName() + " is not configured for this driver");
}
} else {
logger.warn("Annotation: " + annotationToken.getQualifiedTypeName() + " is not configured for this driver.");
}
return annotation;
}
示例11: buildAnnotation
import org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition; //导入依赖的package包/类
@Override
public Annotation buildAnnotation( AnnotationDefinition annotationDefinition, Object annotationToken ) throws ModelDriverException {
AnnotationSource javaAnnotationToken = ( AnnotationSource ) annotationToken;
AnnotationImpl annotation = new AnnotationImpl( annotationDefinition );
if ( annotationDefinition.isMarker() ) {
return annotation;
} else {
if ( javaAnnotationToken.getValues() != null ) {
List<ValuePair> values = javaAnnotationToken.getValues();
if ( values != null && values.size() > 0 ) {
for ( AnnotationValuePairDefinition valuePairDefinition : annotationDefinition.getValuePairs() ) {
Object annotationValue = buildAnnotationValue( javaAnnotationToken, valuePairDefinition );
if ( annotationValue != null ) {
annotation.setValue( valuePairDefinition.getName(), annotationValue );
}
}
}
}
}
return annotation;
}
示例12: setup
import org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition; //导入依赖的package包/类
@Before
public void setup() {
try {
InputStream in = this.getClass().getResourceAsStream( "GenerationTestResults.properties" );
results.load(in);
in.close();
Set<String> propertyNames = results.stringPropertyNames();
for (String property : propertyNames) {
String newProperty = results.getProperty(property).replaceAll("\n",
System.getProperty("line.separator"));
results.setProperty(property,
newProperty);
}
engine = GenerationEngine.getInstance();
dataModelOracleDriver = DataModelOracleModelDriver.getInstance();
annotationDefinitions = new HashMap<String, AnnotationDefinition>(5);
List<AnnotationDefinition> configuredAnnotations = dataModelOracleDriver.getConfiguredAnnotations();
for ( AnnotationDefinition annotationDefinition : configuredAnnotations ) {
annotationDefinitions.put( annotationDefinition.getClassName(), annotationDefinition );
}
} catch ( Exception e ) {
e.printStackTrace();
}
}
示例13: createAnnotation
import org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition; //导入依赖的package包/类
public static Annotation createAnnotation(List<ObjectPropertyPath> objectPropertyPathList,
Map<String, AnnotationDefinition> annotationDefinitions) {
Annotation annotation = new AnnotationImpl(annotationDefinitions.get(ComparatorDefinition.class.getName()));
List<Annotation> objectPropertyPathAnnotations = objectPropertyPathList == null ? new ArrayList<>(0) : new ArrayList<>(objectPropertyPathList.size());
if (objectPropertyPathList != null) {
for (ObjectPropertyPath objectPropertyPath : objectPropertyPathList) {
AnnotationImpl comparatorFieldPath = new AnnotationImpl(annotationDefinitions.get(ComparatorObjectPropertyPath.class.getName()));
List<ObjectProperty> path = objectPropertyPath.getObjectPropertyPath();
List<Annotation> comparatorFieldPaths = new ArrayList<>();
for (int i = 0; i < path.size(); i++) {
ObjectProperty objectProperty = path.get(i);
AnnotationImpl comparatorField = new AnnotationImpl(annotationDefinitions.get(ComparatorObjectProperty.class.getName()));
comparatorField.setValue(NAME,
objectProperty.getName());
comparatorField.setValue(TYPE,
objectProperty.getClassName());
comparatorFieldPaths.add(comparatorField);
}
comparatorFieldPath.setValue(OBJECT_PROPERTIES,
comparatorFieldPaths);
comparatorFieldPath.setValue(ASCENDING,
!objectPropertyPath.isDescending());
objectPropertyPathAnnotations.add(comparatorFieldPath);
}
}
annotation.setValue(OBJECT_PROPERTY_PATHS,
objectPropertyPathAnnotations);
return annotation;
}
示例14: onPlanningSolutionScoreTypeChange
import org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition; //导入依赖的package包/类
@Test
public void onPlanningSolutionScoreTypeChange() {
PlannerDataObjectEditor objectEditor = createObjectEditor();
objectEditor.onContextChange(context);
Mockito.reset(view);
when(view.getPlanningSolutionScoreType()).thenReturn(BendableScore.class.getName());
context.getAnnotationDefinitions().put(PlannerDomainAnnotations.PLANNING_SCORE_ANNOTATION,
mock(AnnotationDefinition.class));
context.getAnnotationDefinitions().put(PlannerDomainAnnotations.JAXB_XML_ROOT_ELEMENT,
mock(AnnotationDefinition.class));
context.getAnnotationDefinitions().put(PlannerDomainAnnotations.JAXB_XML_ACCESSOR_TYPE,
mock(AnnotationDefinition.class));
context.getAnnotationDefinitions().put(PlannerDomainAnnotations.JAXB_XML_JAVA_TYPE_ADAPTER_ANNOTATION,
mock(AnnotationDefinition.class));
context.getAnnotationDefinitions().put(Generated.class.getName(),
mock(AnnotationDefinition.class));
objectEditor.onPlanningSolutionScoreTypeChange();
DataObject dataObject = context.getDataObject();
ObjectProperty scoreObjectProperty = dataObject.getProperty("score");
assertNotNull(scoreObjectProperty);
assertEquals(BendableScore.class.getName(),
scoreObjectProperty.getClassName());
}
示例15: getPlannerAnnotations
import org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition; //导入依赖的package包/类
public static Map<String, AnnotationDefinition> getPlannerAnnotations() {
HashMap<String, AnnotationDefinition> annotations = new HashMap<String, AnnotationDefinition>();
annotations.put(PlanningEntity.class.getName(),
DriverUtils.buildAnnotationDefinition(PlanningEntity.class));
annotations.put(PlanningSolution.class.getName(),
DriverUtils.buildAnnotationDefinition(PlanningSolution.class));
annotations.put(PlanningVariable.class.getName(),
DriverUtils.buildAnnotationDefinition(PlanningVariable.class));
annotations.put(ValueRangeProvider.class.getName(),
DriverUtils.buildAnnotationDefinition(ValueRangeProvider.class));
return annotations;
}