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


Java DataObject.getProperty方法代码示例

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


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

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

示例2: extractSolutionBendableScoreLevelsSize

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
public BendableScoreLevelsWrapper extractSolutionBendableScoreLevelsSize(final Path solutionPath) {
    String solutionString = ioService.readAllString(Paths.convert(solutionPath));

    GenerationResult generationResult = dataModelerService.loadDataObject(solutionPath,
                                                                          solutionString,
                                                                          solutionPath);
    if (!generationResult.hasErrors()) {
        DataObject dataObject = generationResult.getDataObject();

        ObjectProperty scoreObjectProperty = dataObject.getProperty("score");
        if (scoreObjectProperty != null) {
            if (isBendableScore(scoreObjectProperty.getClassName())) {
                Annotation annotation = scoreObjectProperty.getAnnotation(PlanningScore.class.getName());
                if (annotation != null) {
                    Object hardLevelsSize = annotation.getValue("bendableHardLevelsSize");
                    Object softLevelsSize = annotation.getValue("bendableSoftLevelsSize");
                    return new BendableScoreLevelsWrapper(hardLevelsSize == null ? 0 : (int) hardLevelsSize,
                                                          softLevelsSize == null ? 0 : (int) softLevelsSize);
                }
            }
        }
    }
    return new BendableScoreLevelsWrapper();
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:25,代码来源:ScoreHolderServiceImpl.java

示例3: loadDataObjectFieldTest

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Test
public void loadDataObjectFieldTest() {
    JPADataObjectFieldEditor fieldEditor = createFieldEditor();

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

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

    verify( view, times( 2 ) ).loadPropertyEditorCategories( anyListOf( PropertyEditorCategory.class ) );
    assertFalse( fieldEditor.isReadonly() );
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:17,代码来源:JPADataObjectFieldEditorTest.java

示例4: loadDataObjectFieldTest

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

    DroolsDataObjectFieldEditor fieldEditor = createFieldEditor();

    DataObject dataObject = context.getDataObject();
    ObjectProperty field1 = dataObject.getProperty( "field1" );
    //emulates selection of field1 in current context.
    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 ) ).setEquals( true );
    verify( view, times( 1 ) ).setPosition( "0" );

    assertFalse( fieldEditor.isReadonly() );
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:22,代码来源:DroolsDataObjectFieldEditorTest.java

示例5: onPlanningSolutionScoreTypeChange

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的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());
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:31,代码来源:PlannerDataObjectEditorTest.java

示例6: fieldPlanningEntitySettings

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

    PlannerDataObjectFieldEditor fieldEditor = createFieldEditor();

    //first configure the DataObject as a PlanningEntity
    DataObject dataObject = context.getDataObject();
    dataObject.addAnnotation(new AnnotationImpl(context.getAnnotationDefinition(PlanningEntity.class.getName())));

    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);

    //emulate the user input
    when(view.getPlanningVariableValue()).thenReturn(true);
    when(view.getValueRangeProviderRefsValue()).thenReturn("valueRangeProviderRefsValue");

    fieldEditor.onPlanningVariableChange();
    fieldEditor.onValueRangeProviderRefsChange();

    List<String> valueRangeProviderRefs = new ArrayList<String>();
    valueRangeProviderRefs.add("valueRangeProviderRefsValue");
    assertNotNull(field1.getAnnotation(PlanningVariable.class.getName()));
    assertEquals(valueRangeProviderRefs,
                 field1.getAnnotation(PlanningVariable.class.getName()).getValue("valueRangeProviderRefs"));
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:31,代码来源:PlannerDataObjectFieldEditorTest.java

示例7: planningSolutionSettings

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

    PlannerDataObjectFieldEditor fieldEditor = createFieldEditor();

    //first configure the DataObject as a PlanningSolution
    DataObject dataObject = context.getDataObject();
    dataObject.addAnnotation(new AnnotationImpl(context.getAnnotationDefinition(PlanningSolution.class.getName())));
    dataObject.addProperty("score",
                           HardSoftScore.class.getName());

    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);

    when(view.getValueRangeProviderValue()).thenReturn(true);
    when(view.getValueRangeProviderIdValue()).thenReturn("valueRangeProviderIdValue");

    //emulate the user input
    fieldEditor.onValueRangeProviderChange();
    fieldEditor.onValueRangeProviderIdChange();

    assertNotNull(field1.getAnnotation(ValueRangeProvider.class.getName()));
    assertEquals("valueRangeProviderIdValue",
                 AnnotationValueHandler.getStringValue(field1,
                                                       ValueRangeProvider.class.getName(),
                                                       "id"));
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:33,代码来源:PlannerDataObjectFieldEditorTest.java

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

示例9: generateIdFieldName

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
private String generateIdFieldName( DataObject dataObject ) {
    String id = "id";
    int i = 1;
    boolean generated = false;
    while ( !generated ) {
        if ( dataObject.getProperty( id ) == null ) {
            generated = true;
        } else {
            id = "id"+i;
            i++;
        }
    }
    return id;
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:15,代码来源:JPADataObjectEditor.java

示例10: loadDataObjectFieldTest

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

    MainDataObjectFieldEditor fieldEditor = createFieldEditor();

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

    //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)).setName(field.getName());
    verify(view,
           times(1)).setLabel(AnnotationValueHandler.getStringValue(field,
                                                                    Label.class.getName(),
                                                                    "value"));
    verify(view,
           times(1)).setDescription(AnnotationValueHandler.getStringValue(field,
                                                                          Description.class.getName(),
                                                                          "value"));
    verify(view,
           times(1)).initTypeList(anyList(),
                                  eq(field.getClassName()),
                                  eq(false));

    assertFalse(fieldEditor.isReadonly());
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:34,代码来源:MainDataObjectFieldEditorTest.java

示例11: valuesChangesTest

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

    DroolsDataObjectFieldEditor fieldEditor = createFieldEditor();

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

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

    //emulate the user input.
    when( view.getEquals() ).thenReturn( false );
    when( view.getPosition() ).thenReturn( "1" );

    //notify the presenter about the changes in the UI
    fieldEditor.onEqualsChange();
    fieldEditor.onPositionChange();

    assertNull( field1.getAnnotation( Key.class.getName() ) );
    assertEquals( 1, AnnotationValueHandler.getValue( field1, Position.class.getName(), "value" ) );

    verify( dataModelerEvent, times( 2 ) ).fire( any( DataModelerEvent.class ) );
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:28,代码来源:DroolsDataObjectFieldEditorTest.java

示例12: getObjectPropertyPathList

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
private List<ObjectPropertyPath> getObjectPropertyPathList(Annotation comparatorDefinition) {
    ComparatorDefinitionAnnotationValueHandler comparatorAnnotationHandler = new ComparatorDefinitionAnnotationValueHandler(comparatorDefinition);
    List<ObjectPropertyPath> objectPropertyPathList = new ArrayList<>();
    List<Annotation> comparatorFieldPaths = comparatorAnnotationHandler.getObjectPropertyPaths();

    for (Annotation comparatorFieldPath : comparatorFieldPaths) {
        ObjectPropertyPath objectPropertyPath = new ObjectPropertyPathImpl();
        objectPropertyPath.setDescending(!comparatorAnnotationHandler.isAscending(comparatorFieldPath));

        List<Annotation> comparatorFields = comparatorAnnotationHandler.getObjectProperties(comparatorFieldPath);
        if (!comparatorFields.isEmpty()) {

            String objectPropertyName = comparatorAnnotationHandler.getName(comparatorFields.get(0));

            ObjectProperty objectProperty = dataObject.getProperty(objectPropertyName);
            if (objectProperty == null) {
                throw new IllegalStateException(dataObject.getName() + "Comparator: Property " + objectPropertyName + " not found in data object " + dataObject.getClassName());
            }
            objectPropertyPath.appendObjectProperty(objectProperty);
            for (int i = 1; i < comparatorFields.size(); i++) {

                objectPropertyName = comparatorAnnotationHandler.getName(comparatorFields.get(i));

                ObjectProperty lastObjectPropertyInPath = objectPropertyPath.getObjectPropertyPath().get(objectPropertyPath.getObjectPropertyPath().size() - 1);
                if (lastObjectPropertyInPath.isBaseType() || lastObjectPropertyInPath.isPrimitiveType()) {
                    throw new IllegalStateException(dataObject.getName() + "Comparator: Cannot append property " + objectPropertyName + " to primitive/base type " + lastObjectPropertyInPath.getClassName());
                }
                DataObject lastDataObjectInPath = getContext().getDataModel().getDataObject(lastObjectPropertyInPath.getClassName());
                if (lastObjectPropertyInPath == null) {
                    throw new IllegalStateException(dataObject.getName() + "Comparator: Data object " + lastObjectPropertyInPath.getClassName() + " not found");
                }
                ObjectProperty currentObjectProperty = lastDataObjectInPath.getProperty(objectPropertyName);
                if (currentObjectProperty == null) {
                    throw new IllegalStateException(dataObject.getName() + "Comparator: Property " + objectPropertyName + " not found in data object " + lastDataObjectInPath.getClassName());
                }
                objectPropertyPath.appendObjectProperty(currentObjectProperty);
            }
        }
        objectPropertyPathList.add(objectPropertyPath);
    }

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

示例13: changeToPlanningSolution

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

    PlannerDataObjectEditor objectEditor = createObjectEditor();

    //load the editor.
    objectEditor.onContextChange(context);

    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(PlannerDomainAnnotations.PLANNING_SCORE_ANNOTATION,
                                           mock(AnnotationDefinition.class));
    context.getAnnotationDefinitions().put(Generated.class.getName(),
                                           mock(AnnotationDefinition.class));

    // reset state changed by onContextChange
    Mockito.reset(view);

    //emulate user input.
    when(view.getPlanningSolutionValue()).thenReturn(true);
    when(view.getPlanningSolutionScoreType()).thenReturn(HardSoftScore.class.getName());

    //notify the presenter about the changes in the UI
    objectEditor.onPlanningSolutionChange();

    DataObject dataObject = context.getDataObject();

    //the dataObject should have been now configured as a PlanningEntity
    verify(view,
           times(1)).getPlanningSolutionValue();
    verify(view,
           times(1)).showPlanningSolutionScoreType(true);

    verify(view,
           times(1)).destroyFieldPicker();

    //the dataObject should have been now configured as a HardSoftCore PlanningSolution by default.
    assertNotNull(dataObject.getAnnotation(PlanningSolution.class.getName()));
    assertNotNull(dataObject.getAnnotation(XmlRootElement.class.getName()));

    ObjectProperty scoreObjectProperty = dataObject.getProperty("score");
    assertNotNull(scoreObjectProperty);
    assertEquals(HardSoftScore.class.getName(),
                 scoreObjectProperty.getClassName());
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:50,代码来源:PlannerDataObjectEditorTest.java

示例14: testPlanningSolutionLevelsSizeChange

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
public void testPlanningSolutionLevelsSizeChange(boolean isHardScore) {
    PlannerDataObjectEditor objectEditor = createObjectEditor();

    objectEditor.onContextChange(context);

    DataObject dataObject = context.getDataObject();

    dataObject.addAnnotation(DataModelerEditorsTestHelper.createAnnotation(PlanningSolution.class,
                                                                           null,
                                                                           null));

    AnnotationDefinition planningScoreAnnotationDefinition = mock(AnnotationDefinition.class);
    when(planningScoreAnnotationDefinition.getClassName()).thenReturn(PlanningScore.class.getName());

    context.getAnnotationDefinitions().put(PlannerDomainAnnotations.PLANNING_SCORE_ANNOTATION,
                                           planningScoreAnnotationDefinition);
    context.getAnnotationDefinitions().put(Generated.class.getName(),
                                           mock(AnnotationDefinition.class));

    ObjectProperty scoreObjectProperty = new ObjectPropertyImpl("score",
                                                                BendableScore.class.getName(),
                                                                false);
    dataObject.addProperty(scoreObjectProperty);

    scoreObjectProperty.addAnnotation(DataModelerEditorsTestHelper.createAnnotation(PlanningScore.class,
                                                                                    new Pair("bendableHardLevelsSize",
                                                                                             5),
                                                                                    new Pair("bendableSoftLevelsSize",
                                                                                             5)));
    scoreObjectProperty.addAnnotation(DataModelerEditorsTestHelper.createAnnotation(Generated.class,
                                                                                    null,
                                                                                    null));

    if (isHardScore) {
        when(view.getPlanningSolutionBendableScoreHardLevelsSize()).thenReturn(1);
    } else {
        when(view.getPlanningSolutionBendableScoreSoftLevelsSize()).thenReturn(1);
    }

    when(view.getPlanningSolutionScoreType()).thenReturn(BendableScore.class.getName());

    objectEditor.onPlanningSolutionBendableScoreHardLevelsSizeChange();

    scoreObjectProperty = dataObject.getProperty("score");

    assertNotNull(scoreObjectProperty);

    Annotation planningScoreAnnotation = scoreObjectProperty.getAnnotation(PlanningScore.class.getName());

    assertNotNull(planningScoreAnnotation);

    // check whether bendable levels size has been updated
    if (isHardScore) {
        assertEquals(1,
                     planningScoreAnnotation.getValue("bendableHardLevelsSize"));
    } else {
        assertEquals(1,
                     planningScoreAnnotation.getValue("bendableSoftLevelsSize"));
    }
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:61,代码来源:PlannerDataObjectEditorTest.java

示例15: addByDefaultId

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
private void addByDefaultId( DataObject dataObject ) {

        //add the by default id field
        String idFieldName = generateIdFieldName( dataObject );

        commandBuilder.buildAddPropertyCommand(
                getContext(),
                getName(),
                dataObject,
                idFieldName,
                null,
                Long.class.getName(),
                false ).execute();

        ObjectProperty idField = dataObject.getProperty( idFieldName );

        commandBuilder.buildFieldAnnotationAddCommand( getContext(),
                getName(),
                dataObject,
                idField,
                JPADomainAnnotations.JAVAX_PERSISTENCE_ID_ANNOTATION ).execute();

        //set the by default generated value annotation.
        String generatorName = dataObject.getName().toUpperCase() + "_ID_GENERATOR";
        Annotation generatedValue = new AnnotationImpl( context.getAnnotationDefinition(
                JPADomainAnnotations.JAVAX_PERSISTENCE_GENERATED_VALUE_ANNOTATION ) );
        generatedValue.setValue( "generator", generatorName );
        generatedValue.setValue( "strategy", "AUTO" );

        commandBuilder.buildFieldAnnotationAddCommand( getContext(),
                getName(),
                dataObject,
                idField,
                generatedValue ).execute();

        //set by default sequence generator
        String sequenceName = dataObject.getName().toUpperCase() + "_ID_SEQ";
        Annotation sequenceGenerator = SequenceGeneratorValueHandler.createAnnotation( generatorName, sequenceName,
                context.getAnnotationDefinitions() );

        commandBuilder.buildFieldAnnotationAddCommand( getContext(),
                getName(),
                dataObject,
                idField,
                sequenceGenerator ).execute();
    }
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:47,代码来源:JPADataObjectEditor.java


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