use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType in project midpoint by Evolveum.
the class SchemaTransformer method applyObjectTemplateToObject.
private <O extends ObjectType> void applyObjectTemplateToObject(PrismObject<O> object, ObjectTemplateType objectTemplateType, OperationResult result) throws ObjectNotFoundException, SchemaException {
if (objectTemplateType == null) {
return;
}
for (ObjectReferenceType includeRef : objectTemplateType.getIncludeRef()) {
PrismObject<ObjectTemplateType> subTemplate = cacheRepositoryService.getObject(ObjectTemplateType.class, includeRef.getOid(), null, result);
applyObjectTemplateToObject(object, subTemplate.asObjectable(), result);
}
for (ObjectTemplateItemDefinitionType templateItemDefType : objectTemplateType.getItem()) {
ItemPathType ref = templateItemDefType.getRef();
if (ref == null) {
throw new SchemaException("No 'ref' in item definition in " + objectTemplateType);
}
ItemPath itemPath = ref.getItemPath();
ItemDefinition itemDefFromObject = object.getDefinition().findItemDefinition(itemPath);
if (itemDefFromObject != null) {
applyObjectTemplateItem(itemDefFromObject, templateItemDefType, "item " + itemPath + " in " + object + " as specified in item definition in " + objectTemplateType);
} else {
OperationResult subResult = result.createMinorSubresult(SchemaTransformer.class.getName() + ".applyObjectTemplateToObject");
subResult.recordPartialError("No definition for item " + itemPath + " in " + object + " as specified in item definition in " + objectTemplateType);
continue;
}
Item<?, ?> item = object.findItem(itemPath);
if (item != null) {
ItemDefinition itemDef = item.getDefinition();
if (itemDef != itemDefFromObject) {
applyObjectTemplateItem(itemDef, templateItemDefType, "item " + itemPath + " in " + object + " as specified in item definition in " + objectTemplateType);
}
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType in project midpoint by Evolveum.
the class ObjectMerger method computeProjectionDeltas.
private <O extends ObjectType> void computeProjectionDeltas(final ObjectDelta<O> leftLinkDelta, ObjectDelta<O> rightLinkDelta, final PrismObject<O> objectLeft, final PrismObject<O> objectRight, MergeConfigurationType mergeConfiguration, final String mergeConfigurationName, final Task task, final OperationResult result) throws SchemaException, ConfigurationException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, SecurityViolationException {
List<ShadowType> projectionsLeft = getProjections(objectLeft, task, result);
List<ShadowType> projectionsRight = getProjections(objectRight, task, result);
List<ShadowType> mergedProjections = new ArrayList<>();
List<ShadowType> matchedProjections = new ArrayList<>();
ProjectionMergeConfigurationType defaultProjectionMergeConfig = null;
for (ProjectionMergeConfigurationType projectionMergeConfig : mergeConfiguration.getProjection()) {
if (projectionMergeConfig.getProjectionDiscriminator() == null && projectionMergeConfig.getSituation() == null) {
defaultProjectionMergeConfig = projectionMergeConfig;
} else {
takeProjections(projectionMergeConfig.getLeft(), mergedProjections, matchedProjections, projectionsLeft, projectionsLeft, projectionsRight, projectionMergeConfig);
takeProjections(projectionMergeConfig.getRight(), mergedProjections, matchedProjections, projectionsRight, projectionsLeft, projectionsRight, projectionMergeConfig);
}
}
LOGGER.trace("Merged projections (before default): {}", mergedProjections);
LOGGER.trace("Matched projections (before default): {}", matchedProjections);
if (defaultProjectionMergeConfig != null) {
takeUnmatchedProjections(defaultProjectionMergeConfig.getLeft(), mergedProjections, matchedProjections, projectionsLeft);
takeUnmatchedProjections(defaultProjectionMergeConfig.getRight(), mergedProjections, matchedProjections, projectionsRight);
}
LOGGER.trace("Merged projections: {}", mergedProjections);
checkConflict(mergedProjections);
for (ShadowType mergedProjection : mergedProjections) {
PrismReferenceValue leftLinkRef = findLinkRef(objectLeft, mergedProjection);
if (leftLinkRef == null) {
PrismReferenceValue linkRefRight = findLinkRef(objectRight, mergedProjection);
LOGGER.trace("Moving projection right->left: {}", mergedProjection);
addUnlinkDelta(rightLinkDelta, linkRefRight);
addLinkDelta(leftLinkDelta, linkRefRight);
} else {
LOGGER.trace("Projection already at the left: {}", mergedProjection);
}
}
for (PrismReferenceValue leftLinkRef : getLinkRefs(objectLeft)) {
if (!hasProjection(mergedProjections, leftLinkRef)) {
LOGGER.trace("Removing left projection: {}", leftLinkRef);
addUnlinkDelta(leftLinkDelta, leftLinkRef);
} else {
LOGGER.trace("Left projection stays: {}", leftLinkRef);
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType in project midpoint by Evolveum.
the class ObjectMerger method computeItemDeltas.
private <O extends ObjectType> void computeItemDeltas(final ObjectDelta<O> leftObjectDelta, final PrismObject<O> objectLeft, final PrismObject<O> objectRight, final List<ItemPath> processedPaths, MergeConfigurationType mergeConfiguration, final String mergeConfigurationName, final Task task, final OperationResult result) throws SchemaException, ConfigurationException, ExpressionEvaluationException, ObjectNotFoundException {
for (ItemRefMergeConfigurationType itemMergeConfig : mergeConfiguration.getItem()) {
ItemPath itemPath = itemMergeConfig.getRef().getItemPath();
processedPaths.add(itemPath);
ItemDelta itemDelta = mergeItem(objectLeft, objectRight, mergeConfigurationName, itemMergeConfig, itemPath, task, result);
LOGGER.trace("Item {} delta: {}", itemPath, itemDelta);
if (itemDelta != null && !itemDelta.isEmpty()) {
leftObjectDelta.addModification(itemDelta);
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType in project midpoint by Evolveum.
the class ObjectMerger method getProjections.
private <O extends ObjectType> List<ShadowType> getProjections(PrismObject<O> objectRight, Task task, OperationResult result) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
if (!objectRight.canRepresent(FocusType.class)) {
return new ArrayList<>(0);
}
List<ObjectReferenceType> linkRefs = ((FocusType) objectRight.asObjectable()).getLinkRef();
List<ShadowType> projections = new ArrayList<>(linkRefs.size());
for (ObjectReferenceType linkRef : linkRefs) {
projections.add(getProjection(linkRef, task, result));
}
return projections;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType in project midpoint by Evolveum.
the class ObjectSelectionPanel method initLayout.
public void initLayout(PageBase pageBase) {
Form searchForm = new Form(ID_SEARCH_FORM);
searchForm.setOutputMarkupId(true);
add(searchForm);
searchForm.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return context.isSearchEnabled();
}
});
BasicSearchPanel<ObjectSearchDto> basicSearch = new BasicSearchPanel<ObjectSearchDto>(ID_BASIC_SEARCH) {
@Override
protected IModel<String> createSearchTextModel() {
return new PropertyModel<>(searchModel, ObjectSearchDto.F_SEARCH_TEXT);
}
@Override
protected void searchPerformed(AjaxRequestTarget target) {
ObjectSelectionPanel.this.searchPerformed(target);
}
@Override
protected void clearSearchPerformed(AjaxRequestTarget target) {
ObjectSelectionPanel.this.clearSearchPerformed(target);
}
};
searchForm.add(basicSearch);
add(context.createExtraContentContainer(ID_EXTRA_CONTENT_CONTAINER, this));
List<IColumn<SelectableBean<ObjectType>, String>> columns = initColumns();
ObjectDataProvider provider = new ObjectDataProvider(pageBase, this.objectType);
provider.setQuery(context.getDataProviderQuery());
provider.setOptions(context.getDataProviderOptions());
TablePanel table = new TablePanel<>(ID_TABLE, provider, columns);
table.setOutputMarkupId(true);
addOrReplace(table);
AjaxButton cancelButton = new AjaxButton(ID_BUTTON_CANCEL, createStringResource("chooseTypeDialog.button.cancel")) {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
modalWindow.close(ajaxRequestTarget);
}
};
add(cancelButton);
}
Aggregations