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


Java DataObject类代码示例

本文整理汇总了Java中org.kie.workbench.common.services.datamodeller.core.DataObject的典型用法代码示例。如果您正苦于以下问题:Java DataObject类的具体用法?Java DataObject怎么用?Java DataObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DataObject类属于org.kie.workbench.common.services.datamodeller.core包,在下文中一共展示了DataObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeComparatorDefinition

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入依赖的package包/类
@Override
public void removeComparatorDefinition(DataObject dataObject,
                                       boolean resetPlanningEntityAnnotation) {
    if (comparatorObject != null) {
        commandBuilder.buildDataObjectRemoveNestedClassCommand(getContext(),
                                                               getName(),
                                                               dataObject,
                                                               comparatorObject).execute();
        this.comparatorObject = null;
    }

    commandBuilder.buildDataObjectRemoveAnnotationCommand(getContext(),
                                                          getName(),
                                                          getDataObject(),
                                                          ComparatorDefinition.class.getName()).execute();

    if (resetPlanningEntityAnnotation) {
        commandBuilder.buildDataObjectAddAnnotationCommand(getContext(),
                                                           getName(),
                                                           getDataObject(),
                                                           PlannerDomainAnnotations.PLANNING_ENTITY_ANNOTATION).execute();
    }
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:24,代码来源:PlannerDataObjectEditor.java

示例2: onFieldAdded

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入依赖的package包/类
@Override
public void onFieldAdded(ObjectProperty objectProperty,
                         boolean notify) {
    objectPropertyPath.appendObjectProperty(objectProperty);
    view.addFieldItem(objectProperty);
    if (objectProperty.isBaseType() || objectProperty.isPrimitiveType()) {
        view.displaySelectFieldButton(false);
    } else {
        DataObject dataObject = dataModel.getDataObject(objectProperty.getClassName());
        initSelectFieldDropdownOptions(dataObject);
        view.displaySelectFieldButton(true);
    }
    if (notify) {
        picker.objectPropertyPathChanged(false);
    }
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:17,代码来源:DataObjectFieldPickerItem.java

示例3: onFieldRemoved

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入依赖的package包/类
@Override
public void onFieldRemoved(ObjectProperty objectProperty) {
    for (int i = objectPropertyPath.getObjectPropertyPath().size() - 1; i >= 0; i--) {
        ObjectProperty currentObjectProperty = objectPropertyPath.getObjectPropertyPath().get(i);
        objectPropertyPath.getObjectPropertyPath().remove(i);
        view.removeLastFieldItem();
        if (currentObjectProperty.equals(objectProperty)) {
            break;
        }
    }
    DataObject dataObject;
    if (objectPropertyPath.getObjectPropertyPath().isEmpty()) {
        dataObject = rootDataObject;
    } else {
        ObjectProperty parentObjectProperty = objectPropertyPath.getObjectPropertyPath().get(objectPropertyPath.getObjectPropertyPath().size() - 1);
        dataObject = dataModel.getDataObject(parentObjectProperty.getClassName());
    }
    initSelectFieldDropdownOptions(dataObject);
    view.displaySelectFieldButton(true);
    picker.objectPropertyPathChanged(true);
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:22,代码来源:DataObjectFieldPickerItem.java

示例4: 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

示例5: loadDataObjectPlanningSolution

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入依赖的package包/类
@Test
public void loadDataObjectPlanningSolution() {
    DataObject dataObject = context.getDataObject();
    dataObject.addAnnotation(DataModelerEditorsTestHelper.createAnnotation(PlanningSolution.class,
                                                                           null,
                                                                           null));

    PlannerDataObjectEditor objectEditor = createObjectEditor();
    objectEditor.onContextChange(context);

    verify(view,
           times(1)).enablePlanningSolutionCheckBox(true);
    verify(view,
           times(1)).showPlanningSolutionHelpIcon(false);

    verify(assetsUsageService,
           never()).getAssetUsages(anyString(),
                                   any(),
                                   any(Path.class));
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:21,代码来源:PlannerDataObjectEditorTest.java

示例6: loadDataObjectField

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入依赖的package包/类
@Test
public void loadDataObjectField() {

    PlannerDataObjectFieldEditor fieldEditor = createFieldEditor();

    DataObject dataObject = context.getDataObject();
    ObjectProperty field1 = dataObject.getProperty("field1");
    //emulates the selection of field1
    context.setObjectProperty(field1);

    //The domain editors typically reacts upon DataModelerContext changes.
    //when the context changes the editor will typically be reloaded.
    fieldEditor.onContextChange(context);

    //the view should be populated with the values from the field.
    verify(view,
           times(1)).clear();
    verify(view,
           times(1)).showPlanningFieldPropertiesNotAvailable(true);
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:21,代码来源:PlannerDataObjectFieldEditorTest.java

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: updateComparatorObject

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入依赖的package包/类
@Override
public JavaClass updateComparatorObject(DataObject dataObject,
                                        JavaClass comparatorObject) {
    comparatorObject.getInterfaces().removeIf(i -> i.startsWith("java.util.Comparator"));
    comparatorObject.addInterface("java.util.Comparator<" + dataObject.getClassName() + ">");

    Optional<Method> compareMethod = comparatorObject.getMethods()
            .stream()
            .filter(m -> m.getReturnType().getName().equals("int") && m.getParameters().size() == 2 && m.getName().equals("compare"))
            .findFirst();

    if (!compareMethod.isPresent()) {
        throw new IllegalStateException("'compare' method not found in comparator object " + comparatorObject);
    }

    comparatorObject.addMethod(updateCompareMethod(compareMethod.get(),
                                                   comparatorObject.getAnnotation(ComparatorDefinition.class.getName()),
                                                   dataObject.getClassName()));

    return comparatorObject;
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:22,代码来源:ComparatorDefinitionServiceImpl.java

示例12: checkPlanningSolutionOtherExists

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入依赖的package包/类
@Test
public void checkPlanningSolutionOtherExists() {
    DataObject dataObject = new DataObjectImpl("test",
                                               "Test");
    dataObject.addAnnotation(new AnnotationImpl(DriverUtils.buildAnnotationDefinition(PlanningSolution.class)));

    Path dataObjectPath = mock(Path.class);
    Path otherDataObjectPath = mock(Path.class);
    when(assetsUsageService.getAssetUsages(PlanningSolution.class.getName(),
                                           ResourceType.JAVA,
                                           dataObjectPath)).thenReturn(Arrays.asList(otherDataObjectPath));

    Collection<ValidationMessage> result = saveValidator.validate(dataObjectPath,
                                                                  dataObject);
    assertEquals(1,
                 result.size());

    ValidationMessage message = result.iterator().next();
    assertTrue(message instanceof PlanningSolutionToBeDuplicatedMessage);
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:21,代码来源:PlanningSolutionSaveValidatorTest.java

示例13: validateIsAPlanningScore

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入依赖的package包/类
@Test
public void validateIsAPlanningScore() {
    DataObject dataObject = new DataObjectImpl("test",
                                               "PlanningSolution");
    dataObject.addAnnotation(new AnnotationImpl(DriverUtils.buildAnnotationDefinition(PlanningSolution.class)));

    ObjectProperty objectProperty = new ObjectPropertyImpl("score",
                                                           HardSoftScore.class.getName(),
                                                           false);
    objectProperty.addAnnotation(new AnnotationImpl(DriverUtils.buildAnnotationDefinition(PlanningScore.class)));
    objectProperty.addAnnotation(new AnnotationImpl(DriverUtils.buildAnnotationDefinition(Generated.class)));

    Collection<ValidationMessage> result = deleteValidator.validate(dataObject,
                                                                    objectProperty);
    assertEquals(1,
                 result.size());
    assertTrue(result.iterator().next() instanceof PlanningScoreToBeDeletedMessage);
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:19,代码来源:PlanningScoreDeleteValidatorTest.java

示例14: dataObjectToAPlanningSolution

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入依赖的package包/类
@Test
public void dataObjectToAPlanningSolution() {
    Path dataObjectPath = PathFactory.newPath("Test.java",
                                              "file:///dataObjects");
    when(ioService.readAllString(Paths.convert(dataObjectPath))).thenReturn("testResult");

    DataObject originalDataObject = createDataObject(null);
    GenerationResult generationResult = new GenerationResult();
    generationResult.setDataObject(originalDataObject);
    when(dataModelerService.loadDataObject(any(),
                                           anyString(),
                                           any())).thenReturn(generationResult);

    DataObject updatedDataObject = createDataObject(SimpleScore.class);

    Collection<ValidationMessage> result = validator.validate(dataObjectPath,
                                                              updatedDataObject);
    assertTrue(result.isEmpty());
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:20,代码来源:PlanningSolutionScoreHolderSaveValidatorTest.java

示例15: dataObjectToADataObject

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入依赖的package包/类
@Test
public void dataObjectToADataObject() {
    Path dataObjectPath = PathFactory.newPath("Test.java",
                                              "file:///dataObjects");
    when(ioService.readAllString(Paths.convert(dataObjectPath))).thenReturn("testResult");

    DataObject originalDataObject = createDataObject(null);
    GenerationResult generationResult = new GenerationResult();
    generationResult.setDataObject(originalDataObject);
    when(dataModelerService.loadDataObject(any(),
                                           anyString(),
                                           any())).thenReturn(generationResult);

    DataObject updatedDataObject = createDataObject(null);

    Collection<ValidationMessage> result = validator.validate(dataObjectPath,
                                                              updatedDataObject);
    assertTrue(result.isEmpty());
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:20,代码来源:PlanningSolutionScoreHolderSaveValidatorTest.java


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