use of com.evolveum.midpoint.prism.ItemDefinition in project midpoint by Evolveum.
the class TestJaxbSanity method testAssignmentEquals.
@Test
public void testAssignmentEquals() throws JAXBException, SchemaException, FileNotFoundException {
System.out.println("\n\n ===[testAssnignmentEquals]===\n");
// GIVEN
JAXBElement<UserType> userEl1 = JaxbTestUtil.getInstance().unmarshalElement(new File(USER_BARBOSSA_FILENAME), UserType.class);
UserType user = userEl1.getValue();
assertNotNull(user);
AssignmentType userAssignmentType = user.getAssignment().get(0);
assertNotNull(userAssignmentType);
System.out.println("\n*** user assignment");
System.out.println(PrismTestUtil.serializeAnyDataWrapped(userAssignmentType));
JAXBElement<ObjectModificationType> modEl = JaxbTestUtil.getInstance().unmarshalElement(new File(TEST_DIR, "user-barbossa-modify-delete-assignment-account-opendj-attr.xml"), ObjectModificationType.class);
ObjectModificationType mod = modEl.getValue();
assertNotNull(mod);
//FIXME : modification value -> rawType...
RawType rawType = mod.getItemDelta().get(0).getValue().get(0);
ItemDefinition assignmentDefinition = PrismTestUtil.getPrismContext().getSchemaRegistry().findContainerDefinitionByCompileTimeClass(AssignmentType.class);
assertNotNull(assignmentDefinition);
AssignmentType assignmentType = ((PrismContainerValue<AssignmentType>) rawType.getParsedValue(assignmentDefinition, null)).getValue();
// was: (JAXBElement<AssignmentType>) mod.getItemDelta().get(0).getValue().get(0).getContent().get(0);
assertNotNull(assignmentType);
System.out.println("\n*** assignment");
System.out.println(PrismTestUtil.serializeAnyDataWrapped(assignmentType));
// WHEN, THEN
assertTrue("Assignment not equals", userAssignmentType.equals(assignmentType));
assertTrue("HashCode does not match", userAssignmentType.hashCode() == assignmentType.hashCode());
}
use of com.evolveum.midpoint.prism.ItemDefinition in project midpoint by Evolveum.
the class SearchPanel method createPropertiesList.
private List<Property> createPropertiesList() {
List<Property> list = new ArrayList<>();
Search search = getModelObject();
List<ItemDefinition> defs = search.getAllDefinitions();
for (ItemDefinition def : defs) {
list.add(new Property(def));
}
Collections.sort(list);
return list;
}
use of com.evolveum.midpoint.prism.ItemDefinition in project midpoint by Evolveum.
the class AssignmentEditorDto method prepareAssignmentAttributes.
private List<ACAttributeDto> prepareAssignmentAttributes(AssignmentType assignment, PageBase pageBase) {
List<ACAttributeDto> acAtrList = new ArrayList<>();
if (assignment == null || assignment.getConstruction() == null || assignment.getConstruction().getAttribute() == null || assignment.getConstruction() == null) {
return acAtrList;
}
OperationResult result = new OperationResult(OPERATION_LOAD_ATTRIBUTES);
ConstructionType construction = assignment.getConstruction();
PrismObject<ResourceType> resource = construction.getResource() != null ? construction.getResource().asPrismObject() : null;
if (resource == null) {
resource = getReference(construction.getResourceRef(), result, pageBase);
}
try {
PrismContext prismContext = pageBase.getPrismContext();
RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource, LayerType.PRESENTATION, prismContext);
RefinedObjectClassDefinition objectClassDefinition = refinedSchema.getRefinedDefinition(ShadowKindType.ACCOUNT, construction.getIntent());
if (objectClassDefinition == null) {
return attributes;
}
PrismContainerDefinition definition = objectClassDefinition.toResourceAttributeContainerDefinition();
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Refined definition for {}\n{}", construction, definition.debugDump());
}
Collection<ItemDefinition> definitions = definition.getDefinitions();
for (ResourceAttributeDefinitionType attribute : assignment.getConstruction().getAttribute()) {
for (ItemDefinition attrDef : definitions) {
if (attrDef instanceof PrismPropertyDefinition) {
PrismPropertyDefinition propertyDef = (PrismPropertyDefinition) attrDef;
if (propertyDef.isOperational() || propertyDef.isIgnored()) {
continue;
}
if (ItemPathUtil.getOnlySegmentQName(attribute.getRef()).equals(propertyDef.getName())) {
acAtrList.add(ACAttributeDto.createACAttributeDto(propertyDef, attribute, prismContext));
break;
}
}
}
}
result.recordSuccess();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Exception occurred during assignment attribute loading", ex);
result.recordFatalError("Exception occurred during assignment attribute loading.", ex);
} finally {
result.recomputeStatus();
}
return acAtrList;
}
use of com.evolveum.midpoint.prism.ItemDefinition in project midpoint by Evolveum.
the class TestIntegrationObjectWrapperFactory method test150CreateWrapperShadow.
@Test
public void test150CreateWrapperShadow() throws Exception {
final String TEST_NAME = "test150CreateWrapperShadow";
TestUtil.displayTestTile(TEST_NAME);
PrismObject<ShadowType> shadow = getShadowModel(accountJackOid);
shadow.findReference(ShadowType.F_RESOURCE_REF).getValue().setObject(resourceDummy);
// WHEN
TestUtil.displayWhen(TEST_NAME);
Task task = taskManager.createTaskInstance(TEST_NAME);
ObjectWrapperFactory factory = new ObjectWrapperFactory(getServiceLocator());
ObjectWrapper<ShadowType> objectWrapper = factory.createObjectWrapper("shadow display name", "shadow description", shadow, ContainerStatus.MODIFYING, task);
// THEN
TestUtil.displayThen(TEST_NAME);
display("Wrapper after", objectWrapper);
WrapperTestUtil.assertWrapper(objectWrapper, "shadow display name", "shadow description", shadow, ContainerStatus.MODIFYING);
assertEquals("wrong number of containers in " + objectWrapper, 9, objectWrapper.getContainers().size());
ContainerWrapper<ShadowAttributesType> attributesContainerWrapper = objectWrapper.findContainerWrapper(new ItemPath(ShadowType.F_ATTRIBUTES));
PrismContainer<ShadowAttributesType> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES);
WrapperTestUtil.assertWrapper(attributesContainerWrapper, "prismContainer.shadow.mainPanelDisplayName", new ItemPath(ShadowType.F_ATTRIBUTES), attributesContainer, true, ContainerStatus.MODIFYING);
WrapperTestUtil.assertPropertyWrapper(attributesContainerWrapper, dummyResourceCtl.getAttributeFullnameQName(), USER_JACK_FULL_NAME);
WrapperTestUtil.assertPropertyWrapper(attributesContainerWrapper, SchemaConstants.ICFS_NAME, USER_JACK_USERNAME);
assertEquals("wrong number of items in " + attributesContainerWrapper, 16, attributesContainerWrapper.getItems().size());
ContainerWrapper<ActivationType> activationContainerWrapper = objectWrapper.findContainerWrapper(new ItemPath(UserType.F_ACTIVATION));
WrapperTestUtil.assertWrapper(activationContainerWrapper, "ShadowType.activation", UserType.F_ACTIVATION, shadow, ContainerStatus.MODIFYING);
WrapperTestUtil.assertPropertyWrapper(activationContainerWrapper, ActivationType.F_ADMINISTRATIVE_STATUS, ActivationStatusType.ENABLED);
WrapperTestUtil.assertPropertyWrapper(activationContainerWrapper, ActivationType.F_LOCKOUT_STATUS, null);
assertEquals("Wrong attributes container wrapper readOnly", Boolean.FALSE, (Boolean) attributesContainerWrapper.isReadonly());
ItemWrapper fullnameWrapper = attributesContainerWrapper.findPropertyWrapper(dummyResourceCtl.getAttributeFullnameQName());
// Is this OK?
assertEquals("Wrong attribute fullname readOnly", Boolean.FALSE, (Boolean) fullnameWrapper.isReadonly());
assertEquals("Wrong attribute fullname visible", Boolean.TRUE, (Boolean) fullnameWrapper.isVisible());
ItemDefinition fullNameDefinition = fullnameWrapper.getItemDefinition();
display("fullname attribute definition", fullNameDefinition);
assertEquals("Wrong attribute fullname definition.canRead", Boolean.TRUE, (Boolean) fullNameDefinition.canRead());
assertEquals("Wrong attribute fullname definition.canAdd", Boolean.TRUE, (Boolean) fullNameDefinition.canAdd());
assertEquals("Wrong attribute fullname definition.canModify", Boolean.TRUE, (Boolean) fullNameDefinition.canModify());
// MID-3144
if (fullNameDefinition.getDisplayOrder() == null || fullNameDefinition.getDisplayOrder() < 100 || fullNameDefinition.getDisplayOrder() > 400) {
AssertJUnit.fail("Wrong fullname definition.displayOrder: " + fullNameDefinition.getDisplayOrder());
}
assertEquals("Wrong attribute fullname definition.displayName", "Full Name", fullNameDefinition.getDisplayName());
}
use of com.evolveum.midpoint.prism.ItemDefinition in project midpoint by Evolveum.
the class ReportTypeUtil method applyConfigurationDefinition.
public static void applyConfigurationDefinition(PrismObject<ReportType> report, ObjectDelta delta, PrismContext prismContext) throws SchemaException {
PrismSchema schema = ReportTypeUtil.parseReportConfigurationSchema(report, prismContext);
PrismContainerDefinition<ReportConfigurationType> definition = ReportTypeUtil.findReportConfigurationDefinition(schema);
if (definition == null) {
//no definition found for container
throw new SchemaException("Couldn't find definitions for report type " + report + ".");
}
Collection<ItemDelta> modifications = delta.getModifications();
for (ItemDelta itemDelta : modifications) {
if (itemDelta.hasCompleteDefinition()) {
continue;
}
ItemDefinition def = definition.findItemDefinition(itemDelta.getPath().tail());
if (def != null) {
itemDelta.applyDefinition(def);
}
}
}
Aggregations