Skip to content

Commit

Permalink
Merge branch 'master' into feature/manual-connectors
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Apr 26, 2017
2 parents 2891037 + 98ac4e0 commit 8de93c8
Show file tree
Hide file tree
Showing 20 changed files with 178 additions and 119 deletions.
Expand Up @@ -101,7 +101,7 @@ private void initLayout(PageAdminObjectDetails<O> parentPage) {
mainForm = new Form<>(ID_MAIN_FORM, true);
add(mainForm);
initLayoutTabs(parentPage);
initLayoutOptions(parentPage);
initLayoutOptions();
initLayoutButtons(parentPage);
}

Expand All @@ -114,7 +114,7 @@ protected void initLayoutTabs(final PageAdminObjectDetails<O> parentPage) {

protected abstract List<ITab> createTabs(PageAdminObjectDetails<O> parentPage);

protected void initLayoutOptions(PageAdminObjectDetails<O> parentPage) {
protected void initLayoutOptions() {
ExecuteChangeOptionsPanel optionsPanel = new ExecuteChangeOptionsPanel(ID_EXECUTE_OPTIONS,
executeOptionsModel, true, false);
optionsPanel.setVisible(getOptionsPanelVisibility());
Expand Down
Expand Up @@ -18,6 +18,7 @@

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.web.component.DateLabelComponent;
Expand All @@ -41,6 +42,7 @@
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -204,6 +206,12 @@ public List<WorkItemDto> getSelectedWorkItems() {

IColumn<WorkItemDto, String> createObjectNameColumn(final String headerKey) {
return new LinkColumn<WorkItemDto>(createStringResource(headerKey), WorkItemDto.F_OBJECT_NAME) {
private static final long serialVersionUID = 1L;

@Override
protected IModel<String> createLinkModel(IModel<WorkItemDto> rowModel) {
return Model.of(WebModelServiceUtils.resolveReferenceName(rowModel.getObject().getObjectRef(), getPageBase()));
}

@Override
public void onClick(AjaxRequestTarget target, IModel<WorkItemDto> rowModel) {
Expand All @@ -216,6 +224,11 @@ public void onClick(AjaxRequestTarget target, IModel<WorkItemDto> rowModel) {
IColumn<WorkItemDto, String> createTargetNameColumn(final String headerKey) {
return new LinkColumn<WorkItemDto>(createStringResource(headerKey), WorkItemDto.F_TARGET_NAME) {

@Override
protected IModel<String> createLinkModel(IModel<WorkItemDto> rowModel) {
return Model.of(WebModelServiceUtils.resolveReferenceName(rowModel.getObject().getTargetRef(), getPageBase()));
}

@Override
public void onClick(AjaxRequestTarget target, IModel<WorkItemDto> rowModel) {
WorkItemDto dto = rowModel.getObject();
Expand Down
Expand Up @@ -351,9 +351,17 @@ public String getCount() {
});
}

@Override
protected boolean getOptionsPanelVisibility() {
return PageUser.this.getOptionsPanelVisibility();
}
};
}

protected boolean getOptionsPanelVisibility(){
return true;
}

private List<AssignmentEditorDto> loadDelegatedByMeAssignments() {
OperationResult result = new OperationResult(OPERATION_LOAD_DELEGATED_BY_ME_ASSIGNMENTS);
List<AssignmentEditorDto> list = new ArrayList<>();
Expand Down
Expand Up @@ -40,8 +40,8 @@
import java.util.*;

import static com.evolveum.midpoint.gui.api.util.WebComponentUtil.*;
import static com.evolveum.midpoint.prism.PrismConstants.T_PARENT;
import static com.evolveum.midpoint.prism.query.OrderDirection.DESCENDING;
import static com.evolveum.midpoint.schema.GetOperationOptions.createResolve;
import static com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType.*;

/**
Expand Down Expand Up @@ -82,8 +82,10 @@ public Iterator<? extends WorkItemDto> internalIterator(long first, long count)
try {
ObjectQuery query = createQuery(first, count, result);
Collection<SelectorOptions<GetOperationOptions>> options =
Collections.singletonList(
SelectorOptions.create(new ItemPath(F_ASSIGNEE_REF), createResolve()));
GetOperationOptions.resolveItemsNamed(
new ItemPath(F_ASSIGNEE_REF),
new ItemPath(T_PARENT, WfContextType.F_OBJECT_REF),
new ItemPath(T_PARENT, WfContextType.F_TARGET_REF));
List<WorkItemType> items = getModel().searchContainers(WorkItemType.class, query, options, task, result);

for (WorkItemType item : items) {
Expand Down
Expand Up @@ -15,11 +15,13 @@
*/
package com.evolveum.midpoint.web.page.self;

import static com.evolveum.midpoint.prism.PrismConstants.T_PARENT;
import static com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType.F_CREATE_TIMESTAMP;

import java.util.*;

import com.evolveum.midpoint.gui.api.PredefinedDashboardWidgetId;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.schema.util.AdminGuiConfigTypeUtil;
import com.evolveum.midpoint.web.application.Url;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
Expand Down Expand Up @@ -282,7 +284,11 @@ private CallableResult<List<WorkItemDto>> loadWorkItems() {
.item(WorkItemType.F_ASSIGNEE_REF).ref(user.getOid())
.desc(F_CREATE_TIMESTAMP)
.build();
List<WorkItemType> workItems = getModelService().searchContainers(WorkItemType.class, query, null, task, result);
Collection<SelectorOptions<GetOperationOptions>> options =
GetOperationOptions.resolveItemsNamed(
new ItemPath(T_PARENT, WfContextType.F_OBJECT_REF),
new ItemPath(T_PARENT, WfContextType.F_TARGET_REF));
List<WorkItemType> workItems = getModelService().searchContainers(WorkItemType.class, query, options, task, result);
for (WorkItemType workItem : workItems) {
list.add(new WorkItemDto(workItem));
}
Expand Down
Expand Up @@ -22,7 +22,9 @@
import com.evolveum.midpoint.web.application.AuthorizationAction;
import com.evolveum.midpoint.web.application.PageDescriptor;
import com.evolveum.midpoint.web.component.breadcrumbs.Breadcrumb;
import com.evolveum.midpoint.web.component.form.Form;
import com.evolveum.midpoint.web.page.admin.users.PageUser;
import com.evolveum.midpoint.web.page.admin.users.component.ExecuteChangeOptionsPanel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

Expand All @@ -46,13 +48,11 @@ protected String getObjectOidParameter() {
return WebModelServiceUtils.getLoggedInUserOid();
}

//
// @Override
// protected ExecuteChangeOptionsPanel initOptions(final Form mainForm) {
// ExecuteChangeOptionsPanel optionsPanel = super.initOptions(mainForm);
// optionsPanel.setVisible(false);
// return optionsPanel;
// }

@Override
protected boolean getOptionsPanelVisibility(){
return false;
}


@Override
Expand Down
Expand Up @@ -247,7 +247,7 @@
}
.user-image {
float: left;
width: 25px;
max-width: 25px;
height: 25px;
border-radius: 35%;
margin-right: 10px;
Expand Down
3 changes: 1 addition & 2 deletions gui/admin-gui/src/main/webapp/less/midpoint-theme.less
Expand Up @@ -156,8 +156,7 @@ th.cog, td.cog {
background-color: #FFFFFF;
border-radius: 35%;
height: 115px;
width: 115px;
max-width: 100%;
max-width: 115px;
max-height: 100%;
vertical-align: middle;
}
Expand Down
Expand Up @@ -466,7 +466,11 @@ protected void checkMutability() {
@Nullable
abstract public <T> T getRealValue();

// returns PCV or this
// Returns a root of PrismValue tree. For example, if we have a AccessCertificationWorkItemType that has a parent (owner)
// of AccessCertificationCaseType, which has a parent of AccessCertificationCampaignType, this method returns the PCV
// of AccessCertificationCampaignType.
//
// Generally, this method returns either "this" (PrismValue) or a PrismContainerValue.
public PrismValue getRootValue() {
PrismValue current = this;
for (;;) {
Expand Down
Expand Up @@ -78,8 +78,8 @@ public static <T> Collection<SelectorOptions<T>> createCollection(QName pathQNam
}

public static <T> Collection<SelectorOptions<T>> createCollection(T options) {
Collection<SelectorOptions<T>> optionsCollection = new ArrayList<SelectorOptions<T>>(1);
optionsCollection.add(new SelectorOptions<T>(options));
Collection<SelectorOptions<T>> optionsCollection = new ArrayList<>(1);
optionsCollection.add(new SelectorOptions<>(options));
return optionsCollection;
}

Expand Down
Expand Up @@ -68,11 +68,12 @@ public RefinedResourceSchema getRefinedResourceSchema(String resourceOid) {
}
}

public ResourceDataItem findResourceItem(@NotNull String resourceOid, @Nullable ShadowKindType kind, @Nullable String intent, @NotNull ItemPath path) {
public ResourceDataItem findResourceItem(@NotNull String resourceOid, @Nullable ShadowKindType kind, @Nullable String intent,
QName objectClassName, @NotNull ItemPath path) {
kind = DataModelVisualizerImpl.def(kind);
intent = DataModelVisualizerImpl.def(intent);
for (ResourceDataItem item : getResourceDataItems()) {
if (item.matches(resourceOid, kind, intent, path)) {
if (item.matches(resourceOid, kind, intent, objectClassName, path)) {
return item;
}
}
Expand Down
Expand Up @@ -134,7 +134,8 @@ private void processResourceMappings(DataModel model, List<PrismObject<ResourceT
continue;
}
LOGGER.debug("Processing refined attribute definition for {}", attributeDefinition.getName());
ResourceDataItem attrItem = model.findResourceItem(resource.getOid(), kind, intent, new ItemPath(attributeDefinition.getName()));
ResourceDataItem attrItem = model.findResourceItem(resource.getOid(), kind, intent, getObjectClassName(refinedDefinition),
new ItemPath(attributeDefinition.getName()));
if (attributeDefinition.getOutboundMappingType() != null) {
processOutboundMapping(model, attrItem, attributeDefinition.getOutboundMappingType(), null);
}
Expand All @@ -146,7 +147,8 @@ private void processResourceMappings(DataModel model, List<PrismObject<ResourceT
continue;
}
LOGGER.debug("Processing refined association definition for {}", associationDefinition.getName());
ResourceDataItem assocItem = model.findResourceItem(resource.getOid(), kind, intent, new ItemPath(associationDefinition.getName()));
ResourceDataItem assocItem = model.findResourceItem(resource.getOid(), kind, intent, getObjectClassName(refinedDefinition),
new ItemPath(associationDefinition.getName()));
if (associationDefinition.getOutboundMappingType() != null) {
processOutboundMapping(model, assocItem, associationDefinition.getOutboundMappingType(), null);
}
Expand All @@ -158,16 +160,18 @@ private void processResourceMappings(DataModel model, List<PrismObject<ResourceT
}
ResourceActivationDefinitionType actMapping = refinedDefinition.getActivationSchemaHandling();
if (actMapping != null) {
processBidirectionalMapping(model, resource.getOid(), kind, intent, new ItemPath(FocusType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS), actMapping.getAdministrativeStatus());
processBidirectionalMapping(model, resource.getOid(), kind, intent, new ItemPath(FocusType.F_ACTIVATION, ActivationType.F_VALID_FROM), actMapping.getValidFrom());
processBidirectionalMapping(model, resource.getOid(), kind, intent, new ItemPath(FocusType.F_ACTIVATION, ActivationType.F_VALID_TO), actMapping.getValidTo());
processBidirectionalMapping(model, resource.getOid(), kind, intent, new ItemPath(FocusType.F_ACTIVATION, ActivationType.F_LOCKOUT_STATUS), actMapping.getLockoutStatus());
processBidirectionalMapping(model, resource.getOid(), kind, intent, new ItemPath(FocusType.F_ACTIVATION, ACTIVATION_EXISTENCE), actMapping.getExistence());
QName objectClassName = getObjectClassName(refinedDefinition);
processBidirectionalMapping(model, resource.getOid(), kind, intent, objectClassName, new ItemPath(FocusType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS), actMapping.getAdministrativeStatus());
processBidirectionalMapping(model, resource.getOid(), kind, intent, objectClassName, new ItemPath(FocusType.F_ACTIVATION, ActivationType.F_VALID_FROM), actMapping.getValidFrom());
processBidirectionalMapping(model, resource.getOid(), kind, intent, objectClassName, new ItemPath(FocusType.F_ACTIVATION, ActivationType.F_VALID_TO), actMapping.getValidTo());
processBidirectionalMapping(model, resource.getOid(), kind, intent, objectClassName, new ItemPath(FocusType.F_ACTIVATION, ActivationType.F_LOCKOUT_STATUS), actMapping.getLockoutStatus());
processBidirectionalMapping(model, resource.getOid(), kind, intent, objectClassName, new ItemPath(FocusType.F_ACTIVATION, ACTIVATION_EXISTENCE), actMapping.getExistence());
}
ResourcePasswordDefinitionType pwdDef = refinedDefinition.getPasswordDefinition();
if (pwdDef != null) {
final ItemPath pwdPath = new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD);
ResourceDataItem resourceDataItem = model.findResourceItem(resource.getOid(), kind, intent, pwdPath);
ResourceDataItem resourceDataItem = model.findResourceItem(resource.getOid(), kind, intent,
getObjectClassName(refinedDefinition), pwdPath);
if (resourceDataItem == null) {
throw new IllegalStateException("No resource item for " + resource.getOid() + ":" + kind + ":" + intent + ":" + pwdPath);
}
Expand All @@ -184,14 +188,14 @@ private void processResourceMappings(DataModel model, List<PrismObject<ResourceT
}
}

private void processBidirectionalMapping(DataModel model, String oid, ShadowKindType kind, String intent, ItemPath itemPath,
private void processBidirectionalMapping(DataModel model, String oid, ShadowKindType kind, String intent, QName objectClassName, ItemPath itemPath,
ResourceBidirectionalMappingType mapping) {
if (mapping == null) {
return;
}
ResourceDataItem resourceDataItem = model.findResourceItem(oid, kind, intent, itemPath);
ResourceDataItem resourceDataItem = model.findResourceItem(oid, kind, intent, objectClassName, itemPath);
if (resourceDataItem == null) {
throw new IllegalStateException("No resource item for " + oid + ":" + kind + ":" + intent + ":" + itemPath);
throw new IllegalStateException("No resource item for " + oid + ":" + kind + ":" + intent + ":" + objectClassName + ":" + itemPath);
}
for (MappingType outbound : mapping.getOutbound()) {
processOutboundMapping(model, resourceDataItem, outbound, itemPath);
Expand Down Expand Up @@ -229,9 +233,7 @@ private void createDataItems(DataModel model, List<PrismObject<ResourceType>> re
continue;
}
LOGGER.debug("Registering refined attribute definition for {}", attributeDefinition.getName());
ResourceDataItem attrItem = new ResourceDataItem(model, resource.getOid(), kind, intent, attributeDefinition.getName());
attrItem.setRefinedResourceSchema(refinedResourceSchema);
attrItem.setRefinedObjectClassDefinition(refinedDefinition);
ResourceDataItem attrItem = new ResourceDataItem(model, resource.getOid(), kind, intent, refinedResourceSchema, refinedDefinition, attributeDefinition.getName());
attrItem.setRefinedAttributeDefinition(attributeDefinition);
// TODO check the name
model.registerDataItem(attrItem);
Expand All @@ -243,15 +245,15 @@ private void createDataItems(DataModel model, List<PrismObject<ResourceType>> re
continue;
}
LOGGER.debug("Registering refined association definition for {}", associationDefinition.getName());
ResourceDataItem assocItem = new ResourceDataItem(model, resource.getOid(), kind, intent, associationDefinition.getName());
ResourceDataItem assocItem = new ResourceDataItem(model, resource.getOid(), kind, intent, refinedResourceSchema, refinedDefinition, associationDefinition.getName());
model.registerDataItem(assocItem);
}
model.registerDataItem(new ResourceDataItem(model, resource.getOid(), kind, intent, new ItemPath(ShadowType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS)));
model.registerDataItem(new ResourceDataItem(model, resource.getOid(), kind, intent, new ItemPath(ShadowType.F_ACTIVATION, ActivationType.F_LOCKOUT_STATUS)));
model.registerDataItem(new ResourceDataItem(model, resource.getOid(), kind, intent, new ItemPath(ShadowType.F_ACTIVATION, ActivationType.F_VALID_FROM)));
model.registerDataItem(new ResourceDataItem(model, resource.getOid(), kind, intent, new ItemPath(ShadowType.F_ACTIVATION, ActivationType.F_VALID_TO)));
model.registerDataItem(new ResourceDataItem(model, resource.getOid(), kind, intent, new ItemPath(ShadowType.F_ACTIVATION, ACTIVATION_EXISTENCE)));
model.registerDataItem(new ResourceDataItem(model, resource.getOid(), kind, intent, new ItemPath(ShadowType.F_CREDENTIALS, CredentialsType.F_PASSWORD)));
model.registerDataItem(new ResourceDataItem(model, resource.getOid(), kind, intent, refinedResourceSchema, refinedDefinition, new ItemPath(ShadowType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS)));
model.registerDataItem(new ResourceDataItem(model, resource.getOid(), kind, intent, refinedResourceSchema, refinedDefinition, new ItemPath(ShadowType.F_ACTIVATION, ActivationType.F_LOCKOUT_STATUS)));
model.registerDataItem(new ResourceDataItem(model, resource.getOid(), kind, intent, refinedResourceSchema, refinedDefinition, new ItemPath(ShadowType.F_ACTIVATION, ActivationType.F_VALID_FROM)));
model.registerDataItem(new ResourceDataItem(model, resource.getOid(), kind, intent, refinedResourceSchema, refinedDefinition, new ItemPath(ShadowType.F_ACTIVATION, ActivationType.F_VALID_TO)));
model.registerDataItem(new ResourceDataItem(model, resource.getOid(), kind, intent, refinedResourceSchema, refinedDefinition, new ItemPath(ShadowType.F_ACTIVATION, ACTIVATION_EXISTENCE)));
model.registerDataItem(new ResourceDataItem(model, resource.getOid(), kind, intent, refinedResourceSchema, refinedDefinition, new ItemPath(ShadowType.F_CREDENTIALS, CredentialsType.F_PASSWORD)));
}
}
// createRepoDataItems(UserType.class);
Expand Down Expand Up @@ -421,7 +423,8 @@ private Class<? extends ObjectType> guessFocusClass(@NotNull String resourceOid,
}

private ResourceDataItem resolveResourceItem(DataModel model, ResourceDataItem currentItem, ItemPath path) {
return model.findResourceItem(currentItem.getResourceOid(), currentItem.getKind(), currentItem.getIntent(), path);
return model.findResourceItem(currentItem.getResourceOid(), currentItem.getKind(), currentItem.getIntent(),
currentItem.getObjectClassName(), path);
}

private void processOutboundMapping(@NotNull DataModel model, @NotNull ResourceDataItem targetItem, @NotNull MappingType mapping,
Expand All @@ -446,4 +449,9 @@ private void processOutboundMapping(@NotNull DataModel model, @NotNull ResourceD
model.registerMappingRelation(sources, targetItem, mapping);
}

// TODO move to appropriate place
private QName getObjectClassName(RefinedObjectClassDefinition def) {
return def != null ? def.getTypeName() : null;
}

}

0 comments on commit 8de93c8

Please sign in to comment.