-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix for choices for object class and intent on schema handling panel …
…(MID-7274)
- Loading branch information
Showing
7 changed files
with
276 additions
and
138 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
78 changes: 78 additions & 0 deletions
78
...gui/src/main/java/com/evolveum/midpoint/gui/impl/factory/panel/AbstractIntentFactory.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,78 @@ | ||
/* | ||
* 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.gui.impl.factory.panel; | ||
|
||
import com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel; | ||
import com.evolveum.midpoint.gui.api.prism.wrapper.*; | ||
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.PrismPropertyValue; | ||
import com.evolveum.midpoint.prism.PrismReferenceValue; | ||
import com.evolveum.midpoint.prism.Referencable; | ||
import com.evolveum.midpoint.prism.path.ItemPath; | ||
import com.evolveum.midpoint.task.api.Task; | ||
import com.evolveum.midpoint.util.exception.SchemaException; | ||
import com.evolveum.midpoint.web.component.prism.InputPanel; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.*; | ||
|
||
import org.apache.wicket.extensions.ajax.markup.html.autocomplete.StringAutoCompleteRenderer; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.annotation.PostConstruct; | ||
import java.io.Serializable; | ||
import java.util.Collections; | ||
import java.util.Iterator; | ||
|
||
//FIXME serializable? | ||
@Component | ||
public abstract class AbstractIntentFactory extends AbstractInputGuiComponentFactory<String> implements Serializable { | ||
|
||
@Override | ||
protected InputPanel getPanel(PrismPropertyPanelContext<String> panelCtx) { | ||
return new AutoCompleteTextPanel<String>(panelCtx.getComponentId(), panelCtx.getRealValueModel(), String.class, StringAutoCompleteRenderer.INSTANCE) { | ||
|
||
@Override | ||
public Iterator<String> getIterator(String input) { | ||
PrismPropertyWrapper<String> itemWrapper = panelCtx.unwrapWrapperModel(); | ||
PrismObject<ResourceType> resourceType = WebComponentUtil.findResource(itemWrapper, panelCtx); | ||
|
||
if (resourceType == null) { | ||
return Collections.emptyIterator(); | ||
} | ||
|
||
PrismPropertyValue<ShadowKindType> kindPropValue = findKind(itemWrapper); | ||
if (kindPropValue == null) { | ||
return Collections.emptyIterator(); | ||
} | ||
return WebComponentUtil.getIntensForKind(resourceType, kindPropValue.getRealValue(), panelCtx.getPageBase()).iterator(); | ||
} | ||
}; | ||
} | ||
|
||
private PrismPropertyValue<ShadowKindType> findKind(PrismPropertyWrapper<String> itemWrapper) { | ||
PrismContainerValueWrapper<?> parent = itemWrapper.getParent(); | ||
if (parent == null) { | ||
return null; | ||
} | ||
try { | ||
PrismPropertyWrapper<ShadowKindType> kindWrapper = parent.findProperty(ResourceObjectSetType.F_KIND); | ||
if (kindWrapper == null) { | ||
return null; | ||
} | ||
|
||
return kindWrapper.getValue().getNewValue(); | ||
} catch (SchemaException e) { | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public Integer getOrder() { | ||
return 100; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...rc/main/java/com/evolveum/midpoint/gui/impl/factory/panel/AbstractObjectClassFactory.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,50 @@ | ||
/* | ||
* 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.gui.impl.factory.panel; | ||
|
||
import com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteQNamePanel; | ||
import com.evolveum.midpoint.gui.api.prism.wrapper.*; | ||
import com.evolveum.midpoint.gui.api.util.WebComponentUtil; | ||
import com.evolveum.midpoint.prism.PrismObject; | ||
import com.evolveum.midpoint.web.component.prism.InputPanel; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.*; | ||
|
||
import javax.xml.namespace.QName; | ||
import java.io.Serializable; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
//FIXME serializable | ||
public abstract class AbstractObjectClassFactory extends AbstractInputGuiComponentFactory<QName> implements Serializable { | ||
|
||
@Override | ||
protected InputPanel getPanel(PrismPropertyPanelContext<QName> panelCtx) { | ||
return new AutoCompleteQNamePanel<>(panelCtx.getComponentId(), panelCtx.getRealValueModel()) { | ||
|
||
@Override | ||
public Collection<QName> loadChoices() { | ||
PrismPropertyWrapper<QName> itemWrapper = panelCtx.unwrapWrapperModel(); | ||
PrismObject<ResourceType> resourceType = WebComponentUtil.findResource(itemWrapper, panelCtx); | ||
|
||
if (resourceType == null) { | ||
return Collections.emptyList(); | ||
} | ||
return WebComponentUtil.loadResourceObjectClassValues(resourceType.asObjectable(), panelCtx.getPageBase()); | ||
} | ||
|
||
@Override | ||
protected boolean alwaysReload() { | ||
return true; | ||
} | ||
}; | ||
} | ||
|
||
@Override | ||
public Integer getOrder() { | ||
return 10000 - 10; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...gui/src/main/java/com/evolveum/midpoint/gui/impl/factory/panel/ResourceIntentFactory.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,52 @@ | ||
/* | ||
* 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.gui.impl.factory.panel; | ||
|
||
import com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel; | ||
import com.evolveum.midpoint.gui.api.prism.wrapper.*; | ||
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.PrismPropertyValue; | ||
import com.evolveum.midpoint.prism.PrismReferenceValue; | ||
import com.evolveum.midpoint.prism.Referencable; | ||
import com.evolveum.midpoint.prism.path.ItemPath; | ||
import com.evolveum.midpoint.task.api.Task; | ||
import com.evolveum.midpoint.util.exception.SchemaException; | ||
import com.evolveum.midpoint.web.component.prism.InputPanel; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.*; | ||
|
||
import org.apache.wicket.extensions.ajax.markup.html.autocomplete.StringAutoCompleteRenderer; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.annotation.PostConstruct; | ||
import java.io.Serializable; | ||
import java.util.Collections; | ||
import java.util.Iterator; | ||
|
||
@Component | ||
public class ResourceIntentFactory extends AbstractIntentFactory { | ||
|
||
@PostConstruct | ||
public void register() { | ||
getRegistry().addToRegistry(this); | ||
} | ||
|
||
@Override | ||
public <IW extends ItemWrapper<?, ?>> boolean match(IW wrapper) { | ||
PrismObjectWrapper<?> objectWrapper = wrapper.findObjectWrapper(); | ||
if (objectWrapper == null) { | ||
return false; | ||
} | ||
|
||
ObjectType object = objectWrapper.getObject().asObjectable(); | ||
if (!(object instanceof ResourceType)) { | ||
return false; | ||
} | ||
return wrapper.getPath().lastName().equivalent(ResourceObjectTypeDefinitionType.F_INTENT); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...rc/main/java/com/evolveum/midpoint/gui/impl/factory/panel/ResourceObjectClassFactory.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,48 @@ | ||
/* | ||
* 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.gui.impl.factory.panel; | ||
|
||
import com.evolveum.midpoint.gui.api.prism.wrapper.*; | ||
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.PrismReferenceValue; | ||
import com.evolveum.midpoint.prism.Referencable; | ||
import com.evolveum.midpoint.prism.path.ItemPath; | ||
import com.evolveum.midpoint.task.api.Task; | ||
import com.evolveum.midpoint.util.exception.SchemaException; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.*; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.xml.namespace.QName; | ||
import java.io.Serializable; | ||
|
||
@Component | ||
public class ResourceObjectClassFactory extends AbstractObjectClassFactory { | ||
|
||
@PostConstruct | ||
public void register() { | ||
getRegistry().addToRegistry(this); | ||
} | ||
|
||
|
||
@Override | ||
public <IW extends ItemWrapper<?, ?>> boolean match(IW wrapper) { | ||
PrismObjectWrapper<?> objectWrapper = wrapper.findObjectWrapper(); | ||
if (objectWrapper == null) { | ||
return false; | ||
} | ||
|
||
ObjectType object = objectWrapper.getObject().asObjectable(); | ||
if (!(object instanceof ResourceType)) { | ||
return false; | ||
} | ||
return wrapper.getPath().lastName().equivalent(ResourceObjectTypeDefinitionType.F_OBJECT_CLASS); | ||
} | ||
} |
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.