Skip to content

Commit

Permalink
Clean up Item interface (part 1)
Browse files Browse the repository at this point in the history
Attempted to optimize # of object creation in item.getPath()
and delta.getPath() methods. Not sure if it helps.

Unified item.getValue() method.
Removed getPreviousValue/getNextValue methods.
Removed getValue(index) method.
Removed unused AbstractDelegatedXXX classes.
  • Loading branch information
mederly committed Dec 11, 2018
1 parent 58b27d2 commit 7eaa178
Show file tree
Hide file tree
Showing 70 changed files with 412 additions and 3,263 deletions.
Expand Up @@ -342,7 +342,7 @@ private IModel<String> getItemValuesString(Item<?, ?> item, PrismObject<LookupTa
return String.valueOf(((PrismPropertyValue<?>) itemValue).getValue());
} else {
String lookupTableKey = ((PrismPropertyValue<?>) itemValue).getValue().toString();
LookupTableType lookupTableObject = lookupTable.getValue().asObjectable();
LookupTableType lookupTableObject = lookupTable.asObjectable();
String rowLabel = "";
for (LookupTableRowType lookupTableRow : lookupTableObject.getRow()){
if (lookupTableRow.getKey().equals(lookupTableKey)){
Expand Down
Expand Up @@ -72,7 +72,6 @@
import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem;
import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction;
import com.evolveum.midpoint.web.component.prism.*;
import com.evolveum.midpoint.web.page.admin.reports.dto.ReportDeleteDialogDto;
import com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType;
Expand Down
Expand Up @@ -202,7 +202,7 @@ private GuiFlexibleLabelType getLabelConfiguration(QName configurationPropertyNa
if (subContainer == null) {
return null;
}
return subContainer.getValue().asContainerable();
return subContainer.getRealValue();
}

protected String getTagBoxCssClass() {
Expand Down
Expand Up @@ -81,7 +81,7 @@ private void initModels() {
resourceModel = new LoadableDetachableModel<PrismObject<ResourceType>>() {
@Override
protected PrismObject<ResourceType> load() {
ConstructionType construction = getModelObject().getItem().getValue().asContainerable();
ConstructionType construction = getModelObject().getItem().getRealValue();
ObjectReferenceType resourceRef = construction.getResourceRef();
Task loadResourceTask = getPageBase().createSimpleTask(OPERATION_LOAD_RESOURCE);
OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCE);
Expand All @@ -98,7 +98,7 @@ protected PrismObject<ResourceType> load() {
refinedAssociationDefinitionsModel = new LoadableDetachableModel<List<RefinedAssociationDefinition>>() {
@Override
protected List<RefinedAssociationDefinition> load() {
ConstructionType construction = getModelObject().getItem().getValue().asContainerable();
ConstructionType construction = getModelObject().getItem().getRealValue();
if (construction == null){
return new ArrayList<>();
}
Expand Down
Expand Up @@ -17,7 +17,6 @@
package com.evolveum.midpoint.web.component.model.delta;

import com.evolveum.midpoint.prism.Item;
import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.PrismContainerValue;

import java.io.Serializable;
Expand All @@ -44,8 +43,4 @@ public ContainerValueDto(PrismContainerValue value) {

Collections.sort(itemList);
}

public ContainerValueDto(PrismContainer container) {
this(container.getValue());
}
}
Expand Up @@ -41,7 +41,7 @@ public class DeltaDto implements Serializable {
private ContainerValueDto objectToAdd;
private boolean add;

public DeltaDto(ObjectDelta delta) {
public DeltaDto(ObjectDelta<?> delta) {

changeType = "" + delta.getChangeType();
oid = delta.getOid();
Expand Down
Expand Up @@ -165,7 +165,7 @@ public <C extends Containerable> ShadowAssociationWrapper createAssociationWrapp
}
if (resourceAssociation.getRef().getItemPath().asSingleName().equals(refinedAssocationDefinition.getName())){
itemPath = associationValue.getPath();
MappingType outbound = ((ResourceObjectAssociationType)association.getValue().asContainerable()).getOutbound();
MappingType outbound = ((ResourceObjectAssociationType)association.getRealValue()).getOutbound();
if (outbound == null){
continue;
}
Expand Down
Expand Up @@ -691,8 +691,7 @@ public DeltaDto getObject() {
ObjectDeltaType objectDeltaType = (ObjectDeltaType) ((PrismPropertyValue) getModel().getObject()
.getValue()).getValue();
try {
ObjectDelta delta = DeltaConvertor.createObjectDelta(objectDeltaType, prismContext);
return new DeltaDto(delta);
return new DeltaDto(DeltaConvertor.createObjectDelta(objectDeltaType, prismContext));
} catch (SchemaException e) {
throw new IllegalStateException("Couldn't convert object delta: " + objectDeltaType);
}
Expand Down
Expand Up @@ -305,7 +305,7 @@ public I getUpdatedItem(PrismContext prismContext) throws SchemaException {
valueWrapper.normalize(prismContext);
if (ValueStatus.DELETED.equals(valueWrapper.getStatus())) {
updatedItem.remove(valueWrapper.getValue());
} else if (!updatedItem.hasValueIgnoringMetadata(valueWrapper.getValue())) {
} else if (!updatedItem.containsEquivalentValue(valueWrapper.getValue())) {
PrismValue cloned = ObjectWrapper.clone(valueWrapper.getValue());
if (cloned != null) {
updatedItem.add(cloned);
Expand Down
Expand Up @@ -877,7 +877,7 @@ protected AssignmentInfoDto createDelegableAssignmentsPreviewDto(AssignmentType
PageAdminFocus.this, task, result);
Boolean isDelegable = false;
if (targetObject != null) {
isDelegable = targetObject.getRealValue().isDelegable();
isDelegable = targetObject.asObjectable().isDelegable();
}
if (Boolean.TRUE.equals(isDelegable)) {
return createAssignmentsPreviewDto(targetObject, true, assignment, task, result);
Expand Down
Expand Up @@ -16,12 +16,13 @@
package com.evolveum.midpoint.web.page.admin.orgs;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.web.component.util.SelectableBean;
import com.evolveum.midpoint.web.session.UsersStorage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.wicket.ajax.AjaxEventBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;
Expand All @@ -46,7 +47,6 @@
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.AjaxTabbedPanel;
import com.evolveum.midpoint.web.component.TabbedPanel;
import com.evolveum.midpoint.web.session.SessionStorage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;

public abstract class AbstractOrgTabPanel extends BasePanel {
Expand Down Expand Up @@ -182,8 +182,7 @@ private List<PrismObject<OrgType>> loadOrgRoots() {
}
list = getPageBase().getModelService().searchObjects(OrgType.class, query, null, task, result);
// Sort org roots by displayOrder, if not set push the org to the end
list.sort((o1, o2) -> (o1.getRealValue().getDisplayOrder() == null ? Integer.MAX_VALUE : o1.getRealValue().getDisplayOrder())
- (o2.getRealValue().getDisplayOrder() == null ? Integer.MAX_VALUE : o2.getRealValue().getDisplayOrder()));
list.sort(Comparator.comparingInt(o -> (ObjectUtils.defaultIfNull(o.getRealValue().getDisplayOrder(), Integer.MAX_VALUE))));

if (list.isEmpty() && isWarnMessageVisible()) {
warn(getString("PageOrgTree.message.noOrgStructDefined"));
Expand Down
Expand Up @@ -77,7 +77,7 @@ protected ObjectFilter getUsersViewFilter(){
if (collectionObject == null){
return null;
}
ObjectCollectionType collectionValue = collectionObject.getValue().asObjectable();
ObjectCollectionType collectionValue = collectionObject.asObjectable();
if (!QNameUtil.match(collectionValue.getType(), UserType.COMPLEX_TYPE)){
return null;
}
Expand Down
Expand Up @@ -21,7 +21,6 @@
import java.util.*;

import com.evolveum.midpoint.gui.api.PredefinedDashboardWidgetId;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.query.builder.S_FilterEntryOrEmpty;
import com.evolveum.midpoint.web.application.Url;
import com.evolveum.midpoint.wf.util.QueryUtils;
Expand Down Expand Up @@ -563,8 +562,8 @@ private AssignmentItemDto createAssignmentItem(PrismObject<UserType> user,
PrismContainer construction = assignment.findContainer(AssignmentType.F_CONSTRUCTION);
String name = null;
String description = "";
if (construction.getValue().asContainerable() != null && !construction.isEmpty()) {
ConstructionType constr = (ConstructionType) construction.getValue().asContainerable();
if (construction.getRealValue() != null && !construction.isEmpty()) {
ConstructionType constr = (ConstructionType) construction.getRealValue();

if (constr.getResourceRef() != null) {
ObjectReferenceType resourceRef = constr.getResourceRef();
Expand Down

0 comments on commit 7eaa178

Please sign in to comment.