Skip to content

Commit

Permalink
Merge branch 'master' into feature/pre-3.7-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Jul 24, 2017
2 parents edaeaed + 77dc8f2 commit a6ed437
Show file tree
Hide file tree
Showing 14 changed files with 684 additions and 39 deletions.
Expand Up @@ -20,11 +20,14 @@
import com.evolveum.midpoint.web.model.LookupPropertyModel;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
import org.apache.wicket.ajax.attributes.ThrottlingSettings;
import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
import org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteSettings;
import org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField;
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.model.IModel;
import org.apache.wicket.util.time.Duration;

import java.util.Iterator;

Expand Down Expand Up @@ -54,8 +57,12 @@ public AutoCompleteTextPanel(String id, final IModel<T> model, Class<T> type) {
protected Iterator<T> getChoices(String input) {
return getIterator(input);
}



@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes){
super.updateAjaxAttributes(attributes);
attributes.setThrottlingSettings(new ThrottlingSettings(Duration.ONE_SECOND, true));
}
};

input.setType(type);
Expand All @@ -67,12 +74,18 @@ protected Iterator<T> getChoices(String input) {
protected void onUpdate(AjaxRequestTarget target) {
checkInputValue(input, target, (LookupPropertyModel<T>)model);
}

@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes){
super.updateAjaxAttributes(attributes);
attributes.setThrottlingSettings(new ThrottlingSettings(Duration.ONE_SECOND, true));
}
});
}
add(input);
}

/**
/**
* This method takes care of retrieving an iterator over all
* options that can be completed. The generation of options can be
* affected by using current users input in 'input' variable.
Expand Down
Expand Up @@ -27,18 +27,19 @@
import com.evolveum.midpoint.common.SystemConfigurationHolder;
import com.evolveum.midpoint.gui.api.SubscriptionType;
import com.evolveum.midpoint.model.api.*;
import com.evolveum.midpoint.prism.query.builder.S_FilterEntryOrEmpty;
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.*;
import com.evolveum.midpoint.web.page.self.*;
import com.evolveum.midpoint.web.util.NewWindowNotifyingBehavior;
import com.evolveum.midpoint.wf.util.QueryUtils;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
import org.apache.wicket.*;
import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior;
import org.apache.wicket.ajax.AjaxNewWindowNotifyingBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.behavior.AttributeAppender;
Expand Down Expand Up @@ -313,9 +314,9 @@ private void initializeModel() {
protected Integer load() {
try {
Task task = createSimpleTask(OPERATION_LOAD_WORK_ITEM_COUNT);
ObjectQuery query = QueryBuilder.queryFor(WorkItemType.class, getPrismContext())
.item(WorkItemType.F_ASSIGNEE_REF).ref(getPrincipal().getOid())
.build();
S_FilterEntryOrEmpty q = QueryBuilder.queryFor(WorkItemType.class, getPrismContext());
ObjectQuery query = QueryUtils.filterForAssignees(q, getPrincipal(),
OtherPrivilegesLimitationType.F_APPROVAL_WORK_ITEMS).build();
return getModelService().countContainers(WorkItemType.class, query, null, task, task.getResult());
} catch (SchemaException|SecurityViolationException e) {
LoggingUtils.logExceptionAsWarning(LOGGER, "Couldn't load work item count", e);
Expand Down
Expand Up @@ -92,6 +92,22 @@ public boolean isDelta() {
return sceneItem instanceof SceneDeltaItem;
}

public boolean isNullEstimatedOldValues(){
return isDelta() && ((SceneDeltaItem)sceneItem).getSourceDelta() != null && ((SceneDeltaItem)sceneItem).getSourceDelta().getEstimatedOldValues() == null;
}

public boolean isAdd(){
return isDelta() && ((SceneDeltaItem)sceneItem).getSourceDelta() != null && ((SceneDeltaItem)sceneItem).getSourceDelta().isAdd();
}

public boolean isDelete(){
return isDelta() && ((SceneDeltaItem)sceneItem).getSourceDelta() != null && ((SceneDeltaItem)sceneItem).getSourceDelta().isDelete();
}

public boolean isReplace(){
return isDelta() && ((SceneDeltaItem)sceneItem).getSourceDelta() != null && ((SceneDeltaItem)sceneItem).getSourceDelta().isReplace();
}

public boolean isDeltaScene() {
return sceneDto.containsDeltaItems();
}
Expand Down
Expand Up @@ -16,6 +16,7 @@

package com.evolveum.midpoint.web.component.prism.show;

import com.evolveum.midpoint.model.api.visualizer.SceneDeltaItem;
import com.evolveum.midpoint.model.api.visualizer.SceneItemValue;

import java.io.Serializable;
Expand Down Expand Up @@ -72,6 +73,23 @@ public boolean isDeltaScene() {
return sceneItemDto.isDeltaScene();
}

public boolean isNullEstimatedOldValues(){
return sceneItemDto.isNullEstimatedOldValues();
}

public boolean isAdd(){
return sceneItemDto.isAdd();
}

public boolean isDelete(){
return sceneItemDto.isDelete();
}

public boolean isReplace(){
return sceneItemDto.isReplace();
}


@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Expand Up @@ -24,6 +24,7 @@
import com.evolveum.midpoint.web.component.data.column.ImagePanel;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
Expand Down Expand Up @@ -82,11 +83,16 @@ public boolean isVisible() {
oldValueCell.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getModelObject().isDelta();
return getModelObject().isNullEstimatedOldValues() || getModelObject().isDelta();
}
});
SceneItemValuePanel sivp = new SceneItemValuePanel(ID_OLD_VALUE,
new PropertyModel<SceneItemValue>(getModel(), SceneItemLineDto.F_OLD_VALUE));
Component sivp;
if (getModelObject().isNullEstimatedOldValues()){
sivp = new Label(ID_OLD_VALUE, createStringResource("SceneItemLinePanel.unknownLabel"));
} else {
sivp = new SceneItemValuePanel(ID_OLD_VALUE,
new PropertyModel<SceneItemValue>(getModel(), SceneItemLineDto.F_OLD_VALUE));
}
sivp.setRenderBodyOnly(true);
oldValueCell.add(sivp);

Expand All @@ -98,13 +104,39 @@ public boolean isVisible() {
@Override
public boolean isVisible(){
return getModelObject().getOldValue() != null &&
getModelObject().getOldValue().getSourceValue() != null;
getModelObject().getOldValue().getSourceValue() != null &&
!getModelObject().isNullEstimatedOldValues();
}
});
oldValueCell.add(oldValueImagePanel);

add(oldValueCell);

IModel<String> newValueIconModel;
IModel<String> newValueTitleModel;
if (getModelObject().isNullEstimatedOldValues()){
if (getModelObject().isAdd()){
newValueIconModel = Model.of(GuiStyleConstants.CLASS_PLUS_CIRCLE_SUCCESS);
newValueTitleModel = createStringResource("SceneItemLinePanel.addedValue");
} else if (getModelObject().isDelete()){
newValueIconModel = Model.of(GuiStyleConstants.CLASS_MINUS_CIRCLE_DANGER);
newValueTitleModel = createStringResource("SceneItemLinePanel.removedValue");
} else if (getModelObject().isReplace()){
newValueIconModel = Model.of(GuiStyleConstants.CLASS_CIRCLE_FULL);
newValueTitleModel = createStringResource("SceneItemLinePanel.unchangedValue");
} else {
newValueIconModel = Model.of("");
newValueTitleModel = Model.of("");
}
} else {
newValueIconModel = !getModelObject().isDelta() && getModelObject().isDeltaScene() ?
Model.of(GuiStyleConstants.CLASS_CIRCLE_FULL) :
Model.of(GuiStyleConstants.CLASS_PLUS_CIRCLE_SUCCESS);
newValueTitleModel = !getModelObject().isDelta() && getModelObject().isDeltaScene() ?
createStringResource("SceneItemLinePanel.unchangedValue")
: createStringResource("SceneItemLinePanel.addedValue");
}

WebMarkupContainer newValueCell = new WebMarkupContainer(ID_NEW_VALUE_CONTAINER);
sivp = new SceneItemValuePanel(ID_NEW_VALUE,
new PropertyModel<SceneItemValue>(getModel(), SceneItemLineDto.F_NEW_VALUE));
Expand All @@ -113,23 +145,18 @@ public boolean isVisible(){
newValueCell.add(new AttributeModifier("colspan", new AbstractReadOnlyModel<Integer>() {
@Override
public Integer getObject() {
return !getModelObject().isDelta() && getModelObject().isDeltaScene() ? 2 : 1;
return !getModelObject().isDelta() && !getModelObject().isNullEstimatedOldValues() && getModelObject().isDeltaScene() ? 2 : 1;
}
}));
newValueCell.add(new AttributeModifier("align", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return !getModelObject().isDelta() && getModelObject().isDeltaScene() ? "center" : null;
return !getModelObject().isDelta() && !getModelObject().isNullEstimatedOldValues() && getModelObject().isDeltaScene() ? "center" : null;
}
}));

ImagePanel newValueImagePanel = new ImagePanel(ID_NEW_VALUE_IMAGE,
!getModelObject().isDelta() && getModelObject().isDeltaScene() ?
Model.of(GuiStyleConstants.CLASS_CIRCLE_FULL) :
Model.of(GuiStyleConstants.CLASS_PLUS_CIRCLE_SUCCESS),
!getModelObject().isDelta() && getModelObject().isDeltaScene() ?
createStringResource("SceneItemLinePanel.unchangedValue")
: createStringResource("SceneItemLinePanel.addedValue"));
ImagePanel newValueImagePanel = new ImagePanel(ID_NEW_VALUE_IMAGE, newValueIconModel,
newValueTitleModel);
newValueImagePanel.add(new VisibleEnableBehaviour(){
private static final long serialVersionUID = 1L;

Expand Down
Expand Up @@ -160,15 +160,13 @@ private static <T extends ObjectType> PrismObjectDefinition findObjectDefinition
Class<T> type, ResourceShadowDiscriminator discriminator,
ModelServiceLocator modelServiceLocator) {

Task task = modelServiceLocator.createSimpleTask(LOAD_OBJECT_DEFINITION);
OperationResult result = task.getResult();
try {
if (Modifier.isAbstract(type.getModifiers())) {
SchemaRegistry registry = modelServiceLocator.getPrismContext().getSchemaRegistry();
return registry.findObjectDefinitionByCompileTimeClass(type);
}

Task task = modelServiceLocator.createSimpleTask(LOAD_OBJECT_DEFINITION);
OperationResult result = task.getResult();

PrismObject empty = modelServiceLocator.getPrismContext().createObject(type);

if (ShadowType.class.equals(type)) {
Expand All @@ -179,7 +177,8 @@ private static <T extends ObjectType> PrismObjectDefinition findObjectDefinition
empty, AuthorizationPhaseType.REQUEST, task, result);
}
} catch (SchemaException | ConfigurationException | ObjectNotFoundException ex) {
throw new SystemException(ex);
result.recordFatalError(ex.getMessage());
throw new SystemException();
}
}

Expand Down
Expand Up @@ -141,7 +141,7 @@ protected void initLayout() {
final WebMarkupContainer table = new WebMarkupContainer(ID_TABLE);
table.setOutputMarkupId(true);
add(table);
table.add(new AjaxSelfUpdatingTimerBehavior(Duration.milliseconds(1500)));
table.add(new AjaxSelfUpdatingTimerBehavior(Duration.milliseconds(10000)));

Label cpuUsage = new Label(ID_CPU_USAGE, new PropertyModel<>(getModel(), SystemInfoDto.F_CPU_USAGE));
table.add(cpuUsage);
Expand Down
Expand Up @@ -23,7 +23,7 @@
<div wicket:id="historyPanel" class="col-md-3" />
<div wicket:id="eventDetailsPanel" class="col-md-6">
<div class="box box-success">
<table class="table table-striped">
<table class="table table-striped" style="word-break: break-word;">
<tr>
<td><wicket:message key="PageAuditLogDetails.eventTimestamp" /></td>
<td><span wicket:id="timestamp" /></td>
Expand Down
Expand Up @@ -23,6 +23,7 @@
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.web.component.prism.PrismValuePanel;
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.Application;
import org.apache.wicket.Component;
Expand All @@ -32,6 +33,7 @@
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.core.util.lang.PropertyResolver;
import org.apache.wicket.core.util.lang.PropertyResolverConverter;
import org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField;
import org.apache.wicket.feedback.ComponentFeedbackMessageFilter;
import org.apache.wicket.feedback.FeedbackMessage;
import org.apache.wicket.markup.html.WebMarkupContainer;
Expand Down
Expand Up @@ -56,6 +56,7 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
import org.apache.wicket.ajax.markup.html.AjaxLink;
Expand Down Expand Up @@ -165,15 +166,15 @@ private MainObjectListPanel<FocusType> getMemberTable() {
protected AssignmentType createMemberAssignmentToModify(QName relation) throws SchemaException {
AssignmentType assignmentToModify = createAssignmentToModify(relation);

DropDownChoice<OrgType> tenantChoice = (DropDownChoice<OrgType>) get(ID_TENANT);
OrgType tenant = tenantChoice.getModelObject();
if (tenant != null) {
assignmentToModify.setTenantRef(ObjectTypeUtil.createObjectRef(tenant.getOid(), ObjectTypes.ORG));
ChooseTypePanel<OrgType> tenantChoice = (ChooseTypePanel) get(createComponentPath(ID_TENANT));
ObjectViewDto<OrgType> tenant = tenantChoice.getModelObject();
if (tenant != null && tenant.getObjectType() != null) {
assignmentToModify.setTenantRef(ObjectTypeUtil.createObjectRef(tenant.getObjectType().getOid(), ObjectTypes.ORG));
}
DropDownChoice<OrgType> projectChoice = (DropDownChoice<OrgType>) get(ID_PROJECT);
OrgType project = projectChoice.getModelObject();
if (project != null) {
assignmentToModify.setOrgRef(ObjectTypeUtil.createObjectRef(project.getOid(), ObjectTypes.ORG));
ChooseTypePanel<OrgType> projectChoice = (ChooseTypePanel) get(createComponentPath(ID_PROJECT));
ObjectViewDto<OrgType> project = projectChoice.getModelObject();
if (project != null && project.getObjectType() != null) {
assignmentToModify.setOrgRef(ObjectTypeUtil.createObjectRef(project.getObjectType().getOid(), ObjectTypes.ORG));
}

return assignmentToModify;
Expand Down
Expand Up @@ -22,9 +22,11 @@

import com.evolveum.midpoint.gui.api.PredefinedDashboardWidgetId;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.query.builder.S_FilterEntryOrEmpty;
import com.evolveum.midpoint.schema.util.AdminGuiConfigTypeUtil;
import com.evolveum.midpoint.web.application.Url;
import com.evolveum.midpoint.web.component.assignment.RelationTypes;
import com.evolveum.midpoint.wf.util.QueryUtils;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.commons.lang.Validate;
import org.apache.wicket.Application;
Expand Down Expand Up @@ -281,8 +283,12 @@ private CallableResult<List<WorkItemDto>> loadWorkItems() {
callableResult.setResult(result);

try {
ObjectQuery query = QueryBuilder.queryFor(WorkItemType.class, getPrismContext())
.item(WorkItemType.F_ASSIGNEE_REF).ref(user.getOid())
// TODO try to use current state (user) instead of potentially obsolete principal
// but this requires some computation (of deputy relation)
// (Note that the current code is consistent with the other places where work items are displayed.)
S_FilterEntryOrEmpty q = QueryBuilder.queryFor(WorkItemType.class, getPrismContext());
ObjectQuery query = QueryUtils.filterForAssignees(q, SecurityUtils.getPrincipalUser(),
OtherPrivilegesLimitationType.F_APPROVAL_WORK_ITEMS)
.desc(F_CREATE_TIMESTAMP)
.build();
Collection<SelectorOptions<GetOperationOptions>> options =
Expand Down
Expand Up @@ -3211,6 +3211,7 @@ ScenePanel.value=Value
SceneItemLinePanel.removedValue=Removed value
SceneItemLinePanel.addedValue=Added value
SceneItemLinePanel.unchangedValue=Unchanged value
SceneItemLinePanel.unknownLabel=(unknown)
operation.com.evolveum.midpoint.web.page.admin.resources.ResourceContentTabPanel.changeOwner=Change owner (GUI)
TaskSummaryPanel.progressWithTotalKnown=Progress: {0} out of {1}
TaskSummaryPanel.progressWithTotalUnknown=Progress: {0}
Expand Down
Expand Up @@ -225,12 +225,11 @@ public <O extends ObjectType> PrismObjectDefinition<O> getEditObjectDefinition(P
return null;
}

ObjectTemplateType objectTemplateType;
ObjectTemplateType objectTemplateType = null;
try {
objectTemplateType = schemaTransformer.determineObjectTemplate(object, phase, result);
} catch (ConfigurationException | ObjectNotFoundException e) {
result.recordFatalError(e);
throw e;
}
schemaTransformer.applyObjectTemplateToDefinition(objectDefinition, objectTemplateType, result);

Expand Down

0 comments on commit a6ed437

Please sign in to comment.