当前位置: 首页>>代码示例>>Java>>正文


Java DataObject.getAnnotation方法代码示例

本文整理汇总了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();
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:17,代码来源:PlannerDomainHandler.java

示例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();
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:19,代码来源:PlanningSolutionSaveValidator.java

示例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();
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:20,代码来源:PlanningSolutionCopyValidator.java

示例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));
        }
    }
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:23,代码来源:PlanningSolutionDeleteHelper.java

示例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;
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:20,代码来源:PlannerDataModelerHelperUtils.java

示例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 );
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:23,代码来源:DroolsDataObjectEditor.java

示例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 );
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:21,代码来源:DroolsDataObjectEditor.java

示例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;
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:17,代码来源:DataModelerServiceImpl.java

示例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();
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:34,代码来源:PlanningSolutionScoreHolderDeleteValidator.java

示例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();
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:13,代码来源:PlanningScoreDeleteValidator.java

示例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;
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:10,代码来源:ScoreHolderUtils.java

示例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));
            }
        }
    }
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:33,代码来源:PlanningSolutionCopyHelper.java

示例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));
            }
        }
    }
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:33,代码来源:PlanningSolutionRenameWorkaroundHelper.java

示例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 + ".");
    }
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:40,代码来源:PlannerDataModelerHelperUtils.java

示例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());
    }
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:29,代码来源:MainDataObjectEditor.java


注:本文中的org.kie.workbench.common.services.datamodeller.core.DataObject.getAnnotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。