Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Jun 16, 2016
2 parents 18af4e3 + 76e9000 commit 7f96454
Show file tree
Hide file tree
Showing 22 changed files with 178 additions and 74 deletions.
Expand Up @@ -213,18 +213,18 @@ public void onCancel() {

@Override
public void onFinish() {
if(getModel() != null && getModel().getObject() != null){
IWizardStep activeStep = getModel().getObject().getActiveStep();

if(activeStep != null){
OperationResult result = ((WizardStep)activeStep).getResult();
if (result != null) {
getPageBase().showResult(result);
}
}
}
// 'show result' is already done
// if(getModel() != null && getModel().getObject() != null){
// IWizardStep activeStep = getModel().getObject().getActiveStep();
//
// if(activeStep != null){
// OperationResult result = ((WizardStep)activeStep).getResult();
// if (result != null) {
// getPageBase().showResult(result);
// }
// }
// }

//setResponsePage(new PageResources(false));
getPageBase().redirectBack();
}

Expand Down
Expand Up @@ -39,7 +39,7 @@
<wicket:message key="org.apache.wicket.extensions.wizard.save"/>
</button>
<button class="btn btn-default" wicket:id="visualize" type="submit" value="visualize">
<wicket:message key="ResourceWizard.visualize"/>
<span wicket:id="visualizeLabel" />
</button>
</span>
<span class="button-group">
Expand Down
Expand Up @@ -24,9 +24,11 @@
import org.apache.wicket.Session;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.wizard.*;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.IFormSubmittingComponent;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.AbstractReadOnlyModel;

/**
* @author lazyman
Expand All @@ -41,6 +43,7 @@ public class WizardButtonBar extends Panel implements IDefaultButtonProvider {
private static final String ID_VALIDATE = "validate";
private static final String ID_SAVE = "save";
private static final String ID_VISUALIZE = "visualize";
private static final String ID_VISUALIZE_LABEL = "visualizeLabel";

public WizardButtonBar(String id, final Wizard wizard) {
super(id);
Expand Down Expand Up @@ -136,6 +139,7 @@ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
IWizardStep activeStep = wizard.getModelObject().getActiveStep();
if (activeStep != null) {
activeStep.applyState();
target.add(getPage());
}
}

Expand All @@ -150,6 +154,16 @@ protected void onError(AjaxRequestTarget target, Form<?> form) {
final AjaxSubmitButton visualize = new AjaxSubmitButton(ID_VISUALIZE) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
IWizardStep activeStep = wizard.getModelObject().getActiveStep();
PageResourceWizard wizardPage = (PageResourceWizard) getPage();
if (!wizardPage.isReadOnly()) {
if (activeStep != null) {
activeStep.applyState();
if (!activeStep.isComplete()) {
return;
}
}
}
((PageResourceWizard) getPage()).visualize(target);
}

Expand All @@ -160,6 +174,15 @@ protected void onError(AjaxRequestTarget target, Form<?> form) {
};
visualize.setVisible(moreSteps);
add(visualize);

Label visualizeLabel = new Label(ID_VISUALIZE_LABEL, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
PageResourceWizard wizardPage = (PageResourceWizard) getPage();
return wizardPage.isReadOnly() ? getString("ResourceWizard.visualize") : getString("ResourceWizard.saveAndVisualize");
}
});
visualize.add(visualizeLabel);
}

private void couldntSave() {
Expand Down
Expand Up @@ -367,6 +367,8 @@ private void savePerformed() {
OperationResult result = task.getResult();
ModelService modelService = getPageBase().getModelService();

boolean saved = false;

try {
PrismObject<ResourceType> oldResource;
final PrismObject<ResourceType> resourceObject = resourceModel.getObject();
Expand Down Expand Up @@ -403,6 +405,7 @@ private void savePerformed() {
.createDeltaCollection(delta);
modelService.executeChanges(deltas, null, getPageBase().createSimpleTask(OPERATION_SAVE_CAPABILITIES), result);
parentPage.resetModels();
saved = true;
}
}
} catch (CommonException|RuntimeException e){
Expand All @@ -413,7 +416,7 @@ private void savePerformed() {
setResult(result);
}

if (WebComponentUtil.showResultInPage(result)) {
if (parentPage.showSaveResultInPage(saved, result)) {
getPageBase().showResult(result);
}
}
Expand Down
Expand Up @@ -274,6 +274,7 @@ public void applyState() {
private void saveChanges() {
Task task = parentPage.createSimpleTask(OPERATION_SAVE);
OperationResult result = task.getResult();
boolean saved = false;
try {
List<ContainerWrapper> wrappers = configurationPropertiesModel.getObject();
ObjectDelta delta = ObjectDelta.createEmptyModifyDelta(ResourceType.class, parentPage.getEditedResourceOid(), parentPage.getPrismContext());
Expand All @@ -284,6 +285,7 @@ private void saveChanges() {
parentPage.logDelta(delta);
WebModelServiceUtils.save(delta, result, parentPage);
parentPage.resetModels();
saved = true;
}
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Error occurred during saving changes", ex);
Expand All @@ -293,7 +295,7 @@ private void saveChanges() {
setResult(result);
}

if (WebComponentUtil.showResultInPage(result)) {
if (parentPage.showSaveResultInPage(saved, result)) {
parentPage.showResult(result);
}

Expand Down
Expand Up @@ -45,7 +45,6 @@
import com.evolveum.midpoint.web.component.form.DropDownFormGroup;
import com.evolveum.midpoint.web.component.form.TextAreaFormGroup;
import com.evolveum.midpoint.web.component.form.TextFormGroup;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.component.wizard.WizardStep;
import com.evolveum.midpoint.web.component.wizard.resource.dto.ConnectorHostTypeComparator;
import com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard;
Expand Down Expand Up @@ -433,6 +432,7 @@ public void applyState() {
PrismContext prismContext = parentPage.getPrismContext();
Task task = parentPage.createSimpleTask(OPERATION_SAVE_RESOURCE);
OperationResult result = task.getResult();
boolean saved = false;

try {
PrismObject<ResourceType> resource = resourceModelRaw.getObject();
Expand Down Expand Up @@ -481,6 +481,7 @@ public void applyState() {
parentPage.logDelta(delta);
WebModelServiceUtils.save(delta, ModelExecuteOptions.createRaw(), result, parentPage);
parentPage.resetModels();
saved = true;
}

if (isNew) {
Expand All @@ -495,7 +496,7 @@ public void applyState() {
setResult(result);
}

if (WebComponentUtil.showResultInPage(result)) {
if (parentPage.showSaveResultInPage(saved, result)) {
parentPage.showResult(result);
}
}
Expand Down
Expand Up @@ -49,6 +49,7 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down Expand Up @@ -284,16 +285,18 @@ public String getObject() {

if (objectType != null) {
ResourceObjectTypeDefinitionType object = objectType.getObjectType();
sb.append(object.getDisplayName() != null ? object.getDisplayName() : "- ");
sb.append(object.getDisplayName() != null ? object.getDisplayName() + " " : "");
addKindAndIntent(sb, object.getKind(), object.getIntent());
sb.append(" -> ");
sb.append(object.getObjectClass() != null ? object.getObjectClass().getLocalPart() : "");
}
return sb.toString();
}
};
}

static void addKindAndIntent(StringBuilder sb, ShadowKindType kind, String intent) {
sb.append(" (");
sb.append("(");
sb.append(ResourceTypeUtil.fillDefault(kind));
sb.append(", ");
sb.append(ResourceTypeUtil.fillDefault(intent));
Expand Down Expand Up @@ -354,6 +357,7 @@ protected void onUpdate(AjaxRequestTarget target) {
}
}
}
parentPage.refreshIssues(target);
}
});
parentPage.addEditingEnabledBehavior(editorDefault);
Expand All @@ -379,12 +383,7 @@ protected Iterator<String> getChoices(String input) {
return getObjectClassChoices(input);
}
};
editorObjectClass.add(new EmptyOnChangeAjaxFormUpdatingBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget target) {
parentPage.refreshIssues(target);
}
});
editorObjectClass.add(new UpdateNamesBehaviour());
editorObjectClass.add(createObjectClassValidator(new AbstractReadOnlyModel<List<QName>>() {
@Override
public List<QName> getObject() {
Expand Down Expand Up @@ -592,7 +591,7 @@ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
editor.add(credentialsTooltip);
}

private String formatItemInfo(ResourceItemDefinitionType item, ItemPathType ref, String displayName, List<MappingType> inbound,
private String formatItemInfo(ResourceItemDefinitionType item, ItemPathType ref, String displayName, List<MappingType> inbounds,
MappingType outbound) {
StringBuilder sb = new StringBuilder();
if (ref != null && !ref.getItemPath().isEmpty()) {
Expand All @@ -613,16 +612,42 @@ private String formatItemInfo(ResourceItemDefinitionType item, ItemPathType ref,
if (displayName != null) {
sb.append(" (").append(displayName).append(")");
}
if (!inbound.isEmpty()) {
sb.append(", ");
sb.append(getString("SchemaHandlingStep.in", inbound.size()));
if (!inbounds.isEmpty()) {
sb.append(" | ");
sb.append(getString("SchemaHandlingStep.in", ""));
boolean first = true;
for (MappingType inbound : inbounds) {
if (inbound != null && inbound.getTarget() != null) {
if (first) first = false; else sb.append(", ");
sb.append(formatPath(inbound.getTarget().getPath()));
}
}
}
if (outbound != null) {
sb.append(", ").append(getString("SchemaHandlingStep.out"));
sb.append(" | ").append(getString("SchemaHandlingStep.out")).append(": ");
boolean first = true;
for (MappingSourceDeclarationType source : outbound.getSource()) {
if (source != null) {
if (first) first = false; else sb.append(", ");
sb.append(formatPath(source.getPath()));
}
}
}
return sb.toString();
}

// FIXME brutally hacked for now
private String formatPath(ItemPathType path) {
String rv = String.valueOf(path);
rv = StringUtils.removeStart(rv, "$user/");
rv = StringUtils.removeStart(rv, "$c:user/");
rv = StringUtils.removeStart(rv, "$focus/");
rv = StringUtils.removeStart(rv, "$c:focus/");
rv = StringUtils.removeStart(rv, "extension/");
rv = StringUtils.removeStart(rv, "c:extension/");
return rv;
}

private String getDuplicateInfo(ResourceItemDefinitionType item) {
ResourceObjectTypeDefinitionTypeDto selectedObjectTypeDto = schemaHandlingDtoModel.getObject().getSelectedObjectTypeDto();
if (selectedObjectTypeDto == null) {
Expand Down Expand Up @@ -843,6 +868,7 @@ private void savePerformed() {
OperationResult result = task.getResult();
ModelService modelService = parentPage.getModelService();
ObjectDelta delta;
boolean saved = false;

removeEmptyContainers(newResource);

Expand All @@ -859,6 +885,7 @@ private void savePerformed() {
Collection<ObjectDelta<? extends ObjectType>> deltas = WebComponentUtil.createDeltaCollection(delta);
modelService.executeChanges(deltas, null, parentPage.createSimpleTask(OPERATION_SAVE_SCHEMA_HANDLING), result);
parentPage.resetModels();
saved = true;
}
} catch (RuntimeException|CommonException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save schema handling", e);
Expand All @@ -868,7 +895,7 @@ private void savePerformed() {
}

setResult(result);
if (WebComponentUtil.showResultInPage(result)) {
if (parentPage.showSaveResultInPage(saved, result)) {
parentPage.showResult(result);
}
}
Expand Down Expand Up @@ -910,10 +937,10 @@ private boolean isSelected(@NotNull ResourceObjectTypeDefinitionTypeDto objectTy

private void addObjectTypePerformed(AjaxRequestTarget target) {
ResourceObjectTypeDefinitionType objectType = new ResourceObjectTypeDefinitionType();
objectType.setDisplayName(generateName(getString("SchemaHandlingStep.label.newObjectType")));
//objectType.setDisplayName(generateName(getString("SchemaHandlingStep.label.newObjectType")));
ResourceObjectTypeDefinitionTypeDto dto = new ResourceObjectTypeDefinitionTypeDto(objectType);

if (schemaHandlingDtoModel.getObject().getObjectTypeDtoList().isEmpty()){
if (schemaHandlingDtoModel.getObject().getObjectTypeDtoList().isEmpty()) {
objectType.setDefault(true);
}

Expand Down

0 comments on commit 7f96454

Please sign in to comment.