Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Aug 25, 2019
2 parents 72c32d6 + e690f38 commit 29c3f70
Show file tree
Hide file tree
Showing 19 changed files with 655 additions and 82 deletions.
Expand Up @@ -27,17 +27,27 @@
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LambdaModel;
import org.apache.wicket.validation.IValidatable;

import com.evolveum.midpoint.gui.api.factory.GuiComponentFactory;
import com.evolveum.midpoint.gui.api.prism.PrismObjectWrapper;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.WebPrismUtil;
import com.evolveum.midpoint.gui.impl.factory.ItemRealValueModel;
import com.evolveum.midpoint.gui.impl.factory.PrismReferencePanelContext;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismPropertyValue;
import com.evolveum.midpoint.prism.PrismReferenceValue;
import com.evolveum.midpoint.prism.Referencable;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.form.ValueChoosePanel;
import com.evolveum.midpoint.web.component.message.FeedbackAlerts;
import com.evolveum.midpoint.web.util.ExpressionValidator;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType;
Expand All @@ -49,6 +59,7 @@
public class PrismReferencePanel<R extends Referencable> extends ItemPanel<PrismReferenceValueWrapperImpl<R>, PrismReferenceWrapper<R>>{

private static final long serialVersionUID = 1L;
private static final Trace LOGGER = TraceManager.getTrace(PrismReferencePanel.class);

private static final String ID_HEADER = "header";
private static final String ID_VALUE = "value";
Expand All @@ -75,7 +86,7 @@ protected Component createValuePanel(ListItem<PrismReferenceValueWrapperImpl<R>>
item.add(panel);
return panel;
} else {
FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK);
FeedbackAlerts feedback = new FeedbackAlerts(ID_FEEDBACK);
feedback.setOutputMarkupId(true);
item.add(feedback);
ValueChoosePanel<R> panel = new ValueChoosePanel<R>(ID_VALUE, new ItemRealValueModel<>(item.getModel())) {
Expand All @@ -101,6 +112,14 @@ protected boolean isEditButtonEnabled() {
return item.getModelObject().isEditEnabled();

}

@Override
protected <O extends ObjectType> void choosePerformed(AjaxRequestTarget target, O object) {
super.choosePerformed(target, object);
getBaseFormComponent().validate();
target.add(getPageBase().getFeedbackPanel());
target.add(feedback);
}

@Override
public List<QName> getSupportedTypes() {
Expand All @@ -122,6 +141,17 @@ protected <O extends ObjectType> Class<O> getDefaultType(List<QName> supportedTy

};

ExpressionValidator<String> expressionValidator = new ExpressionValidator<String>(
LambdaModel.of(getModel().getObject()::getFormComponentValidator), getPageBase()) {

private static final long serialVersionUID = 1L;

@Override
protected Object getValueToValidate(IValidatable<String> validatable) {
return item.getModelObject().getRealValue();
}
};
panel.getBaseFormComponent().add(expressionValidator);
feedback.setFilter(new ComponentFeedbackMessageFilter(panel));
item.add(panel);

Expand Down
Expand Up @@ -25,8 +25,11 @@
<wicket:message key="PageBase.button.edit" />
</button>
</span>
<input type="text" class="form-control input-sm" wicket:id="text" />
<span class="text-danger" wicket:id="feedback" />
<input type="text" class="form-control input-sm" wicket:id="text" disabled style="cursor: not-allowed; background: #eeeeee;"/>

</div>
<div>
<span wicket:id="feedback" />
</div>
</div>

Expand Down
Expand Up @@ -29,6 +29,7 @@
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.feedback.ComponentFeedbackMessageFilter;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.IModel;
Expand All @@ -43,6 +44,8 @@
import com.evolveum.midpoint.util.MiscUtil;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.message.FeedbackAlerts;
import com.evolveum.midpoint.web.component.prism.InputPanel;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
Expand Down Expand Up @@ -72,13 +75,11 @@ public class ValueChoosePanel<R extends Referencable> extends BasePanel<R> {

public ValueChoosePanel(String id, IModel<R> value) {
super(id, value);
setOutputMarkupId(true);
setOutputMarkupId(true);
initLayer();
}

@Override
protected void onInitialize() {
super.onInitialize();

private void initLayer() {
WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);

textWrapper.setOutputMarkupId(true);
Expand All @@ -94,10 +95,11 @@ protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
});
text.add(AttributeAppender.append("title", textModel));
text.setRequired(isRequired());
text.setEnabled(false);
text.setEnabled(true);
textWrapper.add(text);

FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(text));
FeedbackAlerts feedback = new FeedbackAlerts(ID_FEEDBACK);
feedback.setFilter(new ComponentFeedbackMessageFilter(text));
textWrapper.add(feedback);

AjaxLink<String> edit = new AjaxLink<String>(ID_EDIT) {
Expand Down Expand Up @@ -187,58 +189,14 @@ protected IModel<String> createTextModel() {
public String getObject() {
R prv = model.getObject();

// if (ort instanceof PrismReferenceValue) {
// PrismReferenceValue prv = (PrismReferenceValue) ort;
// return prv == null ? null
// : (prv.getTargetName() != null
// ? (prv.getTargetName().getOrig() + (prv.getTargetType() != null
// ? ": " + prv.getTargetType().getLocalPart() : ""))
// : prv.getOid());
// } else if (ort instanceof ObjectReferenceType) {
// Referencable prv = (Referencable) ort;
return prv == null ? null
: (prv.getTargetName() != null ? (prv.getTargetName().getOrig()
+ (prv.getType() != null ? ": " + prv.getType().getLocalPart() : ""))
: prv.getOid());
// } else if (ort instanceof ObjectViewDto) {
// return ((ObjectViewDto) ort).getName();
// }
// return ort != null ? ort.toString() : null;
//=======
// T ort = (T) model.getObject();
// if (ort == null){
// return createStringResource("ValueChoosePanel.undefined").getString();
// }
//
// if (ort instanceof PrismReferenceValue) {
// PrismReferenceValue prv = (PrismReferenceValue) ort;
// if (StringUtils.isEmpty(prv.getOid())){
// return createStringResource("ValueChoosePanel.undefined").getString();
// }
// ObjectReferenceType objectReferenceType = new ObjectReferenceType();
// objectReferenceType.setupReferenceValue((PrismReferenceValue) ort);
// String targetObjectName = WebComponentUtil.getName(objectReferenceType,
// ValueChoosePanel.this.getPageBase(), OPERATION_LOAD_REFERENCE_OBJECT_DISPLAY_NAME);
// return StringUtils.isNotEmpty(targetObjectName)
// ? (targetObjectName + (prv.getTargetType() != null ? ": " + prv.getTargetType().getLocalPart() : ""))
// : prv.getOid();
// } else if (ort instanceof ObjectReferenceType) {
// ObjectReferenceType prv = (ObjectReferenceType) ort;
// if (StringUtils.isEmpty(prv.getOid())){
// return createStringResource("ValueChoosePanel.undefined").getString();
// }
// String targetObjectName = WebComponentUtil.getName(prv,
// ValueChoosePanel.this.getPageBase(), OPERATION_LOAD_REFERENCE_OBJECT_DISPLAY_NAME);
//
// return StringUtils.isNotEmpty(targetObjectName) ?
// (targetObjectName + (prv.getType() != null ? ": " + prv.getType().getLocalPart() : ""))
// : prv.getOid();
// } else if (ort instanceof ObjectViewDto) {
// return ((ObjectViewDto) ort).getName();
// }
// return ort != null ? ort.toString() : null;
//>>>>>>> origin/master

}

@Override
public void setObject(String object) {
}
};
}
Expand Down Expand Up @@ -332,4 +290,9 @@ protected <O extends ObjectType> boolean isObjectUnique(O object) {
protected <O extends ObjectType> void choosePerformedHook(AjaxRequestTarget target, O object) {
}


public FormComponent<String> getBaseFormComponent() {
return (FormComponent<String>) getTextWrapperComponent().get(ID_TEXT);
}

}
Expand Up @@ -331,7 +331,7 @@ public InlineMenuItemAction initAction() {
private static final long serialVersionUID = 1L;

@Override
public void onSubmit(AjaxRequestTarget target) {
public void onClick(AjaxRequestTarget target) {
deleteAllPerformed(target, ReportDeleteDialogDto.Operation.DELETE_ALL);
}
};
Expand All @@ -347,7 +347,7 @@ public InlineMenuItemAction initAction() {
private static final long serialVersionUID = 1L;

@Override
public void onSubmit(AjaxRequestTarget target) {
public void onClick(AjaxRequestTarget target) {
deleteSelectedPerformed(target, ReportDeleteDialogDto.Operation.DELETE_SELECTED, null);
}
};
Expand Down
Expand Up @@ -274,7 +274,7 @@ private InfoBoxPanel createLastAvailabilityStatusInfo(ResourceType resource) {

String messageKey = "PageResource.resource.availabilityUnknown";
String backgroundColor = "bg-gray";
String icon = "fa-question";
String icon = "fa fa-question";

OperationalStateType operationalState = resource.getOperationalState();
if (operationalState != null) {
Expand All @@ -283,15 +283,15 @@ private InfoBoxPanel createLastAvailabilityStatusInfo(ResourceType resource) {
if (lastAvailabilityStatus == AvailabilityStatusType.UP) {
messageKey = "PageResource.resource.up";
backgroundColor = "bg-green";
icon = "fa-power-off";
icon = "fa fa-power-off";
} else if (lastAvailabilityStatus == AvailabilityStatusType.DOWN) {
backgroundColor = "bg-red";
messageKey = "PageResource.resource.down";
icon = "fa-ban";
icon = "fa fa-ban";
} else if (lastAvailabilityStatus == AvailabilityStatusType.BROKEN) {
backgroundColor = "bg-yellow";
messageKey = "PageResource.resource.broken";
icon = "fa-warning";
icon = "fa fa-warning";
}
}
}
Expand Down Expand Up @@ -323,7 +323,7 @@ private InfoBoxPanel createLastAvailabilityStatusInfo(ResourceType resource) {
private InfoBoxPanel createSchemaStatusInfo(ResourceType resource) {

String backgroundColor = "bg-gray";
String icon = "fa-times";
String icon = "fa fa-times";
String numberMessage = null;
String description = null;

Expand All @@ -333,7 +333,7 @@ private InfoBoxPanel createSchemaStatusInfo(ResourceType resource) {
refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource);
if (refinedSchema != null) {
backgroundColor = "bg-purple";
icon = "fa-cubes";
icon = "fa fa-cubes";
int numObjectTypes = 0;
List<? extends RefinedObjectClassDefinition> refinedDefinitions = refinedSchema
.getRefinedDefinitions();
Expand All @@ -356,7 +356,7 @@ private InfoBoxPanel createSchemaStatusInfo(ResourceType resource) {
}
} catch (SchemaException e) {
backgroundColor = "bg-danger";
icon = "fa-warning";
icon = "fa fa-warning";
numberMessage = parentPage.getString("PageResource.resource.schemaError");
}

Expand Down Expand Up @@ -694,7 +694,7 @@ private SourceTarget determineIfSourceOrTarget(ResourceType resource) {

private enum SourceTarget {

NOT_DEFINED("fa-square-o"), SOURCE("fa-sign-in"), TARGET("fa-sign-out"), SOURCE_TARGET("fa-exchange");
NOT_DEFINED("fa fa-square-o"), SOURCE("fa fa-sign-in"), TARGET("fa fa-sign-out"), SOURCE_TARGET("fa fa-exchange");

private String cssClass;

Expand Down
Expand Up @@ -441,7 +441,7 @@ protected void onUpdateRow(AjaxRequestTarget target, DataTable table, IModel<Tas

columns.addAll(initCustomTaskColumns());

IColumn<TaskDto, String> menuColumn = new InlineMenuButtonColumn<>(createTasksInlineMenu(false, null),
IColumn<TaskDto, String> menuColumn = new InlineMenuButtonColumn<>(createTasksInlineMenu(true, null),
getPageBase());
columns.add(menuColumn);

Expand Down
Expand Up @@ -76,7 +76,7 @@ public void validate(IValidatable<T> validatable) {
}

PrismContext prismContext = serviceLocator.getPrismContext();
T valueToValidate = validatable.getValue();
Object valueToValidate = getValueToValidate(validatable);
String contextDesc = " form component expression validation ";
PrismPropertyDefinition<OperationResultType> outputDefinition = prismContext.definitionFactory().createPropertyDefinition(ExpressionConstants.OUTPUT_ELEMENT_NAME,
OperationResultType.COMPLEX_TYPE);
Expand Down Expand Up @@ -149,5 +149,9 @@ public void validate(IValidatable<T> validatable) {
protected <O extends ObjectType> O getObjectType() {
return null;
}

protected Object getValueToValidate(IValidatable<T> validatable) {
return validatable.getValue();
}

}
Expand Up @@ -115,7 +115,7 @@
.fe-handy:before {
content: "\e91d";
}
.fe-no-line:before {
.fe-slash:before {
content: "\e91e";
}
.fe-file:before {
Expand Down
2 changes: 1 addition & 1 deletion testing/schrodingertest/pom.xml
Expand Up @@ -16,7 +16,7 @@
<project.app.package.name>com.evolveum.midpoint.web.boot.MidPointSpringApplication</project.app.package.name>
<selenium.version>3.6.0</selenium.version>
<skipTests>false</skipTests>
<server.port>8180</server.port>
<server.port>8080</server.port>
<midpoint.host>0.0.0.0</midpoint.host>
<midpoint.home></midpoint.home>
<javax.net.ssl.trustStore></javax.net.ssl.trustStore>
Expand Down
Expand Up @@ -21,9 +21,9 @@ public class AccountTests extends TestBase {

private static File CSV_TARGET_FILE;

private static final File CSV_RESOURCE_MEDIUM = new File("../../samples/resources/csv/resource-csv-username.xml");
private static final File CSV_RESOURCE_MEDIUM = new File("./src/test/resources/csv/resource-csv-username.xml");

protected static final File CSV_INITIAL_SOURCE_FILE = new File("../../samples/resources/csv/midpoint-username.csv");
protected static final File CSV_INITIAL_SOURCE_FILE = new File("./src/test/resources/csv/midpoint-username.csv");

protected static final String IMPORT_CSV_RESOURCE_DEPENDENCY= "importCsvResource";
protected static final String CREATE_MP_USER_DEPENDENCY= "createMidpointUser";
Expand Down
Expand Up @@ -21,11 +21,11 @@ public class OrganizationStructureTests extends TestBase {

private static File CSV_TARGET_FILE;

private static final File CSV_RESOURCE_ADVANCED_SYNC = new File("../../samples/resources/csv/resource-csv-groups.xml");
private static final File CSV_RESOURCE_ADVANCED_SYNC = new File("./src/test/resources/csv/resource-csv-groups.xml");

private static final File CSV_INITIAL_SOURCE_FILE = new File("../../samples/resources/csv/midpoint-groups.csv");
private static final File CSV_INITIAL_SOURCE_FILE = new File("./src/test/resources/csv/midpoint-groups.csv");
private static final File ORG_ACCOUNT_INDUCEMENT_FILE = new File("./src/test/resources/org-account-inducement.xml");
private static final File ORG_MONKEY_ISLAND_SOURCE_FILE = new File("../../samples/org/org-monkey-island-simple.xml");
private static final File ORG_MONKEY_ISLAND_SOURCE_FILE = new File("./src/test/resources/csv/org-monkey-island-simple.xml");

private static final String TEST_USER_GUYBRUSH_NAME = "guybrush";

Expand Down
@@ -1,6 +1,6 @@
username=administrator
password=5ecr3t
base_url=http://localhost:8180/midpoint
base_url=http://localhost:8080/midpoint
webdriver=webdriver.chrome.driver
webdriverLocation=/opt/chromedriver
# By default if no value is specified for headless start then the value is: false
Expand Down
@@ -0,0 +1 @@
"login","firstname","lastname","disabled","password","groups"
@@ -0,0 +1,5 @@
username,firstname,lastname,disabled,password
user01,Firstname,Lastname,false,secret
user02,Test,Lastname,false,secret
csvUserTest,,,false,
Security Approvers manager,,,false,password

0 comments on commit 29c3f70

Please sign in to comment.