use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType in project midpoint by Evolveum.
the class ResourceTypeAssignmentPopupTabPanel method getSelectedAssignmentsMap.
@Override
protected Map<String, AssignmentType> getSelectedAssignmentsMap() {
Map<String, AssignmentType> assignmentList = new HashMap<>();
List<ResourceType> selectedObjects = getSelectedObjectsList();
ShadowKindType kind = getKindValue();
String intent = getIntentValue();
selectedObjects.forEach(selectedObject -> {
AssignmentType newConstructionAssignment = ObjectTypeUtil.createAssignmentWithConstruction(selectedObject.asPrismObject(), kind, intent, getPageBase().getPrismContext());
if (isEntitlementAssignment()) {
NameItemPathSegment segment = getAssociationValue() != null ? new NameItemPathSegment(getAssociationValue().getName()) : null;
if (segment != null) {
ResourceObjectAssociationType association = new ResourceObjectAssociationType();
association.setRef(new ItemPathType(ItemPath.create(segment)));
newConstructionAssignment.getConstruction().getAssociation().add(association);
}
}
assignmentList.put(selectedObject.getOid(), newConstructionAssignment);
});
return assignmentList;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType in project midpoint by Evolveum.
the class TestEnergy method setKindIntent.
@SuppressWarnings("SameParameterValue")
private void setKindIntent(String shadowName, ShadowKindType kind, String intent, OperationResult result) throws CommonException {
QName groupOcName = RESOURCE_AD.controller.getGroupObjectClass();
PrismObject<ResourceType> ad = getObject(ResourceType.class, RESOURCE_AD.oid);
PrismObject<ShadowType> shadow = findShadowByName(groupOcName, shadowName, ad, result);
repositoryService.modifyObject(ShadowType.class, shadow.getOid(), prismContext.deltaFor(ShadowType.class).item(ShadowType.F_KIND).replace(kind).item(ShadowType.F_INTENT).replace(intent).asItemDeltas(), null, result);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType in project midpoint by Evolveum.
the class ConstructionDetailsPanelChainedModel method initLayout.
private void initLayout() {
CompoundPropertyModel constrModel = new CompoundPropertyModel(getModel()) {
@Override
public Object getObject() {
Object o = super.getObject();
return o;
}
@Override
public void setObject(Object o) {
super.setObject(o);
}
};
Form<ConstructionType> form = new Form<ConstructionType>(ID_FORM, constrModel);
form.setOutputMarkupId(true);
DropDownChoice kindChoice = new DropDownChoice<>("kind", Model.ofList(Arrays.asList(ShadowKindType.values())));
kindChoice.setOutputMarkupId(true);
kindChoice.add(new EmptyOnBlurAjaxFormUpdatingBehaviour() {
@Override
protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
// ajaxRequestTarget.add(form);
}
});
// kindChoice.add(new AjaxEventBehavior("blur") {
// @Override
// protected void onEvent(AjaxRequestTarget ajaxRequestTarget) {
// ajaxRequestTarget.add(form);
// }
// });
form.add(kindChoice);
DropDownChoice intentDropdown = new DropDownChoice<>("intent", new IModel<List<String>>() {
@Override
public List<String> getObject() {
List<String> availableIntentValues = new ArrayList<>();
try {
if (resourceModel.getObject() == null) {
return availableIntentValues;
}
ResourceSchema refinedSchema = ResourceSchemaFactory.getCompleteSchema(resourceModel.getObject());
if (refinedSchema != null) {
ConstructionType m = (ConstructionType) constrModel.getObject();
ShadowKindType kind = m.getKind();
List<? extends ResourceObjectTypeDefinition> definitions = refinedSchema.getObjectTypeDefinitions(kind);
for (ResourceObjectTypeDefinition def : definitions) {
if (def.getIntent() != null) {
availableIntentValues.add(def.getIntent());
}
}
}
} catch (SchemaException ex) {
LOGGER.error("Cannot get refined resource schema for resource {}. {}", resourceModel.getObject().getName().getOrig(), ex.getLocalizedMessage());
}
return availableIntentValues;
}
@Override
public void setObject(List<String> o) {
//
}
@Override
public void detach() {
}
});
intentDropdown.setOutputMarkupId(true);
form.add(intentDropdown);
add(form);
// DropDownChoice kindDropDown = new DropDownChoice<ShadowKindType>(ID_KIND_FIELD, kindModel, Model.ofList(Arrays.asList(ShadowKindType.values()))){
// @Override
// protected void onSelectionChanged(ShadowKindType newSelection) {
// if (newSelection == null){
// ConstructionDetailsPanelChainedModel.this.getModelObject().setKind(null);
// return;
// }
// if (newSelection instanceof ShadowKindType){
// ConstructionDetailsPanelChainedModel.this.getModelObject().setKind((ShadowKindType) newSelection);
// }
// }
// };
// kindDropDown.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
//
// kindDropDown.setOutputMarkupId(true);
// add(kindDropDown);
//
// TextField intentDropDown = new TextField(ID_INTENT_FIELD, intentChoicesModel);
// DropDownChoicePanel intentDropDown = new DropDownChoicePanel(ID_INTENT_FIELD,
// PropertyModel.of(getModel(), ConstructionType.F_INTENT.getLocalPart()), intentChoicesModel);
// intentDropDown.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
// intentDropDown.setOutputMarkupId(true);
// add(intentDropDown);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType in project midpoint by Evolveum.
the class ConstructionDetailsPanelChainedModel method initModels.
private void initModels() {
resourceModel = new LoadableDetachableModel<PrismObject<ResourceType>>() {
@Override
protected PrismObject<ResourceType> load() {
ObjectReferenceType resourceRef = getModelObject().getResourceRef();
Task loadResourceTask = getPageBase().createSimpleTask(OPERATION_LOAD_RESOURCE);
OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCE);
PrismObject<ResourceType> resource = WebModelServiceUtils.loadObject(resourceRef, getPageBase(), loadResourceTask, result);
result.computeStatusIfUnknown();
if (!result.isAcceptable()) {
LOGGER.error("Cannot find resource referenced from construction. {}", result.getMessage());
result.recordPartialError("Could not find resource referenced from construction.");
return null;
}
return resource;
}
};
kindModel = new IModel<ShadowKindType>() {
@Override
public ShadowKindType getObject() {
return getModelObject().getKind();
}
@Override
public void setObject(ShadowKindType shadowKindType) {
getModelObject().setKind(shadowKindType);
}
@Override
public void detach() {
}
};
intentChoicesModel = new ChainingModel<String>(kindModel) {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
List<String> availableIntentValues = new ArrayList<>();
try {
if (resourceModel.getObject() == null) {
return availableIntentValues.toString();
}
ResourceSchema refinedSchema = ResourceSchemaFactory.getCompleteSchema(resourceModel.getObject());
if (refinedSchema != null) {
ShadowKindType kind = ((IModel<ShadowKindType>) super.getChainedModel()).getObject();
List<? extends ResourceObjectTypeDefinition> definitions = refinedSchema.getObjectTypeDefinitions(kind);
for (ResourceObjectTypeDefinition def : definitions) {
if (def.getIntent() != null) {
availableIntentValues.add(def.getIntent());
}
}
}
} catch (SchemaException ex) {
LOGGER.error("Cannot get refined resource schema for resource {}. {}", resourceModel.getObject().getName().getOrig(), ex.getLocalizedMessage());
}
return availableIntentValues.toString();
}
@Override
public void setObject(String o) {
super.setObject(o);
}
};
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType in project midpoint by Evolveum.
the class ResourceObjectDefinitionResolver method getDefinitionForShadow.
/**
* Returns appropriate {@link ResourceObjectDefinition} for given shadow. We are not too strict here.
* Unknown kind/intent values are ignored (treated like null). Intent without kind is ignored.
*
* Takes auxiliary object classes defined in the shadow into account.
*
* Note: we could be even more relaxed (in the future):
*
* 1. Currently the consistency between kind, intent, and OC is checked. We could avoid this.
* 2. The {@link ResourceSchema#findObjectDefinition(ShadowKindType, String, QName)} method used throws an exception
* when it cannot decide among various definitions for given kind (when intent and OC is null). We could be more
* permissive and return any of them.
*/
@Nullable
public static ResourceObjectDefinition getDefinitionForShadow(@NotNull ResourceSchema resourceSchema, @NotNull ShadowType shadow) {
QName objectClassName = shadow.getObjectClass();
ShadowKindType kind;
String intent;
// Ignoring "UNKNOWN" values
if (shadow.getKind() == null || shadow.getKind() == ShadowKindType.UNKNOWN) {
kind = null;
intent = null;
} else {
kind = shadow.getKind();
if (SchemaConstants.INTENT_UNKNOWN.equals(shadow.getIntent())) {
intent = null;
} else {
intent = shadow.getIntent();
}
}
ResourceObjectDefinition structuralDefinition;
if (kind != null) {
structuralDefinition = resourceSchema.findObjectDefinition(kind, intent, objectClassName);
} else if (objectClassName != null) {
structuralDefinition = resourceSchema.findDefinitionForObjectClass(objectClassName);
} else {
structuralDefinition = null;
}
if (structuralDefinition != null) {
return addAuxiliaryObjectClasses(structuralDefinition, shadow.getAuxiliaryObjectClass(), resourceSchema);
} else {
return null;
}
}
Aggregations