Skip to content

Commit

Permalink
MID-5120 assignment details panel fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Feb 5, 2019
1 parent 4fba627 commit 683cdfc
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 69 deletions.
Expand Up @@ -268,31 +268,6 @@ private <O extends ObjectType> IModel<String> getIdentifierLabelModel(ContainerV
// return WebComponentUtil.createAssignableTypesList();
// }

@Override
protected Fragment getCustomSpecificContainers(String contentAreaId, ContainerValueWrapper<AssignmentType> modelObject) {
Fragment specificContainers = new Fragment(contentAreaId, AssignmentPanel.ID_SPECIFIC_CONTAINERS_FRAGMENT, this);
specificContainers.add(getSpecificContainerPanel(modelObject));
return specificContainers;
}

@Override
protected IModel<ContainerWrapper> getSpecificContainerModel(ContainerValueWrapper<AssignmentType> modelObject) {
if (ConstructionType.COMPLEX_TYPE.equals(AssignmentsUtil.getTargetType(modelObject.getContainerValue().getValue()))) {
ContainerWrapper<ConstructionType> constructionWrapper = modelObject.findContainerWrapper(ItemPath.create(modelObject.getPath(),
AssignmentType.F_CONSTRUCTION));

return Model.of(constructionWrapper);
}

if (PersonaConstructionType.COMPLEX_TYPE.equals(AssignmentsUtil.getTargetType(modelObject.getContainerValue().getValue()))) {
ContainerWrapper<PolicyRuleType> personasWrapper = modelObject.findContainerWrapper(ItemPath.create(modelObject.getPath(),
AssignmentType.F_PERSONA_CONSTRUCTION));

return Model.of(personasWrapper);
}
return Model.of();
}

@Override
protected List<SearchItemDefinition> createSearchableItems(PrismContainerDefinition<AssignmentType> containerDef) {
List<SearchItemDefinition> defs = new ArrayList<>();
Expand Down
Expand Up @@ -21,6 +21,7 @@
<wicket:fragment wicket:id="searchFragment">
</wicket:fragment>
<wicket:fragment wicket:id="specificContainersFragment">
<div wicket:id="specificContainers" />
<div wicket:id="activationPanel" />
</wicket:fragment>
</wicket:panel>
Expand Down
Expand Up @@ -341,6 +341,14 @@ protected IModel<String> createLinkModel(IModel<ContainerValueWrapper<Assignment
return Model.of(name);
}

@Override
public boolean isEnabled(IModel<ContainerValueWrapper<AssignmentType>> rowModel) {
if (rowModel.getObject().getContainerValue().asContainerable().getFocusMappings() != null){
return false;
}
return true;
}

@Override
public void onClick(AjaxRequestTarget target, IModel<ContainerValueWrapper<AssignmentType>> rowModel) {
AssignmentPanel.this.assignmentDetailsPerformed(target);
Expand Down Expand Up @@ -610,6 +618,7 @@ protected Fragment getCustomSpecificContainers(String contentAreaId, ContainerVa
specificContainers.add(getSpecificContainerPanel(modelObject));
return specificContainers;
}

protected PrismContainerPanel getSpecificContainerPanel(ContainerValueWrapper<AssignmentType> modelObject) {
Form form = new Form<>("form");
ItemPath assignmentPath = modelObject.getPath();
Expand Down Expand Up @@ -639,6 +648,25 @@ protected ItemVisibility getSpecificContainersItemsVisibility(ItemWrapper itemWr
}

protected IModel<ContainerWrapper> getSpecificContainerModel(ContainerValueWrapper<AssignmentType> modelObject){
if (ConstructionType.COMPLEX_TYPE.equals(AssignmentsUtil.getTargetType(modelObject.getContainerValue().getValue()))) {
ContainerWrapper<ConstructionType> constructionWrapper = modelObject.findContainerWrapper(ItemPath.create(modelObject.getPath(),
AssignmentType.F_CONSTRUCTION));

return Model.of(constructionWrapper);
}

if (PersonaConstructionType.COMPLEX_TYPE.equals(AssignmentsUtil.getTargetType(modelObject.getContainerValue().getValue()))) {
//TODO is it correct? findContainerWrapper by path F_PERSONA_CONSTRUCTION will return PersonaConstructionType
//but not PolicyRuleType
ContainerWrapper<PolicyRuleType> personasWrapper = modelObject.findContainerWrapper(ItemPath.create(modelObject.getPath(),
AssignmentType.F_PERSONA_CONSTRUCTION));

return Model.of(personasWrapper);
}
if (PolicyRuleType.COMPLEX_TYPE.equals(AssignmentsUtil.getTargetType(modelObject.getContainerValue().getValue()))) {
ContainerWrapper<PolicyRuleType> policyRuleWrapper = modelObject.findContainerWrapper(ItemPath.create(modelObject.getPath(), AssignmentType.F_POLICY_RULE));
return Model.of(policyRuleWrapper);
}
return Model.of();
}

Expand All @@ -654,24 +682,28 @@ protected ItemVisibility getAssignmentBasicTabVisibity(ItemWrapper itemWrapper,
if (targetRef != null) {
targetType = targetRef.getType();
}
pathsToHide.add(parentAssignmentPath.append(AssignmentType.F_TARGET_REF));
pathsToHide.add(assignmentPath.append(AssignmentType.F_TARGET_REF));
pathsToHide.add(assignmentPath.append(AssignmentType.F_TARGET));

if (OrgType.COMPLEX_TYPE.equals(targetType) || AssignmentsUtil.isPolicyRuleAssignment(prismContainerValue.asContainerable())) {
pathsToHide.add(parentAssignmentPath.append(AssignmentType.F_TENANT_REF));
pathsToHide.add(parentAssignmentPath.append(AssignmentType.F_ORG_REF));
pathsToHide.add(assignmentPath.append(AssignmentType.F_TENANT_REF));
pathsToHide.add(assignmentPath.append(AssignmentType.F_ORG_REF));
}
if (AssignmentsUtil.isPolicyRuleAssignment(prismContainerValue.asContainerable())){
pathsToHide.add(parentAssignmentPath.append(AssignmentType.F_FOCUS_TYPE));
pathsToHide.add(assignmentPath.append(AssignmentType.F_FOCUS_TYPE));
}

if (assignment.getConstruction() == null) {
pathsToHide.add(parentAssignmentPath.append(AssignmentType.F_CONSTRUCTION));
pathsToHide.add(assignmentPath.append(AssignmentType.F_CONSTRUCTION));
}
if (assignment.getPersonaConstruction() == null) {
pathsToHide.add(assignmentPath.append(AssignmentType.F_PERSONA_CONSTRUCTION));
}
if (assignment.getPolicyRule() == null) {
pathsToHide.add(assignmentPath.append(AssignmentType.F_POLICY_RULE));
}
pathsToHide.add(parentAssignmentPath.append(AssignmentType.F_PERSONA_CONSTRUCTION));
pathsToHide.add(parentAssignmentPath.append(AssignmentType.F_POLICY_RULE));


if (PropertyOrReferenceWrapper.class.isAssignableFrom(itemWrapper.getClass()) && !WebComponentUtil.isItemVisible(pathsToHide, itemWrapper.getPath())) {
if (PropertyOrReferenceWrapper.class.isAssignableFrom(itemWrapper.getClass()) && !WebComponentUtil.isItemVisible(pathsToHide, itemWrapper.getItem().getPath())) {
return ItemVisibility.AUTO;
} else {
return ItemVisibility.HIDDEN;
Expand Down
Expand Up @@ -100,33 +100,4 @@ protected ObjectQuery createObjectQuery(){
.build();
}

@Override
protected IModel<ContainerWrapper> getSpecificContainerModel(ContainerValueWrapper<AssignmentType> modelObject) {
if (ConstructionType.COMPLEX_TYPE.equals(AssignmentsUtil.getTargetType(modelObject.getContainerValue().getValue()))) {
ContainerWrapper<ConstructionType> constructionWrapper = modelObject.findContainerWrapper(ItemPath.create(modelObject.getPath(),
AssignmentType.F_CONSTRUCTION));

return Model.of(constructionWrapper);
}

if (PersonaConstructionType.COMPLEX_TYPE.equals(AssignmentsUtil.getTargetType(modelObject.getContainerValue().getValue()))) {
//TODO is it correct? findContainerWrapper by path F_PERSONA_CONSTRUCTION will return PersonaConstructionType
//but not PolicyRuleType
ContainerWrapper<PolicyRuleType> personasWrapper = modelObject.findContainerWrapper(ItemPath.create(modelObject.getPath(),
AssignmentType.F_PERSONA_CONSTRUCTION));

return Model.of(personasWrapper);
}
return Model.of();
}

@Override
protected ItemVisibility getAssignmentBasicTabVisibity(ItemWrapper itemWrapper, ItemPath parentAssignmentPath, ItemPath assignmentPath, PrismContainerValue<AssignmentType> prismContainerValue) {
if (itemWrapper.getPath().containsNameExactly(AssignmentType.F_CONSTRUCTION)) {
return ItemVisibility.AUTO;
} else {
return super.getAssignmentBasicTabVisibity(itemWrapper, parentAssignmentPath, assignmentPath, prismContainerValue);
}

}
}
Expand Up @@ -156,12 +156,6 @@ protected ObjectQuery createObjectQuery() {
.build();
}

@Override
protected IModel<ContainerWrapper> getSpecificContainerModel(ContainerValueWrapper<AssignmentType> modelObject) {
ContainerWrapper<PolicyRuleType> policyRuleWrapper = modelObject.findContainerWrapper(ItemPath.create(modelObject.getPath(), AssignmentType.F_POLICY_RULE));
return Model.of(policyRuleWrapper);
}

@Override
protected List<SearchItemDefinition> createSearchableItems(PrismContainerDefinition<AssignmentType> containerDef) {
List<SearchItemDefinition> defs = new ArrayList<>();
Expand Down
Expand Up @@ -363,6 +363,11 @@ protected boolean isNewObjectButtonVisible(PrismObject focusObject){
return false;
}

@Override
protected QName getAssignmentType() {
return AssignmentType.F_FOCUS_MAPPINGS;
}

};
assignmentPanel.setOutputMarkupId(true);
switchAssignmentTypePerformed(target, assignmentPanel, ID_FOCUS_MAPPING_ASSIGNMENTS);
Expand Down

0 comments on commit 683cdfc

Please sign in to comment.