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 May 29, 2017
2 parents 05bb823 + 0dc3284 commit 9ffe5d8
Show file tree
Hide file tree
Showing 14 changed files with 349 additions and 218 deletions.
Expand Up @@ -59,6 +59,17 @@ public void setParentPath(ItemPathDto parentPath) {
}

public ItemPath toItemPath() {
if (parentPath == null) {
if (itemDef == null) {
return path;
}
this.path = new ItemPath(itemDef.getName());
} else {
if (itemDef == null) {
return parentPath.toItemPath();
}
this.path = parentPath.toItemPath().append(itemDef.getName());
}
return path;

}
Expand Down
Expand Up @@ -38,13 +38,11 @@ public class ItemPathPanel extends BasePanel<ItemPathDto> {
private static final String ID_PLUS = "plus";
private static final String ID_MINUS = "minus";

Map<QName, Collection<ItemDefinition<?>>> schemaDefinitionsMap = null;

public ItemPathPanel(String id, IModel<ItemPathDto> model, PageBase parent) {
super(id, model);

setParent(parent);
initNamspaceDefinitionMap();


initLayout();

Expand All @@ -56,7 +54,7 @@ public ItemPathPanel(String id, ItemPathDto model, PageBase parent) {
}

private void initLayout() {
final ItemPathSegmentPanel itemDefPanel = new ItemPathSegmentPanel(ID_DEFINITION,
ItemPathSegmentPanel itemDefPanel = new ItemPathSegmentPanel(ID_DEFINITION,
new AbstractReadOnlyModel<ItemPathDto>() {

private static final long serialVersionUID = 1L;
Expand All @@ -69,7 +67,7 @@ public ItemPathDto getObject() {

@Override
protected Map<QName, Collection<ItemDefinition<?>>> getSchemaDefinitionMap() {
return schemaDefinitionsMap;
return initNamspaceDefinitionMap();
}
};
itemDefPanel.setOutputMarkupId(true);
Expand All @@ -90,7 +88,7 @@ public void onClick(AjaxRequestTarget target) {

@Override
public boolean isVisible() {
if (getModelObject().getParentPath() == null) {
if (getModelObject().getParentPath() == null || getModelObject().getParentPath().toItemPath() == null) {
return true;
}
return (getModelObject().getParentPath().getItemDef() instanceof PrismContainerDefinition);
Expand All @@ -104,7 +102,14 @@ public boolean isVisible() {

@Override
public void onClick(AjaxRequestTarget target) {
refreshItemPathPanel(ItemPathPanel.this.getModelObject().getParentPath(), false, target);
ItemPathDto path = ItemPathPanel.this.getModelObject();
// ItemPathDto parent = null;
// if (path.getItemDef() == null){
// parent = path.getParentPath();
// } else {
// parent = path;
// }
refreshItemPathPanel(path, false, target);

}
};
Expand All @@ -113,7 +118,7 @@ public void onClick(AjaxRequestTarget target) {

@Override
public boolean isVisible() {
return getModelObject().getParentPath() != null;
return getModelObject().getParentPath() != null && getModelObject().getParentPath().toItemPath() != null;
}
});
minusButton.setOutputMarkupId(true);
Expand All @@ -128,7 +133,7 @@ public boolean isVisible() {

@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(itemDefPanel);
refreshItemPath(ItemPathPanel.this.getModelObject(), target);

}
});
Expand All @@ -139,7 +144,7 @@ protected void onUpdate(AjaxRequestTarget target) {

@Override
public boolean isVisible() {
return getModelObject().getParentPath() == null;
return getModelObject().getParentPath() == null || getModelObject().getParentPath().toItemPath() == null;
}
});
namespacePanel.setOutputMarkupId(true);
Expand All @@ -153,7 +158,19 @@ private void refreshItemPathPanel(ItemPathDto itemPathDto, boolean isAdd, AjaxRe
}

if (!isAdd) {
itemPathDto = itemPathDto.getParentPath();
ItemPathDto newItem = itemPathDto;
ItemPathDto currentItem = itemPathDto.getParentPath();
ItemPathDto parentPath = currentItem.getParentPath();
ItemPathDto resultingItem = null;
if (parentPath == null) {
parentPath = new ItemPathDto();
parentPath.setObjectType(currentItem.getObjectType());
resultingItem = parentPath;
} else {
resultingItem = parentPath;
}
newItem.setParentPath(resultingItem);
itemPathDto = resultingItem;
}
// pathSegmentPanel.refreshModel(itemPathDto);
this.getModel().setObject(itemPathDto);
Expand All @@ -162,9 +179,15 @@ private void refreshItemPathPanel(ItemPathDto itemPathDto, boolean isAdd, AjaxRe
// target.add(pathSegmentPanel);

}

private void refreshItemPath(ItemPathDto itemPathDto, AjaxRequestTarget target) {

this.getModel().setObject(itemPathDto);
target.add(this);
}

private void initNamspaceDefinitionMap() {
schemaDefinitionsMap = new HashMap<>();
private Map<QName, Collection<ItemDefinition<?>>> initNamspaceDefinitionMap() {
Map<QName, Collection<ItemDefinition<?>>> schemaDefinitionsMap = new HashMap<>();
if (getModelObject().getObjectType() != null) {
Class clazz = WebComponentUtil.qnameToClass(getPageBase().getPrismContext(),
getModelObject().getObjectType());
Expand All @@ -182,7 +205,7 @@ private void initNamspaceDefinitionMap() {
schemaDefinitionsMap.put(getModelObject().getObjectType(), itemDefs);
}
}
// }
return schemaDefinitionsMap;
}

}
Expand Up @@ -52,6 +52,10 @@ public String getObject() {
return null;
}

if (getModelObject().getParentPath().toItemPath() == null) {
return null;
}

return getString("ItemPathSegmentPanel.itemToSearch", getModelObject().getParentPath().toItemPath().toString());
}
});
Expand All @@ -61,7 +65,7 @@ public String getObject() {

@Override
public boolean isVisible() {
return getModelObject().getParentPath() != null;
return getModelObject().getParentPath() != null && getModelObject().getParentPath().toItemPath() != null;
}
});
label.setOutputMarkupId(true);
Expand Down
Expand Up @@ -27,6 +27,7 @@
import com.evolveum.midpoint.common.SystemConfigurationHolder;
import com.evolveum.midpoint.gui.api.SubscriptionType;
import com.evolveum.midpoint.model.api.*;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.web.component.menu.*;
import com.evolveum.midpoint.web.page.admin.configuration.*;
import com.evolveum.midpoint.web.page.admin.reports.*;
Expand Down Expand Up @@ -96,8 +97,6 @@
import com.evolveum.midpoint.task.api.TaskManager;
import com.evolveum.midpoint.util.Holder;
import com.evolveum.midpoint.util.Producer;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SecurityViolationException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
Expand Down Expand Up @@ -164,6 +163,7 @@ public abstract class PageBase extends WebPage implements ModelServiceLocator {
private static final String DOT_CLASS = PageBase.class.getName() + ".";
private static final String OPERATION_LOAD_USER = DOT_CLASS + "loadUser";
private static final String OPERATION_LOAD_WORK_ITEM_COUNT = DOT_CLASS + "loadWorkItemCount";
private static final String OPERATION_LOAD_CERT_WORK_ITEM_COUNT = DOT_CLASS + "loadCertificationWorkItemCount";

private static final String ID_TITLE = "title";
private static final String ID_MAIN_HEADER = "mainHeader";
Expand Down Expand Up @@ -264,6 +264,7 @@ public abstract class PageBase extends WebPage implements ModelServiceLocator {
private boolean initialized = false;

private LoadableModel<Integer> workItemCountModel;
private LoadableModel<Integer> certWorkItemCountModel;
private LoadableModel<DeploymentInformationType> deploymentInfoModel;

public PageBase(PageParameters parameters) {
Expand Down Expand Up @@ -315,6 +316,26 @@ protected Integer load() {
}
}
};
certWorkItemCountModel = new LoadableModel<Integer>() {
private static final long serialVersionUID = 1L;

@Override
protected Integer load() {
try {
AccessCertificationService acs = getCertificationService();
Task task = createSimpleTask(OPERATION_LOAD_CERT_WORK_ITEM_COUNT);
OperationResult result = task.getResult();
List<AccessCertificationWorkItemType> certWorkItems = acs.searchOpenWorkItems(new ObjectQuery(),
true, null, task, result);

return certWorkItems == null ? 0 : certWorkItems.size();
} catch (SchemaException|SecurityViolationException|ObjectNotFoundException
|ConfigurationException|CommunicationException e) {
LoggingUtils.logExceptionAsWarning(LOGGER, "Couldn't load certification work item count", e);
return null;
}
}
};
deploymentInfoModel = new LoadableModel<DeploymentInformationType>() {
private static final long serialVersionUID = 1L;

Expand All @@ -331,6 +352,12 @@ public void resetWorkItemCountModel() {
}
}

public void resetCertWorkItemCountModel() {
if (certWorkItemCountModel != null) {
certWorkItemCountModel.reset();
}
}

protected void createBreadcrumb() {
BreadcrumbPageClass bc = new BreadcrumbPageClass(new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -1261,7 +1288,19 @@ private MainMenuItem createReportsItems() {
private MainMenuItem createCertificationItems() {

MainMenuItem item = new MainMenuItem("fa fa-certificate",
createStringResource("PageAdmin.menu.top.certification"), null);
createStringResource("PageAdmin.menu.top.certification"), null){
private static final long serialVersionUID = 1L;

@Override
public String getBubbleLabel() {
Integer certWorkItemCount = certWorkItemCountModel.getObject();
if (certWorkItemCount == null || certWorkItemCount == 0) {
return null;
} else {
return certWorkItemCount.toString();
}
}
};

List<MenuItem> submenu = item.getItems();

Expand Down
Expand Up @@ -409,11 +409,21 @@ public static Integer safeLongToInteger(Long l) {

// TODO: move to schema component
public static List<QName> createObjectTypeList() {

List<QName> types = new ArrayList<>(ObjectTypes.values().length);
for (ObjectTypes t : ObjectTypes.values()) {
types.add(t.getTypeQName());
}
return types;

return types.stream().sorted((type1, type2) -> {
Validate.notNull(type1);
Validate.notNull(type2);

return String.CASE_INSENSITIVE_ORDER.compare(QNameUtil.qNameToUri(type1), QNameUtil.qNameToUri(type2));


}).collect(Collectors.toList());

}

// TODO: move to schema component
Expand Down
Expand Up @@ -24,12 +24,7 @@
<select class="form-control input-sm col-md-2" wicket:id="viewTypeSelect"/>
</div>

<div class="col-md-2" wicket:id="targetUserContainer">
<a wicket:id="targetUserButton" class="btn btn-sm btn-default">
<span wicket:id="targetUserLabel"/>
<i wicket:id="deleteTargetUserButton" class="fa fa-times-circle fa-lg text-danger" style="margin-left: 10px;"/>
</a>
</div>
<div class="col-md-2" wicket:id="targetUserPanel" />

<form class="col-md-7 search-form" wicket:id="searchForm">
<div wicket:id="search"/>
Expand Down

0 comments on commit 9ffe5d8

Please sign in to comment.