Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Aug 29, 2016
2 parents a664209 + 4b58b2a commit 0145268
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 41 deletions.
Expand Up @@ -243,9 +243,12 @@ public final class WebComponentUtil {

static {
storageTableIdMap = new HashMap<>();
storageTableIdMap.put(TableId.PAGE_RESOURCE_ACCOUNTS_PANEL, SessionStorage.KEY_RESOURCE_ACCOUNT_CONTENT);
storageTableIdMap.put(TableId.PAGE_RESOURCE_ENTITLEMENT_PANEL, SessionStorage.KEY_RESOURCE_ENTITLEMENT_CONTENT);
storageTableIdMap.put(TableId.PAGE_RESOURCE_GENERIC_PANEL, SessionStorage.KEY_RESOURCE_GENERIC_CONTENT);
storageTableIdMap.put(TableId.PAGE_RESOURCE_ACCOUNTS_PANEL_REPOSITORY_MODE, SessionStorage.KEY_RESOURCE_ACCOUNT_CONTENT + SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT);
storageTableIdMap.put(TableId.PAGE_RESOURCE_ACCOUNTS_PANEL_RESOURCE_MODE, SessionStorage.KEY_RESOURCE_ACCOUNT_CONTENT + SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT);
storageTableIdMap.put(TableId.PAGE_RESOURCE_ENTITLEMENT_PANEL_REPOSITORY_MODE, SessionStorage.KEY_RESOURCE_ENTITLEMENT_CONTENT + SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT);
storageTableIdMap.put(TableId.PAGE_RESOURCE_ENTITLEMENT_PANEL_RESOURCE_MODE, SessionStorage.KEY_RESOURCE_ENTITLEMENT_CONTENT + SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT);
storageTableIdMap.put(TableId.PAGE_RESOURCE_GENERIC_PANEL_REPOSITORY_MODE, SessionStorage.KEY_RESOURCE_GENERIC_CONTENT + SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT);
storageTableIdMap.put(TableId.PAGE_RESOURCE_GENERIC_PANEL_RESOURCE_MODE, SessionStorage.KEY_RESOURCE_GENERIC_CONTENT + SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT);
storageTableIdMap.put(TableId.PAGE_RESOURCE_OBJECT_CLASS_PANEL, SessionStorage.KEY_RESOURCE_OBJECT_CLASS_CONTENT);

}
Expand Down
Expand Up @@ -275,7 +275,9 @@ public void onClick(AjaxRequestTarget target) {
}

private void resourceDetailsPerformed(AjaxRequestTarget target, String oid) {
PageParameters parameters = new PageParameters();
clearSessionStorageForResourcePage();

PageParameters parameters = new PageParameters();
parameters.add(OnePageParameterEncoder.PARAMETER, oid);
setResponsePage(PageResource.class, parameters);
}
Expand Down Expand Up @@ -448,4 +450,9 @@ private void editAsXmlPerformed(ResourceType resourceType) {
parameters.add(PageDebugView.PARAM_OBJECT_TYPE, ResourceType.class.getSimpleName());
setResponsePage(PageDebugView.class, parameters);
}

private void clearSessionStorageForResourcePage() {
((PageBase) getPage()).getSessionStorage().clearResourceContentStorage();
}

}
Expand Up @@ -22,6 +22,7 @@

import javax.xml.namespace.QName;

import com.evolveum.midpoint.web.session.SessionStorage;
import org.apache.commons.lang.StringUtils;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
Expand Down Expand Up @@ -144,17 +145,19 @@ public abstract class ResourceContentPanel extends Panel {

private PageBase pageBase;
private ShadowKindType kind;
private String searchMode;
private String intent;
private QName objectClass;
private SelectableBeanObjectDataProvider<ShadowType> provider;

IModel<PrismObject<ResourceType>> resourceModel;

public ResourceContentPanel(String id, IModel<PrismObject<ResourceType>> resourceModel, QName objectClass,
ShadowKindType kind, String intent, PageBase pageBase) {
ShadowKindType kind, String intent, String searchMode, PageBase pageBase) {
super(id);
this.pageBase = pageBase;
this.kind = kind;
this.searchMode = searchMode;
this.resourceModel = resourceModel;
this.intent = intent;
this.objectClass = objectClass;
Expand Down Expand Up @@ -208,18 +211,36 @@ private TableId getTableId() {
return TableId.PAGE_RESOURCE_OBJECT_CLASS_PANEL;
}

switch (kind) {
case ACCOUNT:
return TableId.PAGE_RESOURCE_ACCOUNTS_PANEL;
case GENERIC:
return TableId.PAGE_RESOURCE_GENERIC_PANEL;
case ENTITLEMENT:
return TableId.PAGE_RESOURCE_ENTITLEMENT_PANEL;

default:
return TableId.PAGE_RESOURCE_OBJECT_CLASS_PANEL;
}

if (searchMode == null) {
searchMode = SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT;
}

if (searchMode.equals(SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT)) {
switch (kind) {
case ACCOUNT:
return TableId.PAGE_RESOURCE_ACCOUNTS_PANEL_REPOSITORY_MODE;
case GENERIC:
return TableId.PAGE_RESOURCE_GENERIC_PANEL_REPOSITORY_MODE;
case ENTITLEMENT:
return TableId.PAGE_RESOURCE_ENTITLEMENT_PANEL_REPOSITORY_MODE;

default:
return TableId.PAGE_RESOURCE_OBJECT_CLASS_PANEL;
}
} else if (searchMode.equals(SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT)){
switch (kind) {
case ACCOUNT:
return TableId.PAGE_RESOURCE_ACCOUNTS_PANEL_RESOURCE_MODE;
case GENERIC:
return TableId.PAGE_RESOURCE_GENERIC_PANEL_RESOURCE_MODE;
case ENTITLEMENT:
return TableId.PAGE_RESOURCE_ENTITLEMENT_PANEL_RESOURCE_MODE;

default:
return TableId.PAGE_RESOURCE_OBJECT_CLASS_PANEL;
}
}
return TableId.PAGE_RESOURCE_OBJECT_CLASS_PANEL;
}

private void initLayout() {
Expand Down
Expand Up @@ -34,8 +34,8 @@ public class ResourceContentRepositoryPanel extends ResourceContentPanel {
private static final long serialVersionUID = 1L;

public ResourceContentRepositoryPanel(String id, IModel<PrismObject<ResourceType>> resourceModel,
QName objectClass, ShadowKindType kind, String intent, PageBase pageBase) {
super(id, resourceModel, objectClass, kind, intent, pageBase);
QName objectClass, ShadowKindType kind, String intent, String searchMode, PageBase pageBase) {
super(id, resourceModel, objectClass, kind, intent, searchMode, pageBase);
}

@Override
Expand Down
Expand Up @@ -47,8 +47,8 @@ public class ResourceContentResourcePanel extends ResourceContentPanel {
private static final String DOT_CLASS = ResourceContentResourcePanel.class.getName() + ".";

public ResourceContentResourcePanel(String id, IModel<PrismObject<ResourceType>> resourceModel,
QName objectClass, ShadowKindType kind, String intent, PageBase pageBase) {
super(id, resourceModel, objectClass, kind, intent, pageBase);
QName objectClass, ShadowKindType kind, String intent, String searchMode, PageBase pageBase) {
super(id, resourceModel, objectClass, kind, intent, searchMode, pageBase);
}

@Override
Expand Down
Expand Up @@ -22,6 +22,7 @@

import javax.xml.namespace.QName;

import com.evolveum.midpoint.web.session.SessionStorage;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
Expand Down Expand Up @@ -79,6 +80,7 @@ enum Operation {
private ShadowKindType kind;

private boolean useObjectClass;
private boolean isRepoSearch = true;

private IModel<ResourceContentSearchDto> resourceContentSearch;

Expand All @@ -101,7 +103,9 @@ private IModel<ResourceContentSearchDto> createContentSearchModel(final ShadowKi

@Override
protected ResourceContentSearchDto load() {
return getContentStorage(kind).getContentSearch();
isRepoSearch = !getContentStorage(kind, SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT).getResourceSearch();
return getContentStorage(kind, isRepoSearch ? SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT :
SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT).getContentSearch();

}

Expand All @@ -111,11 +115,12 @@ protected ResourceContentSearchDto load() {

private void updateResourceContentSearch() {
ResourceContentSearchDto searchDto = resourceContentSearch.getObject();
getContentStorage(kind).setContentSearch(searchDto);
getContentStorage(kind, isRepoSearch ? SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT :
SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT).setContentSearch(searchDto);
}

private ResourceContentStorage getContentStorage(ShadowKindType kind) {
return parentPage.getSessionStorage().getResourceContentStorage(kind);
private ResourceContentStorage getContentStorage(ShadowKindType kind, String searchMode) {
return parentPage.getSessionStorage().getResourceContentStorage(kind, searchMode);
}

private void initLayout(final IModel<PrismObject<ResourceType>> model, final PageBase parentPage) {
Expand Down Expand Up @@ -228,7 +233,11 @@ public boolean isVisible() {

@Override
public void onClick(AjaxRequestTarget target) {
resourceContentSearch.getObject().setResourceSearch(Boolean.FALSE);
isRepoSearch = true;
getContentStorage(kind, SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT).setResourceSearch(Boolean.FALSE);
getContentStorage(kind, SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT).setResourceSearch(Boolean.FALSE);

resourceContentSearch.getObject().setResourceSearch(Boolean.FALSE);
updateResourceContentSearch();
mainForm.addOrReplace(initRepoContent(model));
target.add(getParent().addOrReplace(mainForm));
Expand All @@ -252,8 +261,11 @@ protected void onBeforeRender() {

@Override
public void onClick(AjaxRequestTarget target) {
updateResourceContentSearch();
resourceContentSearch.getObject().setResourceSearch(Boolean.TRUE);
isRepoSearch = false;
getContentStorage(kind, SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT).setResourceSearch(Boolean.TRUE);
getContentStorage(kind, SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT).setResourceSearch(Boolean.TRUE);
updateResourceContentSearch();
resourceContentSearch.getObject().setResourceSearch(Boolean.TRUE);
mainForm.addOrReplace(initResourceContent(model));
target.add(getParent().addOrReplace(mainForm));
target.add(this.add(AttributeModifier.append("class", " active")));
Expand Down Expand Up @@ -299,16 +311,20 @@ private ResourceContentPanel initTable(IModel<PrismObject<ResourceType>> model)
}

private ResourceContentResourcePanel initResourceContent(IModel<PrismObject<ResourceType>> model) {
String searchMode = isRepoSearch ? SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT :
SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT;
ResourceContentResourcePanel resourceContent = new ResourceContentResourcePanel(ID_TABLE, model,
getObjectClass(), getKind(), getIntent(), parentPage);
getObjectClass(), getKind(), getIntent(), searchMode, parentPage);
resourceContent.setOutputMarkupId(true);
return resourceContent;

}

private ResourceContentRepositoryPanel initRepoContent(IModel<PrismObject<ResourceType>> model) {
String searchMode = isRepoSearch ? SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT :
SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT;
ResourceContentRepositoryPanel repositoryContent = new ResourceContentRepositoryPanel(ID_TABLE, model,
getObjectClass(), getKind(), getIntent(), parentPage);
getObjectClass(), getKind(), getIntent(), searchMode, parentPage);
repositoryContent.setOutputMarkupId(true);
return repositoryContent;
}
Expand Down
Expand Up @@ -25,6 +25,7 @@ public class ResourceContentStorage implements PageStorage {
private static final long serialVersionUID = 1L;

private ResourceContentSearchDto contentSearch;
private Boolean resourceSearch = Boolean.FALSE;

private Search attributeSearch;
private ObjectPaging paging;
Expand All @@ -45,7 +46,15 @@ public void setSearch(Search search) {
this.attributeSearch = search;
}

@Override
public Boolean getResourceSearch() {
return resourceSearch;
}

public void setResourceSearch(Boolean resourceSearch) {
this.resourceSearch = resourceSearch;
}

@Override
public void setPaging(ObjectPaging paging) {
this.paging = paging;

Expand Down Expand Up @@ -77,6 +86,7 @@ public String debugDump(int indent) {
StringBuilder sb = new StringBuilder();
DebugUtil.indentDebugDump(sb, indent);
sb.append("ResourceContentStorage\n");
DebugUtil.debugDumpWithLabelLn(sb, "resourceSearch", resourceSearch, indent + 1);
DebugUtil.debugDumpWithLabelLn(sb, "contentSearch", contentSearch, indent+1);
DebugUtil.debugDumpWithLabelLn(sb, "attributeSearch", attributeSearch, indent+1);
DebugUtil.debugDumpWithLabelLn(sb, "paging", paging, indent+1);
Expand Down
Expand Up @@ -49,7 +49,9 @@ public class SessionStorage implements Serializable, DebugDumpable {
public static final String KEY_RESOURCE_ENTITLEMENT_CONTENT = "resourceEntitlementContent";
public static final String KEY_RESOURCE_GENERIC_CONTENT = "resourceGenericContent";
public static final String KEY_RESOURCE_OBJECT_CLASS_CONTENT = "resourceObjectClassContent";

public static final String KEY_RESOURCE_PAGE_RESOURCE_CONTENT = "Resource";
public static final String KEY_RESOURCE_PAGE_REPOSITORY_CONTENT = "Repository";

private static final String KEY_TASKS = "tasks";

/**
Expand Down Expand Up @@ -111,29 +113,29 @@ public RoleMembersStorage getRoleMembers() {
return (RoleMembersStorage)pageStorageMap.get(KEY_ROLE_MEMBERS);
}

public ResourceContentStorage getResourceContentStorage(ShadowKindType kind) {
String key = getContentStorageKey(kind);
public ResourceContentStorage getResourceContentStorage(ShadowKindType kind, String searchMode) {
String key = getContentStorageKey(kind, searchMode);
if (pageStorageMap.get(key) == null) {
pageStorageMap.put(key, new ResourceContentStorage(kind));
}
return (ResourceContentStorage)pageStorageMap.get(key);

}

private String getContentStorageKey(ShadowKindType kind) {
private String getContentStorageKey(ShadowKindType kind, String searchMode) {
if (kind == null) {
return KEY_RESOURCE_OBJECT_CLASS_CONTENT;
}

switch (kind) {
case ACCOUNT:
return KEY_RESOURCE_ACCOUNT_CONTENT;
return KEY_RESOURCE_ACCOUNT_CONTENT + searchMode;

case ENTITLEMENT:
return KEY_RESOURCE_ENTITLEMENT_CONTENT;
return KEY_RESOURCE_ENTITLEMENT_CONTENT + searchMode;

case GENERIC:
return KEY_RESOURCE_GENERIC_CONTENT;
return KEY_RESOURCE_GENERIC_CONTENT + searchMode;
default:
return KEY_RESOURCE_OBJECT_CLASS_CONTENT;

Expand Down Expand Up @@ -255,4 +257,14 @@ public void dumpSizeEstimates(StringBuilder sb, int indent) {
}

}

public void clearResourceContentStorage(){
pageStorageMap.remove(KEY_RESOURCE_ACCOUNT_CONTENT + KEY_RESOURCE_PAGE_REPOSITORY_CONTENT);
pageStorageMap.remove(KEY_RESOURCE_ACCOUNT_CONTENT + KEY_RESOURCE_PAGE_RESOURCE_CONTENT);
pageStorageMap.remove(KEY_RESOURCE_ENTITLEMENT_CONTENT + KEY_RESOURCE_PAGE_REPOSITORY_CONTENT);
pageStorageMap.remove(KEY_RESOURCE_ENTITLEMENT_CONTENT + KEY_RESOURCE_PAGE_RESOURCE_CONTENT);
pageStorageMap.remove(KEY_RESOURCE_GENERIC_CONTENT + KEY_RESOURCE_PAGE_REPOSITORY_CONTENT);
pageStorageMap.remove(KEY_RESOURCE_GENERIC_CONTENT + KEY_RESOURCE_PAGE_RESOURCE_CONTENT);
pageStorageMap.remove(KEY_RESOURCE_OBJECT_CLASS_CONTENT);
}
}
Expand Up @@ -56,9 +56,12 @@ public enum TableId {
PAGE_RESOURCE_PANEL,
PAGE_RESOURCES_PANEL,
PAGE_RESOURCE_TASKS_PANEL,
PAGE_RESOURCE_ACCOUNTS_PANEL,
PAGE_RESOURCE_ENTITLEMENT_PANEL,
PAGE_RESOURCE_GENERIC_PANEL,
PAGE_RESOURCE_ACCOUNTS_PANEL_REPOSITORY_MODE,
PAGE_RESOURCE_ACCOUNTS_PANEL_RESOURCE_MODE,
PAGE_RESOURCE_ENTITLEMENT_PANEL_REPOSITORY_MODE,
PAGE_RESOURCE_ENTITLEMENT_PANEL_RESOURCE_MODE,
PAGE_RESOURCE_GENERIC_PANEL_REPOSITORY_MODE,
PAGE_RESOURCE_GENERIC_PANEL_RESOURCE_MODE,
PAGE_RESOURCE_OBJECT_CLASS_PANEL,
PAGE_TASKS_PANEL,
PAGE_TASKS_NODES_PANEL,
Expand Down

0 comments on commit 0145268

Please sign in to comment.