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
mederly committed Oct 27, 2014
2 parents 0a1550f + 9981473 commit ad03386
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 7 deletions.
Expand Up @@ -21,7 +21,13 @@
<div class="col-xs-10">
<input type="checkbox" wicket:id="selected"/>
<i wicket:id="typeImage"></i>
<a wicket:id="name"><span wicket:id="nameLabel"/></a>
<i class="fa fa-fw fa-exclamation-circle text-danger" wicket:id="errorIcon"></i>
<a wicket:id="name">
<span wicket:id="nameLabel"/>
</a>
<a wicket:id="errorLink" style="font-size: 1em; font-weight: normal;">
<span><wicket:message key="AssignmentEditorPanel.showMore" /></span>
</a>
<span wicket:id="activation"/>
</div>
<div class="col-xs-2 cog"/>
Expand Down
Expand Up @@ -16,6 +16,7 @@

package com.evolveum.midpoint.web.component.assignment;

import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition;
import com.evolveum.midpoint.common.refinery.RefinedResourceSchema;
import com.evolveum.midpoint.model.api.ModelService;
import com.evolveum.midpoint.prism.*;
Expand Down Expand Up @@ -106,6 +107,8 @@ public class AssignmentEditorPanel extends SimplePanel<AssignmentEditorDto> {
private static final String ID_CONSTRUCTION_CONTAINER = "constructionContainer";
private static final String ID_CONTAINER_TENANT_REF = "tenantRefContainer";
private static final String ID_TENANT_CHOOSER = "tenantRefChooser";
private static final String ID_BUTTON_SHOW_MORE = "errorLink";
private static final String ID_ERROR_ICON = "errorIcon";

private IModel<List<ACAttributeDto>> attributesModel;

Expand Down Expand Up @@ -151,6 +154,16 @@ protected void onUpdate(AjaxRequestTarget target) {
createImageTypeModel(new PropertyModel<AssignmentEditorDtoType>(getModel(), AssignmentEditorDto.F_TYPE))));
headerRow.add(typeImage);

Label errorIcon = new Label(ID_ERROR_ICON);
errorIcon.add(new VisibleEnableBehaviour(){

@Override
public boolean isVisible() {
return !isTargetValid();
}
});
headerRow.add(errorIcon);

AjaxLink name = new AjaxLink(ID_NAME) {

@Override
Expand All @@ -160,6 +173,22 @@ public void onClick(AjaxRequestTarget target) {
};
headerRow.add(name);

AjaxLink errorLink = new AjaxLink(ID_BUTTON_SHOW_MORE) {

@Override
public void onClick(AjaxRequestTarget target) {
showErrorPerformed(target);
}
};
errorLink.add(new VisibleEnableBehaviour(){

@Override
public boolean isVisible() {
return !isTargetValid();
}
});
headerRow.add(errorLink);

Label nameLabel = new Label(ID_NAME_LABEL, createAssignmentNameLabelModel());
name.add(nameLabel);

Expand Down Expand Up @@ -206,6 +235,19 @@ public String getObject() {
};
}

private boolean isTargetValid(){

if(getModel() != null && getModel().getObject() != null){
AssignmentEditorDto dto = getModelObject();

if(dto.getName() == null && dto.getAltName() == null){
return false;
}
}

return true;
}

private IModel<String> createHeaderClassModel(final IModel<AssignmentEditorDto> model) {
return new AbstractReadOnlyModel<String>() {

Expand Down Expand Up @@ -504,8 +546,14 @@ private List<ACAttributeDto> loadAttributes() {
PrismContext prismContext = getPageBase().getPrismContext();
RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resource,
LayerType.PRESENTATION, prismContext);
PrismContainerDefinition definition = refinedSchema.getRefinedDefinition(ShadowKindType.ACCOUNT, construction.getIntent())
.toResourceAttributeContainerDefinition();
RefinedObjectClassDefinition objectClassDefinition = refinedSchema.getRefinedDefinition(ShadowKindType.ACCOUNT, construction.getIntent());

if(objectClassDefinition == null){
return attributes;
}

PrismContainerDefinition definition = objectClassDefinition.toResourceAttributeContainerDefinition();

if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Refined definition for {}\n{}", construction, definition.debugDump());
}
Expand Down Expand Up @@ -661,4 +709,9 @@ protected String load() {
}
};
}

private void showErrorPerformed(AjaxRequestTarget target){
error(getString("AssignmentEditorPanel.targetError"));
target.add(getPageBase().getFeedbackPanel());
}
}
Expand Up @@ -27,5 +27,7 @@ AssignmentEditorPanel.relation=Relation
AssignmentEditorPanel.tenantRef=Tenant
AssignmentEditorPanel.name.focus=(focus mapping)
AssignmentEditorPanel.name.noTarget=(no target)
AssignmentEditorPanel.showMore=Show more
AssignmentEditorPanel.targetError=Assignment target was not found. Either target oid is malformed or target object does not exist.


Expand Up @@ -162,6 +162,10 @@ private PrismObject getReference(ObjectReferenceType ref, OperationResult result
subResult.recordFatalError("Couldn't get assignment target ref.", ex);
}

if(!subResult.isHandledError()){
getPageBase().showResultInSession(subResult);
}

return target;
}

Expand Down
Expand Up @@ -820,6 +820,10 @@ private PrismObject getReference(ObjectReferenceType ref, OperationResult result
subResult.recordFatalError("Couldn't get assignment target ref.", ex);
}

if(!subResult.isHandledError()){
showResult(subResult);
}

return target;
}

Expand Down
Expand Up @@ -230,10 +230,10 @@ object.
<q:equal>
<q:path>c:name</q:path>
<expression>
<script>
<language>http://www.w3.org/TR/xpath/</language>
<code>$c:account/c:attributes/icfs:name</code>
</script>
<path>
declare namespace icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3";
$account/attributes/icfs:name
</path>
</expression>
</q:equal>
</correlation>
Expand Down

0 comments on commit ad03386

Please sign in to comment.