Search in sources :

Example 6 with PrismObjectDefinition

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;
}
Also used : PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) QName(javax.xml.namespace.QName) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) ArrayList(java.util.ArrayList) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) PrismReferenceDefinition(com.evolveum.midpoint.prism.PrismReferenceDefinition) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) List(java.util.List) ArrayList(java.util.ArrayList)

Example 7 with PrismObjectDefinition

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);
}
Also used : PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) PrismReference(com.evolveum.midpoint.prism.PrismReference) ReferenceDelta(com.evolveum.midpoint.prism.delta.ReferenceDelta) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 8 with PrismObjectDefinition

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);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 9 with PrismObjectDefinition

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());
}
Also used : OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) ArrayList(java.util.ArrayList) Collection(java.util.Collection) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 10 with PrismObjectDefinition

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());
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) ArrayList(java.util.ArrayList) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

PrismObjectDefinition (com.evolveum.midpoint.prism.PrismObjectDefinition)21 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 ArrayList (java.util.ArrayList)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)5 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)4 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)4 QName (javax.xml.namespace.QName)4 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)3 PrismContext (com.evolveum.midpoint.prism.PrismContext)3 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)3 Task (com.evolveum.midpoint.task.api.Task)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 Collection (java.util.Collection)3 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)2 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)2 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)2 PrismReference (com.evolveum.midpoint.prism.PrismReference)2 EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)2 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)2