Skip to content

Commit

Permalink
Merge commit 'f55e07d65ec83a93ae301653aabc775d7383d92d' into feature/…
Browse files Browse the repository at this point in the history
…performance-stable
  • Loading branch information
1azyman committed Apr 12, 2018
2 parents 2377d62 + f55e07d commit cecc6d3
Show file tree
Hide file tree
Showing 152 changed files with 2,287 additions and 675 deletions.
2 changes: 1 addition & 1 deletion build-system/pom.xml
Expand Up @@ -691,7 +691,7 @@
<dependency>
<groupId>com.evolveum.polygon</groupId>
<artifactId>connector-csv</artifactId>
<version>2.1</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>com.evolveum.polygon</groupId>
Expand Down
Expand Up @@ -57,6 +57,7 @@
import com.evolveum.midpoint.web.component.util.SelectableBean;
import com.evolveum.midpoint.web.session.PageStorage;
import com.evolveum.midpoint.web.session.UserProfileStorage.TableId;
import org.jetbrains.annotations.NotNull;

/**
* @author katkav
Expand Down Expand Up @@ -361,6 +362,7 @@ public SelectableBean<O> createDataObjectWrapper(O obj) {
return bean;
}

@NotNull
@Override
protected List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam) {
List<ObjectOrdering> customOrdering = createCustomOrdering(sortParam);
Expand Down
Expand Up @@ -256,7 +256,7 @@ protected void onUpdate(AjaxRequestTarget target) {
}
}

private class PasswordModel implements IModel<String> {
private static class PasswordModel implements IModel<String> {

IModel<ProtectedStringType> psModel;

Expand Down
Expand Up @@ -416,6 +416,18 @@ public static void safeResultCleanup(OperationResult result, Trace logger) {
}
}

public static GuiObjectListType getDefaultGuiObjectListType(PageBase pageBase) {
AdminGuiConfigurationType config = pageBase.getPrincipal().getAdminGuiConfiguration();
if (config == null) {
return null;
}
GuiObjectListsType lists = config.getObjectLists();
if (lists == null) {
return null;
}
return lists.getDefault();
}

public enum Channel {
// TODO: move this to schema component
LIVE_SYNC(SchemaConstants.CHANGE_CHANNEL_LIVE_SYNC_URI),
Expand Down
Expand Up @@ -713,8 +713,7 @@ public static void addIncludeOptionsForExportOrView(Collection<SelectorOptions<G
}
}

public static boolean isEnableExperimentalFeature(ModelServiceLocator pageBase) {
Task task = pageBase.createSimpleTask("Load admin gui config");
public static boolean isEnableExperimentalFeature(Task task, ModelServiceLocator pageBase) {
OperationResult result = task.getResult();

ModelInteractionService mInteractionService = pageBase.getModelInteractionService();
Expand All @@ -737,6 +736,12 @@ public static boolean isEnableExperimentalFeature(ModelServiceLocator pageBase)
return BooleanUtils.isTrue(adminGuiConfig.isEnableExperimentalFeatures());

}

public static boolean isEnableExperimentalFeature(ModelServiceLocator pageBase) {
Task task = pageBase.createSimpleTask("Load admin gui config");
return isEnableExperimentalFeature(task, pageBase);

}

public static AccessCertificationConfigurationType getCertificationConfiguration(PageBase pageBase) {
OperationResult result = new OperationResult(WebModelServiceUtils.class.getName() + ".getCertificationConfiguration");
Expand Down
Expand Up @@ -71,11 +71,11 @@ private void appendOptions(StringBuilder sb) {
}

sb.append('{');
Iterator<String> keys = map.keySet().iterator();
Iterator<Map.Entry<String, String>> keys = map.entrySet().iterator();
while (keys.hasNext()) {
String key = keys.next();
sb.append(key).append(":");
sb.append('\'').append(map.get(key)).append('\'');
final Map.Entry<String, String> key = keys.next();
sb.append(key.getKey()).append(":");
sb.append('\'').append(key.getValue()).append('\'');
if (keys.hasNext()) {
sb.append(",\n");
}
Expand Down
Expand Up @@ -51,6 +51,7 @@
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.query.builder.QueryBuilder;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.form.Form;
import com.evolveum.midpoint.web.component.input.DropDownChoicePanel;
Expand Down Expand Up @@ -206,7 +207,6 @@ protected <T extends ObjectType> void addSelectedAssignmentsPerformed(AjaxReques
constructionType.setResourceRef(ref);
constructionType.setKind(kind);
constructionType.setIntent(intent);
initAssociationContainer(constructionType);
assignmentType.setConstruction(constructionType);
} else {
assignmentType.setTargetRef(ref);
Expand All @@ -218,9 +218,6 @@ protected <T extends ObjectType> void addSelectedAssignmentsPerformed(AjaxReques
reloadSavePreviewButtons(target);
}

protected void initAssociationContainer(ConstructionType constructionType){
}

protected List<IColumn<ContainerValueWrapper<AssignmentType>, String>> initColumns() {
List<IColumn<ContainerValueWrapper<AssignmentType>, String>> columns = new ArrayList<>();

Expand Down
Expand Up @@ -27,6 +27,7 @@
import com.evolveum.midpoint.prism.query.builder.QueryBuilder;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.data.column.IsolatedCheckBoxPanel;
Expand Down Expand Up @@ -171,13 +172,15 @@ private void onPolicyAddedOrRemoved(PrismObject<AbstractRoleType> assignmentTarg
assignmentsModel.getObject().getValues().remove(assignmentToRemove);
} else {
if (added){
//TODO: not sure if this is correct way of creating new value.. this value is added directly to the origin object... what about deltas??
PrismContainerValue<AssignmentType> newAssignment = assignmentsModel.getObject().getItem().createNewValue();
ObjectReferenceType ref = ObjectTypeUtil.createObjectRef(assignmentTargetObject);
AssignmentType assignmentType = newAssignment.asContainerable();
assignmentType.setTargetRef(ref);
Task task = getPageBase().createSimpleTask("Creating new applicable policy");
ContainerWrapperFactory factory = new ContainerWrapperFactory(getPageBase());
ContainerValueWrapper<AssignmentType> valueWrapper = factory.createContainerValueWrapper(assignmentsModel.getObject(), newAssignment,
assignmentsModel.getObject().getObjectStatus(), ValueStatus.ADDED, assignmentsModel.getObject().getPath());
assignmentsModel.getObject().getObjectStatus(), ValueStatus.ADDED, assignmentsModel.getObject().getPath(), task);
valueWrapper.setShowEmpty(true, false);
assignmentsModel.getObject().getValues().add(valueWrapper);
}
Expand Down
Expand Up @@ -24,6 +24,8 @@
import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.objectdetails.FocusMainPanel;
import com.evolveum.midpoint.web.component.prism.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
Expand All @@ -50,6 +52,7 @@
import com.evolveum.midpoint.prism.query.ObjectPaging;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.AjaxIconButton;
import com.evolveum.midpoint.web.component.data.BoxedTablePanel;
Expand Down Expand Up @@ -84,6 +87,8 @@ public abstract class AssignmentPanel extends BasePanel<ContainerWrapper<Assignm
private final static String ID_DONE_BUTTON = "doneButton";
private final static String ID_CANCEL_BUTTON = "cancelButton";

private static final Trace LOGGER = TraceManager.getTrace(AssignmentPanel.class);

protected boolean assignmentDetailsVisible;
private List<ContainerValueWrapper<AssignmentType>> detailsPanelAssignmentsList = new ArrayList<>();

Expand Down Expand Up @@ -183,7 +188,8 @@ protected List<ContainerValueWrapper<AssignmentType>> searchThroughList() {
};

List<IColumn<ContainerValueWrapper<AssignmentType>, String>> columns = initBasicColumns();
columns.add(new InlineMenuButtonColumn<>(getAssignmentMenuActions(), 2, getPageBase()));
List<InlineMenuItem> menuActionsList = getAssignmentMenuActions();
columns.add(new InlineMenuButtonColumn<>(menuActionsList, menuActionsList.size(), getPageBase()));

BoxedTablePanel<ContainerValueWrapper<AssignmentType>> assignmentTable = new BoxedTablePanel<ContainerValueWrapper<AssignmentType>>(ID_ASSIGNMENTS_TABLE,
assignmentsProvider, columns, getTableId(), getItemsPerPage()) {
Expand Down Expand Up @@ -373,11 +379,30 @@ private List<ContainerValueWrapper<AssignmentType>> getSelectedAssignments() {

private List<InlineMenuItem> getAssignmentMenuActions() {
List<InlineMenuItem> menuItems = new ArrayList<>();
menuItems.add(new InlineMenuItem(createStringResource("PageBase.button.unassign"), new Model<>(true),
new Model<>(true), false, createDeleteColumnAction(), 0, GuiStyleConstants.CLASS_DELETE_MENU_ITEM,
DoubleButtonColumn.BUTTON_COLOR_CLASS.DANGER.toString()));
PrismObject obj = getFocusObject();
boolean isUnassignMenuAdded = false;
try {
boolean isUnassignAuthorized = getParentPage().isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_UNASSIGN_ACTION_URI,
AuthorizationPhaseType.REQUEST, obj,
null, null, null);
if (isUnassignAuthorized) {
menuItems.add(new InlineMenuItem(createStringResource("PageBase.button.unassign"), new Model<>(true),
new Model<>(true), false, createDeleteColumnAction(), 0, GuiStyleConstants.CLASS_DELETE_MENU_ITEM,
DoubleButtonColumn.BUTTON_COLOR_CLASS.DANGER.toString()));
isUnassignMenuAdded = true;
}

} catch (Exception ex){
LOGGER.error("Couldn't check unassign authorization for the object: {}, {}", obj.getName(), ex.getLocalizedMessage());
if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_ASSIGN_ACTION_URI)){
menuItems.add(new InlineMenuItem(createStringResource("PageBase.button.unassign"), new Model<>(true),
new Model<>(true), false, createDeleteColumnAction(), 0, GuiStyleConstants.CLASS_DELETE_MENU_ITEM,
DoubleButtonColumn.BUTTON_COLOR_CLASS.DANGER.toString()));
isUnassignMenuAdded = true;
}
}
menuItems.add(new InlineMenuItem(createStringResource("PageBase.button.edit"), new Model<>(true),
new Model<>(true), false, createEditColumnAction(), 1, GuiStyleConstants.CLASS_EDIT_MENU_ITEM,
new Model<>(true), false, createEditColumnAction(), isUnassignMenuAdded ? 1 : 0, GuiStyleConstants.CLASS_EDIT_MENU_ITEM,
DoubleButtonColumn.BUTTON_COLOR_CLASS.DEFAULT.toString()));
return menuItems;
}
Expand Down Expand Up @@ -459,8 +484,9 @@ protected void deleteAssignmentPerformed(AjaxRequestTarget target, List<Containe

protected ContainerValueWrapper<AssignmentType> createNewAssignmentContainerValueWrapper(PrismContainerValue<AssignmentType> newAssignment) {
ContainerWrapperFactory factory = new ContainerWrapperFactory(getPageBase());
Task task = getPageBase().createSimpleTask("Creating new assignment");
ContainerValueWrapper<AssignmentType> valueWrapper = factory.createContainerValueWrapper(getModelObject(), newAssignment,
getModelObject().getObjectStatus(), ValueStatus.ADDED, getModelObject().getPath());
getModelObject().getObjectStatus(), ValueStatus.ADDED, getModelObject().getPath(), task);
valueWrapper.setShowEmpty(true, false);
getModelObject().getValues().add(valueWrapper);
return valueWrapper;
Expand Down
Expand Up @@ -237,11 +237,13 @@ public List<ObjectReferenceType> load() {
PrismContainerValue associationValue = ((ContainerValueWrapper) associationValueWrapper).getContainerValue();
ResourceObjectAssociationType assoc = (ResourceObjectAssociationType) associationValue.asContainerable();
if (assoc == null || assoc.getOutbound() == null || assoc.getOutbound().getExpression() == null
|| ExpressionUtil.getShadowRefValue(assoc.getOutbound().getExpression()) == null) {
|| (ExpressionUtil.getShadowRefValue(assoc.getOutbound().getExpression()) == null
&& !ValueStatus.ADDED.equals(((ContainerValueWrapper) associationValueWrapper).getStatus()))) {
return;
}
QName assocRef = ItemPathUtil.getOnlySegmentQName(assoc.getRef());
if (defName != null && defName.equals(assocRef)) {
if ((defName != null && defName.equals(assocRef))
|| (assocRef == null && ValueStatus.ADDED.equals(((ContainerValueWrapper) associationValueWrapper).getStatus()))) {
shadowsList.add(ExpressionUtil.getShadowRefValue(assoc.getOutbound().getExpression()));
}
});
Expand Down Expand Up @@ -279,6 +281,7 @@ private List<ObjectReferenceType> getAssociationsShadowRefs(boolean compareName,
private void addNewShadowRefValuePerformed(AjaxRequestTarget target, RefinedAssociationDefinition def){
ObjectFilter filter = WebComponentUtil.createAssociationShadowRefFilter(def,
getPageBase().getPrismContext(), resourceModel.getObject().getOid());
Task task = getPageBase().createAnonymousTask("Adding new shadow");
ObjectBrowserPanel<ShadowType> objectBrowserPanel = new ObjectBrowserPanel<ShadowType>(
getPageBase().getMainPopupBodyId(), ShadowType.class, Arrays.asList(ShadowType.COMPLEX_TYPE),
false, getPageBase(),
Expand All @@ -302,7 +305,7 @@ protected void onSelectPerformed(AjaxRequestTarget target, ShadowType object) {
ContainerWrapperFactory factory = new ContainerWrapperFactory(getPageBase());
ContainerValueWrapper<ResourceObjectAssociationType> valueWrapper =
factory.createContainerValueWrapper(associationWrapper, newAssociation,
associationWrapper.getObjectStatus(), ValueStatus.ADDED, associationWrapper.getPath());
associationWrapper.getObjectStatus(), ValueStatus.ADDED, associationWrapper.getPath(), task);
// valueWrapper.setShowEmpty(true, false);
associationWrapper.getValues().add(valueWrapper);

Expand Down
Expand Up @@ -105,11 +105,7 @@ protected ObjectQuery createObjectQuery() {
ObjectQuery query = super.createObjectQuery();
ObjectFilter filter = query.getFilter();
ObjectQuery entitlementsQuery = QueryBuilder.queryFor(AssignmentType.class, getParentPage().getPrismContext())
.block()
.not()
.item(AssignmentType.F_CONSTRUCTION, ConstructionType.F_ASSOCIATION, ResourceObjectAssociationType.F_OUTBOUND, MappingType.F_EXPRESSION)
.isNull()
.endBlock()
.exists(AssignmentType.F_CONSTRUCTION)
.build();
if (filter != null){
query.setFilter(AndFilter.createAnd(filter, entitlementsQuery.getFilter()));
Expand All @@ -130,11 +126,6 @@ protected Class getDefaultNewAssignmentFocusType(){
}

@Override

protected void initAssociationContainer(ConstructionType constructionType){
constructionType.beginAssociation().beginOutbound().beginExpression();
}

protected boolean isRelationVisible() {
return false;
}
Expand Down Expand Up @@ -202,24 +193,32 @@ private IModel<String> getAssociationLabelModel(ContainerValueWrapper<Assignment

@Override
protected List<ContainerValueWrapper<AssignmentType>> postSearch(List<ContainerValueWrapper<AssignmentType>> assignments) {
//TODO fix post search filtering
List<ContainerValueWrapper<AssignmentType>> filteredAssignments = new ArrayList<>();
assignments.forEach(assignmentWrapper -> {
AssignmentType assignment = assignmentWrapper.getContainerValue().asContainerable();
if (assignment.getConstruction() != null && assignment.getConstruction().getAssociation() != null){
List<ResourceObjectAssociationType> associations = assignment.getConstruction().getAssociation();
associations.forEach(association -> {
if (association.getOutbound() != null && association.getOutbound().getExpression() != null){
ObjectReferenceType shadowRef = ExpressionUtil.getShadowRefValue(association.getOutbound().getExpression());
if (shadowRef != null || (shadowRef == null && ValueStatus.ADDED.equals(assignmentWrapper.getStatus()))){
filteredAssignments.add(assignmentWrapper);
return;
}
AssignmentType assignment = assignmentWrapper.getContainerValue().asContainerable();
if (assignment.getConstruction() != null && assignment.getConstruction().getAssociation() != null) {
List<ResourceObjectAssociationType> associations = assignment.getConstruction().getAssociation();
if (associations.size() == 0 && ValueStatus.ADDED.equals(assignmentWrapper.getStatus())){
filteredAssignments.add(assignmentWrapper);
return;
}
});
associations.forEach(association -> {
if (!filteredAssignments.contains(assignmentWrapper)) {
if (association.getOutbound() == null && ValueStatus.ADDED.equals(assignmentWrapper.getStatus())) {
filteredAssignments.add(assignmentWrapper);
return;
}
if (association.getOutbound() != null && association.getOutbound().getExpression() != null) {
ObjectReferenceType shadowRef = ExpressionUtil.getShadowRefValue(association.getOutbound().getExpression());
if ((shadowRef != null || ValueStatus.ADDED.equals(assignmentWrapper.getStatus()))) {
filteredAssignments.add(assignmentWrapper);
return;
}
}
}
});
}
});
// return filteredAssignments;
return assignments;
return filteredAssignments;
}
}
Expand Up @@ -141,6 +141,7 @@ protected void newAssignmentClickPerformed(AjaxRequestTarget target) {
newAssignment.asContainerable().setPolicyRule(new PolicyRuleType());
ContainerValueWrapper<AssignmentType> newAssignmentWrapper = createNewAssignmentContainerValueWrapper(newAssignment);
newAssignmentWrapper.setShowEmpty(true, false);
newAssignmentWrapper.computeStripes();
assignmentDetailsPerformed(target, Arrays.asList(newAssignmentWrapper));
}

Expand Down

0 comments on commit cecc6d3

Please sign in to comment.