Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding implementation of default search item panels for debug page
- Loading branch information
Showing
15 changed files
with
247 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
...n-gui/src/main/java/com/evolveum/midpoint/web/component/search/ObjectClassSearchItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* Copyright (c) 2010-2020 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.midpoint.web.component.search; | ||
|
||
import javax.xml.namespace.QName; | ||
|
||
import com.evolveum.midpoint.gui.api.page.PageBase; | ||
import com.evolveum.midpoint.gui.api.util.WebComponentUtil; | ||
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils; | ||
import com.evolveum.midpoint.prism.PrismObject; | ||
import com.evolveum.midpoint.prism.Referencable; | ||
import com.evolveum.midpoint.task.api.Task; | ||
import com.evolveum.midpoint.util.DisplayableValue; | ||
|
||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* @author skublik | ||
*/ | ||
public class ObjectClassSearchItem extends PropertySearchItem { | ||
|
||
private static final long serialVersionUID = 1L; | ||
private String lastResourceOid; | ||
|
||
public ObjectClassSearchItem(Search search, SearchItemDefinition definition) { | ||
super(search, definition); | ||
} | ||
|
||
@Override | ||
public List<DisplayableValue> getAllowedValues(PageBase pageBase) { | ||
List<DisplayableValue> list = new ArrayList<>(); | ||
for (PropertySearchItem property : getSearch().getPropertyItems()) { | ||
if (ShadowType.F_RESOURCE_REF.equivalent(property.getPath()) | ||
&& property.getValue() != null && property.getValue().getValue() != null) { | ||
Referencable ref = (Referencable) property.getValue().getValue(); | ||
Task task = pageBase.createSimpleTask("load resource"); | ||
if (StringUtils.isNotBlank(ref.getOid())) { | ||
PrismObject<ResourceType> resource = WebModelServiceUtils.loadObject(ref, pageBase, | ||
task, task.getResult()); | ||
if (resource != null) { | ||
lastResourceOid = resource.getOid(); | ||
List<QName> objectClasses = WebComponentUtil.loadResourceObjectClassValues(resource.asObjectable(), pageBase); | ||
for (QName objectClass : objectClasses) { | ||
list.add(new SearchValue(objectClass, pageBase.createStringResource(objectClass.getLocalPart()).getString())); | ||
} | ||
} | ||
break; | ||
} | ||
} | ||
|
||
} | ||
return list; | ||
} | ||
|
||
@Override | ||
public Type getType() { | ||
return Type.ENUM; | ||
} | ||
|
||
@Override | ||
public DisplayableValue getValue() { | ||
for (PropertySearchItem property : getSearch().getPropertyItems()) { | ||
if (ShadowType.F_RESOURCE_REF.equivalent(property.getPath()) | ||
&& property.getValue() != null && property.getValue().getValue() != null) { | ||
Referencable ref = (Referencable) property.getValue().getValue(); | ||
if (StringUtils.isNotBlank(ref.getOid()) | ||
&& ref.getOid().equals(lastResourceOid)) { | ||
return super.getValue(); | ||
} | ||
break; | ||
} | ||
|
||
} | ||
return new SearchValue<>(); | ||
} | ||
|
||
@Override | ||
protected String getTitle(PageBase pageBase) { | ||
for (PropertySearchItem property : getSearch().getPropertyItems()) { | ||
if (ShadowType.F_RESOURCE_REF.equivalent(property.getPath()) | ||
&& property.getValue() != null && property.getValue().getValue() != null) { | ||
Referencable ref = (Referencable) property.getValue().getValue(); | ||
if (StringUtils.isNotBlank(ref.getOid())) { | ||
return super.getTitle(pageBase); | ||
} | ||
} | ||
} | ||
return pageBase.createStringResource("ObjectClassSearchItem.notFoundResourceItemSearchPanel").getString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.