Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Oct 16, 2018
2 parents e39d7e8 + 91291e0 commit 8ffa8a1
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 13 deletions.
Expand Up @@ -1179,13 +1179,13 @@ public static <C extends Containerable> String getDisplayName(PrismContainerValu
}
if (prismContainerValue.canRepresent(ResourceItemDefinitionType.class)){
ResourceItemDefinitionType resourceItemDefinition = (ResourceItemDefinitionType) prismContainerValue.asContainerable();
if(!resourceItemDefinition.getDisplayName().isEmpty()) {
if(resourceItemDefinition.getDisplayName() != null && !resourceItemDefinition.getDisplayName().isEmpty()) {
return resourceItemDefinition.getDisplayName();
}
}
if (prismContainerValue.canRepresent(MappingType.class)){
MappingType mapping = (MappingType) prismContainerValue.asContainerable();
if(!mapping.getName().isEmpty()) {
if(mapping.getName() != null && !mapping.getName().isEmpty()) {
String name = mapping.getName();
String description = mapping.getDescription();
return name + (StringUtils.isNotEmpty(description) ? (" - " + description) : "");
Expand Down
Expand Up @@ -27,6 +27,7 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType;

import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import javax.xml.namespace.QName;

Expand All @@ -47,6 +48,10 @@ public class RealContainerValueFromSingleValueContainerWrapperModel<C extends Co
public RealContainerValueFromSingleValueContainerWrapperModel(IModel<ContainerWrapper<C>> model) {
this.model = model;
}

public RealContainerValueFromSingleValueContainerWrapperModel(ContainerWrapper<C> wrapper) {
this.model = Model.of(wrapper);
}

@Override
public void detach() {
Expand Down
Expand Up @@ -15,7 +15,7 @@
~ limitations under the License.
-->
<wicket:panel xmlns:wicket="http://wicket.apache.org">
<div wicket:id="summaryBox" class="col-xs-12 info-box" style="padding: 0px; padding-bottom:5px">
<div wicket:id="summaryBox" class="col-xs-12 info-box" style="padding: 0px;">
<!-- take care that there are no whitespaces inside the following div -->
<div wicket:id="summaryIconBox" class="info-box-icon"><span class="user-thumbnail-helper"/><span wicket:id="summaryIcon"/><img wicket:id="summaryPhoto" class="user-thumbnail"/></div>
<div class="info-box-content">
Expand Down
Expand Up @@ -412,14 +412,20 @@ protected PrismContainerPanel getSpecificContainerPanel(ContainerValueWrapper<As
}

protected ItemVisibility getSpecificContainersItemsVisibility(ItemWrapper itemWrapper, ItemPath parentAssignmentPath) {
if(parentAssignmentPath.append(AssignmentType.F_CONSTRUCTION).append(ConstructionType.F_ATTRIBUTE).append(ResourceAttributeDefinitionType.F_INBOUND).removeIdentifiers().isSubPathOrEquivalent(itemWrapper.getPath().removeIdentifiers())
|| parentAssignmentPath.append(AssignmentType.F_CONSTRUCTION).append(ConstructionType.F_ASSOCIATION).append(ResourceAttributeDefinitionType.F_INBOUND).removeIdentifiers().isSubPathOrEquivalent(itemWrapper.getPath().removeIdentifiers())) {
return ItemVisibility.HIDDEN;
}
if (ContainerWrapper.class.isAssignableFrom(itemWrapper.getClass())){
return ItemVisibility.AUTO;
}
List<ItemPath> pathsToHide = new ArrayList<>();
pathsToHide.add(parentAssignmentPath.append(AssignmentType.F_CONSTRUCTION).append(ConstructionType.F_RESOURCE_REF));
pathsToHide.add(parentAssignmentPath.append(AssignmentType.F_CONSTRUCTION).append(ConstructionType.F_AUXILIARY_OBJECT_CLASS));
pathsToHide.add(parentAssignmentPath.append(AssignmentType.F_CONSTRUCTION).append(ConstructionType.F_STRENGTH));
if (PropertyOrReferenceWrapper.class.isAssignableFrom(itemWrapper.getClass()) && !WebComponentUtil.isItemVisible(pathsToHide, itemWrapper.getPath())) {
pathsToHide.add(parentAssignmentPath.append(AssignmentType.F_CONSTRUCTION).append(ConstructionType.F_RESOURCE_REF).removeIdentifiers());
pathsToHide.add(parentAssignmentPath.append(AssignmentType.F_CONSTRUCTION).append(ConstructionType.F_AUXILIARY_OBJECT_CLASS).removeIdentifiers());
pathsToHide.add(parentAssignmentPath.append(AssignmentType.F_CONSTRUCTION).append(ConstructionType.F_STRENGTH).removeIdentifiers());
pathsToHide.add(parentAssignmentPath.append(AssignmentType.F_CONSTRUCTION).append(ConstructionType.F_ATTRIBUTE).append(ResourceAttributeDefinitionType.F_INBOUND).removeIdentifiers());
pathsToHide.add(parentAssignmentPath.append(AssignmentType.F_CONSTRUCTION).append(ConstructionType.F_ASSOCIATION).append(ResourceObjectAssociationType.F_INBOUND).removeIdentifiers());
if (PropertyOrReferenceWrapper.class.isAssignableFrom(itemWrapper.getClass()) && !WebComponentUtil.isItemVisible(pathsToHide, itemWrapper.getPath().removeIdentifiers())) {
return ItemVisibility.AUTO;
} else {
return ItemVisibility.HIDDEN;
Expand Down
Expand Up @@ -231,8 +231,6 @@ public String getObject() {
public static String getName(ContainerValueWrapper<AssignmentType> assignmentValueWrapper, PageBase pageBase) {
AssignmentType assignment = assignmentValueWrapper.getContainerValue().asContainerable();

LOGGER.info("XXXXXXXXXXXXXXXXXXXXXXXX ass :" + assignment);

if (assignment == null) {
return null;
}
Expand Down
Expand Up @@ -21,9 +21,12 @@
import java.util.*;

import javax.xml.datatype.Duration;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.common.refinery.RefinedAssociationDefinition;
import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition;
import com.evolveum.midpoint.common.refinery.RefinedResourceSchema;
import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl;
import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.web.component.input.*;
Expand All @@ -41,13 +44,11 @@
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField;
import org.apache.wicket.extensions.yui.calendar.DateTimeField;
import org.apache.wicket.feedback.ComponentFeedbackMessageFilter;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.markup.html.form.TextField;
Expand Down Expand Up @@ -77,8 +78,8 @@
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.processor.ResourceAttribute;
import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ShadowUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.DOMUtil;
import com.evolveum.midpoint.util.MiscUtil;
Expand All @@ -98,6 +99,7 @@
import com.evolveum.prism.xml.ns._public.query_3.QueryType;
import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType;
import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;
import org.apache.wicket.util.visit.IVisit;
import org.apache.wicket.util.visit.IVisitor;
Expand Down Expand Up @@ -733,6 +735,90 @@ public String getObject() {
}
}, 10);
} else if (ItemPathType.COMPLEX_TYPE.equals(valueType)) {

if((getModelObject().getItem().getParent() != null && getModelObject().getItem().getParent().getPath() != null)
&& (getModelObject().getItem().getParent().getPath().removeIdentifiers().equivalent(
new ItemPath(AbstractRoleType.F_INDUCEMENT, AssignmentType.F_CONSTRUCTION, ConstructionType.F_ATTRIBUTE))
|| getModelObject().getItem().getParent().getPath().removeIdentifiers().equivalent(
new ItemPath(AbstractRoleType.F_INDUCEMENT, AssignmentType.F_CONSTRUCTION, ConstructionType.F_ASSOCIATION)))
&& (getModelObject().getItem().getParent().getItem() != null
&& getModelObject().getItem().getParent().getItem().getParent() != null)){

Class type = XsdTypeMapper.getXsdToJavaMapping(valueType);
if (type != null && type.isPrimitive()) {
type = ClassUtils.primitiveToWrapper(type);

}

PrismContainerValue reference = (PrismContainerValue)getModelObject().getItem().getParent().getItem().getParent();

ResourceType resource = ((ConstructionType)reference.getValue()).getResource();
if(resource == null) {
ObjectReferenceType resourceRef = ((ConstructionType)reference.getValue()).getResourceRef();
OperationResult result = new OperationResult("load_resource");
Task task = getPageBase().createSimpleTask("load_resource");
resource = (ResourceType)WebModelServiceUtils.resolveReferenceNoFetch(resourceRef, getPageBase(), task, result).getRealValue();
}

RefinedResourceSchema schema = null;
try {
schema = RefinedResourceSchemaImpl.getRefinedSchema(resource, getPageBase().getPrismContext());
} catch (SchemaException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't parse resource schema.", ex);
getSession().error(getString("SchemaListPanel.message.couldntParseSchema") + " " + ex.getMessage());
}

LookupTableType lookupTable = new LookupTableType();
List<LookupTableRowType> list = lookupTable.createRowList();

for(RefinedObjectClassDefinition schemaDefinition: schema.getRefinedDefinitions()){
if(getModelObject().getItem().getParent().getPath().removeIdentifiers().equivalent(
new ItemPath(AbstractRoleType.F_INDUCEMENT, AssignmentType.F_CONSTRUCTION, ConstructionType.F_ATTRIBUTE))) {
for (ResourceAttributeDefinition def : schemaDefinition.getAttributeDefinitions()) {
LookupTableRowType row = new LookupTableRowType();
row.setKey(def.getName().toString());
row.setValue(def.getName().toString());
row.setLabel(new PolyStringType(def.getName().getLocalPart()));
list.add(row);
}
} else {
for (RefinedAssociationDefinition def : schemaDefinition.getAssociationDefinitions()) {
LookupTableRowType row = new LookupTableRowType();
row.setKey(def.getName().toString());
row.setValue(def.getName().toString());
row.setLabel(new PolyStringType(def.getName().getLocalPart()));
list.add(row);
}
}
}
LookupPropertyModel inputValue = new LookupPropertyModel<>(Model.of(getModel()), baseExpression, lookupTable, true);
return new AutoCompleteTextPanel<String>(id, inputValue, String.class) {

private static final long serialVersionUID = 1L;

@Override
public Iterator<String> getIterator(String input) {
return prepareAutoCompleteList(input, lookupTable.asPrismObject()).iterator();
}

@Override
public void checkInputValue(AutoCompleteTextField input, AjaxRequestTarget target, LookupPropertyModel model){
model.setObject(input.getInput());
for(LookupTableRowType row : lookupTable.getRow()) {
if(row.getLabel().toString().equalsIgnoreCase(input.getInput())) {
String namespace = row.getValue().substring(row.getValue().indexOf("{") + 1);
namespace = namespace.substring(0, namespace.indexOf("}"));
((PrismPropertyValue<ItemPathType>) PrismValuePanel.this.getModelObject().getValue()).setValue(new ItemPathType(new ItemPath(new QName(namespace, row.getLabel().toString()))));
break;
}
}

}


};
}

return new ItemPathPanel(id, (ItemPathType) getModelObject().getValue().getRealValue()) {

private static final long serialVersionUID = 1L;
Expand Down

0 comments on commit 8ffa8a1

Please sign in to comment.