本文整理汇总了Java中org.kie.workbench.common.services.datamodeller.core.DataObject.getAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java DataObject.getAnnotation方法的具体用法?Java DataObject.getAnnotation怎么用?Java DataObject.getAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kie.workbench.common.services.datamodeller.core.DataObject
的用法示例。
在下文中一共展示了DataObject.getAnnotation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getComparatorNestedClasses
import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
private List<JavaClass> getComparatorNestedClasses(DataObject dataObject) {
Annotation planningEntityAnnotation = dataObject.getAnnotation(PlannerDomainAnnotations.PLANNING_ENTITY_ANNOTATION);
if (dataObject.getNestedClasses() != null && planningEntityAnnotation != null) {
String difficultyComparatorClass = (String) planningEntityAnnotation.getValue("difficultyComparatorClass");
if (difficultyComparatorClass != null && difficultyComparatorClass.matches("\\w[\\.\\w]+\\.class")) {
String[] difficultyComparatorTokens = difficultyComparatorClass.split("\\.");
return dataObject.getNestedClasses().stream()
.filter(t -> t.getName().equals(difficultyComparatorTokens[difficultyComparatorTokens.length - 2])
&& t.getAnnotation(ComparatorDefinition.class.getName()) != null
&& t.getAnnotation("javax.annotation.Generated") != null
&& t.getInterfaces().stream().anyMatch(i -> i.startsWith(Comparator.class.getName())))
.collect(Collectors.toList());
}
}
return Collections.emptyList();
}
示例2: validate
import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Override
public Collection<ValidationMessage> validate(final Path dataObjectPath,
final DataObject dataObject) {
if (dataObject != null && dataObject.getAnnotation(PLANNING_SOLUTION_ANNOTATION) != null) {
List<Path> planningSolutionUsages = assetsUsageService.getAssetUsages(PLANNING_SOLUTION_ANNOTATION,
ResourceType.JAVA,
dataObjectPath);
// PlanningSolution already present in this object
if (planningSolutionUsages.contains(dataObjectPath)) {
return Collections.emptyList();
}
// Check other PlanningSolution usages
if (!planningSolutionUsages.isEmpty()) {
return Arrays.asList(new PlanningSolutionToBeDuplicatedMessage(Level.ERROR));
}
}
return Collections.emptyList();
}
示例3: validate
import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Override
public Collection<ValidationMessage> validate(final Path path) {
if (path != null) {
String dataObjectSource = ioService.readAllString(Paths.convert(path));
GenerationResult generationResult = dataModelerService.loadDataObject(path,
dataObjectSource,
path);
if (generationResult.hasErrors()) {
return Collections.emptyList();
} else {
DataObject dataObject = generationResult.getDataObject();
if (dataObject.getAnnotation(PLANNING_SOLUTION_ANNOTATION) != null) {
return Arrays.asList(new PlanningSolutionToBeDuplicatedMessage(Level.ERROR));
}
}
}
return Collections.emptyList();
}
示例4: postProcess
import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Override
public void postProcess(final Path path) {
String dataObjectSource = ioService.readAllString(Paths.convert(path));
GenerationResult generationResult = dataModelerService.loadDataObject(path,
dataObjectSource,
path);
if (generationResult.hasErrors()) {
LOGGER.warn("Path " + path + " parsing as a data object has failed. Score holder global generation will be skipped.");
} else {
DataObject dataObject = generationResult.getDataObject();
if (dataObject.getAnnotation(PLANNING_SOLUTION_ANNOTATION) != null) {
org.uberfire.java.nio.file.Path source = Paths.convert(kieProjectService.resolvePackage(path).getPackageMainResourcesPath());
org.uberfire.java.nio.file.Path sourcePackage = Files.isDirectory(source) ? source : source.getParent();
String dataObjectFileName = path.getFileName().substring(0,
path.getFileName().indexOf("."));
ioService.deleteIfExists(sourcePackage.resolve(dataObjectFileName + SCORE_HOLDER_GLOBAL_FILE_SUFFIX));
}
}
}
示例5: getComparatorObject
import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
private JavaClass getComparatorObject(DataObject dataObject) {
Annotation planningEntityAnnotation = dataObject.getAnnotation(PlannerDomainAnnotations.PLANNING_ENTITY_ANNOTATION);
if (dataObject.getNestedClasses() != null && planningEntityAnnotation != null) {
String difficultyComparatorClass = (String) planningEntityAnnotation.getValue("difficultyComparatorClass");
if (difficultyComparatorClass != null && difficultyComparatorClass.matches("\\w[\\.\\w]+\\.class")) {
String[] difficultyComparatorTokens = difficultyComparatorClass.split("\\.");
Optional<JavaClass> comparatorNestedClass = dataObject.getNestedClasses().stream()
.filter(t -> t.getName().equals(difficultyComparatorTokens[difficultyComparatorTokens.length - 2])
&& t.getAnnotation(ComparatorDefinition.class.getName()) != null
&& t.getAnnotation("javax.annotation.Generated") != null
&& t.getInterfaces().stream().anyMatch(i -> i.startsWith(Comparator.class.getName())))
.findFirst();
if (comparatorNestedClass.isPresent()) {
return comparatorNestedClass.get();
}
}
}
return null;
}
示例6: loadDurationSelector
import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
private void loadDurationSelector( DataObject dataObject ) {
if ( dataObject == null ) {
return;
}
List<String> types = new ArrayList<String>();
types.add( "short" );
types.add( "int" );
types.add( "long" );
types.add( "java.lang.Short" );
types.add( "java.lang.Integer" );
types.add( "java.lang.Long" );
String defaultValue = null;
Annotation annotation = dataObject.getAnnotation( DroolsDomainAnnotations.DURATION_ANNOTATION );
if ( annotation != null ) {
defaultValue = AnnotationValueHandler.getStringValue( annotation, DroolsDomainAnnotations.VALUE_PARAM );
}
List<Pair<String, String>> propertyOptions = loadPropertyOptions( dataObject, types, defaultValue );
view.initDurationFieldList( propertyOptions, true );
}
示例7: loadTimestampSelector
import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
private void loadTimestampSelector( DataObject dataObject ) {
if ( dataObject == null ) {
return;
}
List<String> types = new ArrayList<String>();
types.add( "long" );
types.add( "java.lang.Long" );
types.add( "java.util.Date" );
types.add( "java.sql.Timestamp" );
String defaultValue = null;
Annotation annotation = dataObject.getAnnotation( DroolsDomainAnnotations.TIMESTAMP_ANNOTATION );
if ( annotation != null ) {
defaultValue = AnnotationValueHandler.getStringValue( annotation, DroolsDomainAnnotations.VALUE_PARAM );
}
List<Pair<String, String>> propertyOptions = loadPropertyOptions( dataObject, types, defaultValue );
view.initTimeStampFieldList( propertyOptions, true );
}
示例8: findPersistableClasses
import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Override
public List<String> findPersistableClasses(final Path path) {
List<String> classes = new ArrayList<String>();
KieModule module = moduleService.resolveModule(path);
if (module != null) {
DataModel dataModel = loadModel(module);
if (dataModel != null) {
for (DataObject dataObject : dataModel.getDataObjects()) {
if (dataObject.getAnnotation(Entity.class.getName()) != null) {
classes.add(dataObject.getClassName());
}
}
}
}
return classes;
}
示例9: validatePath
import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
private Collection<ValidationMessage> validatePath(final Path dataObjectPath) {
if (dataObjectPath != null) {
String dataObjectSource = ioService.readAllString(Paths.convert(dataObjectPath));
GenerationResult generationResult = dataModelerService.loadDataObject(dataObjectPath,
dataObjectSource,
dataObjectPath);
if (generationResult.hasErrors()) {
return Collections.emptyList();
} else {
DataObject originalDataObject = generationResult.getDataObject();
if (originalDataObject.getAnnotation(PLANNING_SOLUTION_ANNOTATION) != null) {
String originalDataObjectScoreTypeFqn = scoreHolderUtils.extractScoreTypeFqn(originalDataObject);
String originalDataObjectScoreHolderTypeFqn = scoreHolderUtils.getScoreHolderTypeFqn(originalDataObjectScoreTypeFqn);
if (originalDataObjectScoreHolderTypeFqn == null) {
return Arrays.asList(new ScoreHolderGlobalTypeNotRecognizedMessage(Level.WARNING));
}
List<Path> scoreHolderGlobalUsages = assetsUsageService.getAssetUsages(originalDataObjectScoreHolderTypeFqn,
ResourceType.JAVA,
dataObjectPath);
if (scoreHolderGlobalUsages.isEmpty()) {
return Collections.emptyList();
} else {
return Arrays.asList(new ScoreHolderGlobalToBeRemovedMessage(Level.WARNING));
}
}
}
}
return Collections.emptyList();
}
示例10: validate
import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Override
public Collection<ValidationMessage> validate(final DataObject dataObject,
final ObjectProperty objectProperty) {
final boolean isGeneratedPlanningScoreField =
dataObject != null
&& dataObject.getAnnotation(PlanningSolution.class.getName()) != null
&& objectProperty != null
&& "score".equals(objectProperty.getName())
&& objectProperty.getAnnotation(PlanningScore.class.getName()) != null
&& objectProperty.getAnnotation(Generated.class.getName()) != null;
return isGeneratedPlanningScoreField ? Arrays.asList(new PlanningScoreToBeDeletedMessage()) : Collections.emptyList();
}
示例11: extractScoreTypeFqn
import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
public String extractScoreTypeFqn(final DataObject dataObject) {
if (dataObject.getAnnotation(PlanningSolution.class.getName()) != null) {
final ObjectProperty scoreObjectProperty = dataObject.getProperty("score");
if (scoreObjectProperty != null) {
return scoreObjectProperty.getClassName();
}
}
return null;
}
示例12: postProcess
import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Override
public void postProcess(Path sourcePath,
Path destinationPath) {
String dataObjectSource = ioService.readAllString(Paths.convert(sourcePath));
GenerationResult generationResult = dataModelerService.loadDataObject(sourcePath,
dataObjectSource,
sourcePath);
if (generationResult.hasErrors()) {
LOGGER.warn("Path " + sourcePath + " parsing as a data object has failed. Score holder global generation will be skipped.");
} else {
DataObject dataObject = generationResult.getDataObject();
if (dataObject.getAnnotation(PLANNING_SOLUTION_ANNOTATION) != null) {
org.uberfire.java.nio.file.Path source = Paths.convert(kieProjectService.resolvePackage(sourcePath).getPackageMainResourcesPath());
org.uberfire.java.nio.file.Path sourcePackage = Files.isDirectory(source) ? source : source.getParent();
String sourceDataObjectFileName = sourcePath.getFileName().substring(0,
sourcePath.getFileName().indexOf("."));
org.uberfire.java.nio.file.Path destination = Paths.convert(kieProjectService.resolvePackage(destinationPath).getPackageMainResourcesPath());
org.uberfire.java.nio.file.Path destinationPackage = Files.isDirectory(destination) ? destination : destination.getParent();
String destinationDataObjectFileName = destinationPath.getFileName().substring(0,
destinationPath.getFileName().indexOf("."));
boolean scoreHolderGlobalFileExists = ioService.exists(sourcePackage.resolve(sourceDataObjectFileName + SCORE_HOLDER_GLOBAL_FILE_SUFFIX));
if (scoreHolderGlobalFileExists) {
ioService.copy(sourcePackage.resolve(sourceDataObjectFileName + SCORE_HOLDER_GLOBAL_FILE_SUFFIX),
destinationPackage.resolve(destinationDataObjectFileName + SCORE_HOLDER_GLOBAL_FILE_SUFFIX));
}
}
}
}
示例13: postProcess
import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Override
public void postProcess(final Path sourcePath,
final Path destinationPath) {
String dataObjectSource = ioService.readAllString(Paths.convert(destinationPath));
GenerationResult generationResult = dataModelerService.loadDataObject(destinationPath,
dataObjectSource,
destinationPath);
if (generationResult.hasErrors()) {
LOGGER.warn("Path " + sourcePath + " parsing as a data object has failed. Score holder global generation will be skipped.");
} else {
DataObject dataObject = generationResult.getDataObject();
if (dataObject.getAnnotation(PLANNING_SOLUTION_ANNOTATION) != null) {
org.uberfire.java.nio.file.Path source = Paths.convert(kieProjectService.resolvePackage(sourcePath).getPackageMainResourcesPath());
org.uberfire.java.nio.file.Path sourcePackage = Files.isDirectory(source) ? source : source.getParent();
String sourceDataObjectFileName = sourcePath.getFileName().substring(0,
sourcePath.getFileName().indexOf("."));
org.uberfire.java.nio.file.Path destination = Paths.convert(kieProjectService.resolvePackage(destinationPath).getPackageMainResourcesPath());
org.uberfire.java.nio.file.Path destinationPackage = Files.isDirectory(destination) ? destination : destination.getParent();
String destinationDataObjectFileName = destinationPath.getFileName().substring(0,
destinationPath.getFileName().indexOf("."));
boolean scoreHolderGlobalFileExists = ioService.exists(sourcePackage.resolve(sourceDataObjectFileName + SCORE_HOLDER_GLOBAL_FILE_SUFFIX));
if (scoreHolderGlobalFileExists) {
ioService.move(sourcePackage.resolve(sourceDataObjectFileName + SCORE_HOLDER_GLOBAL_FILE_SUFFIX),
destinationPackage.resolve(destinationDataObjectFileName + SCORE_HOLDER_GLOBAL_FILE_SUFFIX));
}
}
}
}
示例14: updateDataObject
import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
public void updateDataObject(Path dataObjectPath) {
String dataObjectString = ioService.readAllString(Paths.convert(dataObjectPath));
GenerationResult generationResult = dataModelerService.loadDataObject(dataObjectPath,
dataObjectString,
dataObjectPath);
DataObject dataObject = generationResult.getDataObject();
if (dataObject != null && generationResult.getErrors() == null || generationResult.getErrors().isEmpty()) {
JavaClass comparatorObject = getComparatorObject(dataObject);
if (comparatorObject != null) {
JavaClass updatedComparatorObject = comparatorDefinitionService.updateComparatorObject(dataObject,
comparatorObject);
dataObject.removeNestedClass(comparatorObject);
dataObject.addNestedClass(updatedComparatorObject);
Annotation planningEntityAnnotation = dataObject.getAnnotation(PlanningEntity.class.getName());
if (planningEntityAnnotation != null) {
planningEntityAnnotation.setValue("difficultyComparatorClass",
dataObject.getName() + ".DifficultyComparator");
}
generationResult = dataModelerService.updateSource(dataObjectString,
dataObjectPath,
dataObject);
if (generationResult.getDataObject() != null && generationResult.getErrors() == null || generationResult.getErrors().isEmpty()) {
ioService.write(Paths.convert(dataObjectPath),
generationResult.getSource());
} else {
logger.error("Data object " + dataObject.getClassName() + " couldn't be updated, path: " + dataObjectPath + ".");
}
}
} else {
logger.error("Data object couldn't be loaded, path: " + dataObjectPath + ".");
}
}
示例15: loadDataObject
import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Override
protected void loadDataObject(DataObject dataObject) {
clear();
setReadonly(true);
if (dataObject != null) {
this.dataObject = dataObject;
view.setName(dataObject.getName());
Annotation annotation = dataObject.getAnnotation(MainDomainAnnotations.LABEL_ANNOTATION);
if (annotation != null) {
view.setLabel(AnnotationValueHandler.getStringValue(annotation,
MainDomainAnnotations.VALUE_PARAM));
}
annotation = dataObject.getAnnotation(MainDomainAnnotations.DESCRIPTION_ANNOTATION);
if (annotation != null) {
view.setDescription(AnnotationValueHandler.getStringValue(annotation,
MainDomainAnnotations.VALUE_PARAM));
}
view.setPackageName(dataObject.getPackageName());
initSuperClassList(false);
setReadonly(getContext() == null || getContext().isReadonly());
}
}