use of com.evolveum.midpoint.prism.PrismObjectDefinition in project midpoint by Evolveum.
the class FocusProjectionsTabPanel method createShadowMenu.
private List<InlineMenuItem> createShadowMenu() {
List<InlineMenuItem> items = new ArrayList<InlineMenuItem>();
PrismObjectDefinition def = getObjectWrapper().getObject().getDefinition();
PrismReferenceDefinition ref = def.findReferenceDefinition(UserType.F_LINK_REF);
InlineMenuItem item;
if (ref.canRead() && ref.canAdd()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.addShadow"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
List<QName> supportedTypes = new ArrayList<>(1);
supportedTypes.add(ResourceType.COMPLEX_TYPE);
PageBase pageBase = FocusProjectionsTabPanel.this.getPageBase();
ObjectBrowserPanel<ResourceType> resourceSelectionPanel = new ObjectBrowserPanel<ResourceType>(pageBase.getMainPopupBodyId(), ResourceType.class, supportedTypes, true, pageBase) {
@Override
protected void addPerformed(AjaxRequestTarget target, QName type, List<ResourceType> selected) {
// TODO Auto-generated method stub
FocusProjectionsTabPanel.this.addSelectedAccountPerformed(target, selected);
}
};
resourceSelectionPanel.setOutputMarkupId(true);
pageBase.showMainPopup(resourceSelectionPanel, target);
}
});
items.add(item);
items.add(new InlineMenuItem());
}
PrismPropertyDefinition prop = def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
if (prop.canRead() && prop.canModify()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.enable"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
updateShadowActivation(target, getSelectedProjections(projectionModel), true);
}
});
items.add(item);
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.disable"), new InlineMenuItemAction() {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
updateShadowActivation(target, getSelectedProjections(projectionModel), false);
}
});
items.add(item);
}
if (ref.canRead() && ref.canAdd()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.unlink"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
unlinkProjectionPerformed(target, projectionModel, getSelectedProjections(projectionModel), ID_SHADOWS);
}
});
items.add(item);
}
prop = def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS);
if (prop.canRead() && prop.canModify()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.unlock"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
unlockShadowPerformed(target, projectionModel, getSelectedProjections(projectionModel));
}
});
items.add(item);
}
prop = def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
if (prop.canRead() && prop.canModify()) {
items.add(new InlineMenuItem());
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.delete"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
deleteProjectionPerformed(target, projectionModel);
}
});
items.add(item);
}
return items;
}
use of com.evolveum.midpoint.prism.PrismObjectDefinition in project midpoint by Evolveum.
the class ObjectUpdater method createAddParentRefDelta.
private <T extends ObjectType> List<ReferenceDelta> createAddParentRefDelta(PrismObject<T> object) {
PrismReference parentOrgRef = object.findReference(ObjectType.F_PARENT_ORG_REF);
if (parentOrgRef == null || parentOrgRef.isEmpty()) {
return new ArrayList<>();
}
PrismObjectDefinition def = object.getDefinition();
ReferenceDelta delta = ReferenceDelta.createModificationAdd(new ItemPath(ObjectType.F_PARENT_ORG_REF), def, parentOrgRef.getClonedValues());
return Arrays.asList(delta);
}
use of com.evolveum.midpoint.prism.PrismObjectDefinition in project midpoint by Evolveum.
the class AddOverwriteTest method getCarla.
private PrismObject getCarla(OperationResult opResult) throws Exception {
final String CARLA_NAME = "carla";
PrismObjectDefinition userObjectDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class);
ObjectQuery query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_NAME).eq(CARLA_NAME).build();
List<PrismObject<UserType>> users = repositoryService.searchObjects(UserType.class, query, null, opResult);
AssertJUnit.assertEquals(1, users.size());
return users.get(0);
}
use of com.evolveum.midpoint.prism.PrismObjectDefinition in project midpoint by Evolveum.
the class AddOverwriteTest method test091GetVersion.
@Test
public void test091GetVersion() throws Exception {
OperationResult result = new OperationResult("get version");
String version = repositoryService.getVersion(OrgType.class, ORG_OID, result);
AssertJUnit.assertEquals("0", version);
PrismObjectDefinition def = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(OrgType.class);
Collection deltas = new ArrayList();
deltas.add(PropertyDelta.createAddDelta(def, OrgType.F_ORG_TYPE, "asdf"));
repositoryService.modifyObject(OrgType.class, ORG_OID, deltas, result);
version = repositoryService.getVersion(OrgType.class, ORG_OID, result);
AssertJUnit.assertEquals("1", version);
result.recomputeStatus();
AssertJUnit.assertTrue(result.isSuccess());
}
use of com.evolveum.midpoint.prism.PrismObjectDefinition in project midpoint by Evolveum.
the class AbstractOrgClosureTest method addOrgParent.
// TODO generalzie to addObjectParent
protected void addOrgParent(OrgType org, ObjectReferenceType parentOrgRef, boolean useReplace, OperationResult opResult) throws Exception {
List<ItemDelta> modifications = new ArrayList<>();
PrismReferenceValue existingValue = parentOrgRef.asReferenceValue();
ItemDelta itemDelta;
if (!useReplace) {
itemDelta = ReferenceDelta.createModificationAdd(OrgType.class, OrgType.F_PARENT_ORG_REF, prismContext, existingValue.clone());
} else {
List<PrismReferenceValue> newValues = new ArrayList<>();
for (ObjectReferenceType ort : org.getParentOrgRef()) {
newValues.add(ort.asReferenceValue().clone());
}
newValues.add(existingValue.clone());
PrismObjectDefinition objectDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(OrgType.class);
itemDelta = ReferenceDelta.createModificationReplace(new ItemPath(OrgType.F_PARENT_ORG_REF), objectDefinition, newValues);
}
modifications.add(itemDelta);
repositoryService.modifyObject(OrgType.class, org.getOid(), modifications, opResult);
orgGraph.addEdge(org.getOid(), existingValue.getOid());
}
Aggregations