Skip to content

Commit

Permalink
archetypeRef filter is added to new assignment popup query
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Jan 23, 2019
1 parent d85d3ca commit ea7e974
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
Expand Up @@ -17,10 +17,14 @@

import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.query.RefFilter;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.web.component.util.SelectableBean;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import org.apache.commons.collections.CollectionUtils;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.WebMarkupContainer;
Expand Down Expand Up @@ -83,7 +87,22 @@ protected IModel<Boolean> getCheckBoxEnableModel(IModel<SelectableBean<O>> rowMo

@Override
protected ObjectQuery addFilterToContentQuery(ObjectQuery query) {
return AbstractPopupTabPanel.this.addFilterToContentQuery(query);
ObjectQuery queryWithFilters = AbstractPopupTabPanel.this.addFilterToContentQuery(query);
List<ObjectReferenceType> archetypeRefList = getArchetypeRefList();
if (!CollectionUtils.isEmpty(archetypeRefList)){
if (queryWithFilters == null){
queryWithFilters = getPrismContext().queryFactory().createQuery();
}
for (ObjectReferenceType archetypeRef : archetypeRefList){
RefFilter filter = (RefFilter) AbstractPopupTabPanel.this.getPageBase().getPrismContext().queryFor(AssignmentHolderType.class)
.item(AssignmentHolderType.F_ARCHETYPE_REF).ref(archetypeRef.getOid())
.buildFilter();
filter.setTargetTypeNullAsAny(true);
filter.setRelationNullAsAny(true);
queryWithFilters.addFilter(filter);
}
}
return queryWithFilters;
}

};
Expand Down Expand Up @@ -126,6 +145,10 @@ protected ObjectQuery addFilterToContentQuery(ObjectQuery query){
return query;
}

protected List<ObjectReferenceType> getArchetypeRefList(){
return null;
}

protected boolean isObjectListPanelVisible(){
return true;
}
Expand Down
Expand Up @@ -146,6 +146,11 @@ protected ContainerWrapper<AssignmentType> getAssignmentWrapperModel() {
protected QName getPredefinedRelation() {
return AssignmentPopup.this.getPredefinedRelation();
}

@Override
protected List<ObjectReferenceType> getArchetypeRefList(){
return AssignmentPopup.this.getArchetypeRefList();
}
};
}

Expand Down Expand Up @@ -191,6 +196,11 @@ protected ContainerWrapper<AssignmentType> getAssignmentWrapperModel() {
protected QName getPredefinedRelation() {
return AssignmentPopup.this.getPredefinedRelation();
}

@Override
protected List<ObjectReferenceType> getArchetypeRefList(){
return AssignmentPopup.this.getArchetypeRefList();
}
};
}

Expand Down Expand Up @@ -231,6 +241,11 @@ protected ContainerWrapper<AssignmentType> getAssignmentWrapperModel() {
protected QName getPredefinedRelation() {
return AssignmentPopup.this.getPredefinedRelation();
}

@Override
protected List<ObjectReferenceType> getArchetypeRefList(){
return AssignmentPopup.this.getArchetypeRefList();
}
};
}

Expand Down Expand Up @@ -271,6 +286,10 @@ protected QName getPredefinedRelation() {
return AssignmentPopup.this.getPredefinedRelation();
}

@Override
protected List<ObjectReferenceType> getArchetypeRefList(){
return AssignmentPopup.this.getArchetypeRefList();
}
};
}

Expand Down Expand Up @@ -301,6 +320,11 @@ protected void onSelectionPerformed(AjaxRequestTarget target, IModel<SelectableB
protected boolean isEntitlementAssignment(){
return AssignmentPopup.this.isEntitlementAssignment();
}

@Override
protected List<ObjectReferenceType> getArchetypeRefList(){
return AssignmentPopup.this.getArchetypeRefList();
}
};
}

Expand All @@ -317,6 +341,10 @@ protected ContainerWrapper<AssignmentType> getAssignmentWrapperModel(){
return null;
}

protected List<ObjectReferenceType> getArchetypeRefList(){
return null;
}

private boolean isTabVisible(ObjectTypes objectType){
List<ObjectTypes> availableObjectTypesList = getAvailableObjectTypesList();
return availableObjectTypesList == null || availableObjectTypesList.size() == 0 || availableObjectTypesList.contains(objectType);
Expand Down
Expand Up @@ -459,9 +459,16 @@ protected List<ObjectTypes> getAvailableObjectTypesList(){

@Override
protected QName getPredefinedRelation(){
if (assignmentTargetRelation == null){
return null;
}
return !CollectionUtils.isEmpty(assignmentTargetRelation.getRelations()) ? assignmentTargetRelation.getRelations().get(0) : null;
}

@Override
protected List<ObjectReferenceType> getArchetypeRefList(){
return assignmentTargetRelation != null ? assignmentTargetRelation.getArchetypeRefs() : null;
}

@Override
protected boolean isEntitlementAssignment(){
Expand Down

0 comments on commit ea7e974

Please sign in to comment.