Skip to content

Commit

Permalink
Merge branch 'master' into feature/simulations
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jan 12, 2023
2 parents 072542f + 75c8eec commit 28cbaa0
Show file tree
Hide file tree
Showing 53 changed files with 1,823 additions and 506 deletions.
13 changes: 7 additions & 6 deletions gui/admin-gui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,13 @@ public static <O extends ObjectType> List<O> loadReferencedObjectList(List<Objec
return loadedObjectsList;
}

public static ObjectFilter getShadowTypeFilterForAssociation(ConstructionType construction, String operation, PageBase pageBase) {
public static ObjectFilter getShadowTypeFilterForAssociation(
ConstructionType construction, String operation, PageBase pageBase) {
return getShadowTypeFilterForAssociation(construction, null, operation, pageBase);
}

public static ObjectFilter getShadowTypeFilterForAssociation(
ConstructionType construction, ItemName association, String operation, PageBase pageBase) {
PrismContext prismContext = pageBase.getPrismContext();
if (construction == null) {
return null;
Expand All @@ -408,6 +414,9 @@ public static ObjectFilter getShadowTypeFilterForAssociation(ConstructionType co
Collection<ResourceAssociationDefinition> resourceAssociationDefinitions = oc.getAssociationDefinitions();

for (ResourceAssociationDefinition resourceAssociationDefinition : resourceAssociationDefinitions) {
if (association != null && !resourceAssociationDefinition.getName().equivalent(association)) {
continue;
}
S_FilterEntryOrEmpty atomicFilter = prismContext.queryFor(ShadowType.class);
List<ObjectFilter> orFilterClauses = new ArrayList<>();
resourceAssociationDefinition.getIntents()
Expand Down Expand Up @@ -3601,6 +3610,38 @@ public static Collection<QName> loadResourceObjectClassValues(ResourceType resou
return new ArrayList<>();
}

public static List<ResourceAssociationDefinition> getRefinedAssociationDefinition(ConstructionType construction, PageBase pageBase) {
List<ResourceAssociationDefinition> associationDefinitions = new ArrayList<>();

PrismContext prismContext = pageBase.getPrismContext();
if (construction == null) {
return associationDefinitions;
}
PrismObject<ResourceType> resource = WebComponentUtil.getConstructionResource(construction, "load resource", pageBase);
if (resource == null) {
return associationDefinitions;
}

ObjectQuery query = prismContext.queryFactory().createQuery();
try {
ResourceSchema schema = ResourceSchemaFactory.getCompleteSchema(resource);
ResourceObjectDefinition oc = schema.findDefinitionForConstruction(construction);
if (oc == null) {
LOGGER.debug("Association for {} not supported by resource {}", construction, resource);
return null;
}
associationDefinitions.addAll(oc.getAssociationDefinitions());

if (CollectionUtils.isEmpty(associationDefinitions)) {
LOGGER.debug("Association for {} not supported by resource {}", construction, resource);
return associationDefinitions;
}
} catch (Exception ex) {
LOGGER.error("Association for {} not supported by resource {}: {}", construction, resource, ex.getLocalizedMessage());
}
return associationDefinitions;
}

public static List<ResourceAssociationDefinition> getRefinedAssociationDefinition(ResourceType resource, ShadowKindType kind, String intent) {
List<ResourceAssociationDefinition> associationDefinitions = new ArrayList<>();

Expand All @@ -3610,11 +3651,16 @@ public static List<ResourceAssociationDefinition> getRefinedAssociationDefinitio
return associationDefinitions;
}
ResourceSchema refinedResourceSchema = ResourceSchemaFactory.getCompleteSchema(resource.asPrismObject());
if (ShadowUtil.isNotKnown(kind) || ShadowUtil.isNotKnown(intent)) {
// TODO Is this OK? Please review this.
if (ShadowUtil.isNotKnown(kind)) {
return associationDefinitions;
}
ResourceObjectDefinition oc = refinedResourceSchema.findObjectDefinition(kind, intent);

ResourceObjectDefinition oc;
if (ShadowUtil.isNotKnown(intent)) {
oc = refinedResourceSchema.findDefaultDefinitionForKind(kind);
} else {
oc = refinedResourceSchema.findObjectDefinition(kind, intent);
}
if (oc == null) {
LOGGER.debug("Association for {}/{} not supported by resource {}", kind, intent, resource);
return associationDefinitions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ public ChoicesSearchItemPanel(String id, IModel<ChoicesSearchItemWrapper> search
@Override
protected Component initSearchItemField() {
return WebComponentUtil.createDropDownChoices(
ID_SEARCH_ITEM_FIELD, new PropertyModel(getModel(), ChoicesSearchItemWrapper.F_DISPLAYABLE_VALUE), Model.ofList(getModelObject().getAvailableValues()), true, getPageBase());
ID_SEARCH_ITEM_FIELD, new PropertyModel(getModel(), ChoicesSearchItemWrapper.F_DISPLAYABLE_VALUE), Model.ofList(getModelObject().getAvailableValues()), allowNull(), getPageBase());
}

private boolean allowNull() {
if (getModel() != null && getModelObject() != null) {
return getModelObject().allowNull();
}
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@ public ObjectFilter createFilter(Class type, PageBase pageBase, VariablesMap var
return PrismContext.get().queryFor(type)
.item(getPath()).eq(getValue().getValue()).buildFilter();
}

public boolean allowNull() {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!--
~ Copyright (c) 2010-2017 Evolveum
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<wicket:enclosure child="tilesContainer">
<div class="d-flex flex-column flex-grow-1">
<div wicket:id="tilesHeader"/>
<div class="card d-flex flex-column p-3 mb-0 mt-4" style="min-height: 5.4rem;" wicket:id="selectedItemsContainer">
<span>
<wicket:message key="SelectObjectClassesStepPanel.selectedItem"/>
</span>
<div class="d-inline-flex">
<wicket:container wicket:id="selectedItemContainer">
<div class="btn-sm btn-primary d-flex" style="cursor: auto;">
<div wicket:id="selectedItem"/>
<a wicket:id="deselectButton">
<i class="fa fa-xmark ml-2 text-white"></i>
</a>
</div>
</wicket:container>
</div>
</div>
<div class="row pt-3" wicket:id="tilesContainer">
<div wicket:id="tiles" style="min-height: 250px;">
<div wicket:id="tile"/>
</div>
</div>
<div class="d-flex" wicket:id="footerContainer">
<div class="d-flex">
<div wicket:id="buttonToolbar"/>
</div>
<div class="ml-auto align-self-end" wicket:id="tilesPaging"/>
</div>
</div>
</wicket:enclosure>

<div wicket:id="table"/>
</wicket:panel>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package com.evolveum.midpoint.gui.impl.component.tile;

import com.evolveum.midpoint.gui.impl.page.admin.resource.component.TemplateTile;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.data.SelectableBeanObjectDataProvider;
import com.evolveum.midpoint.web.component.util.SelectableBean;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;

import java.io.Serializable;
import java.util.List;

public abstract class MultiSelectTileTablePanel<E extends Serializable, O extends ObjectType> extends SingleSelectTileTablePanel<O> {

private static final String ID_SELECTED_ITEMS_CONTAINER = "selectedItemsContainer";
private static final String ID_SELECTED_ITEM_CONTAINER = "selectedItemContainer";
private static final String ID_SELECTED_ITEM = "selectedItem";
private static final String ID_DESELECT_BUTTON = "deselectButton";

public MultiSelectTileTablePanel(
String id,
UserProfileStorage.TableId tableId) {
super(id, tableId);
}

@Override
protected void onInitialize() {
super.onInitialize();
initLayout();
}

private void initLayout(){
WebMarkupContainer selectedItemsContainer = new WebMarkupContainer(ID_SELECTED_ITEMS_CONTAINER);
selectedItemsContainer.setOutputMarkupId(true);
add(selectedItemsContainer);

ListView<E> selectedContainer = new ListView<>(
ID_SELECTED_ITEM_CONTAINER,
getSelectedItemsModel()) {

@Override
protected void populateItem(ListItem<E> item) {
E entry = item.getModelObject();

item.add(new Label(ID_SELECTED_ITEM, getItemLabelModel(entry)));
AjaxButton deselectButton = new AjaxButton(ID_DESELECT_BUTTON) {
@Override
public void onClick(AjaxRequestTarget target) {
deselectItem(entry);
refresh(target);
}
};
item.add(deselectButton);
}
};
selectedContainer.setOutputMarkupId(true);
selectedItemsContainer.add(selectedContainer);
}

@Override
public void refresh(AjaxRequestTarget target) {
super.refresh(target);
target.add(get(ID_SELECTED_ITEMS_CONTAINER));
}

protected abstract void deselectItem(E entry);

protected abstract IModel<String> getItemLabelModel(E entry);

protected abstract IModel<List<E>> getSelectedItemsModel();

@Override
public SelectableBeanObjectDataProvider<O> getProvider() {
return (SelectableBeanObjectDataProvider<O>) super.getProvider();
}

@Override
protected Component createTile(String id, IModel<TemplateTile<SelectableBean<O>>> model) {

return new SelectableFocusTilePanel<>(id, model) {
@Override
protected void onClick(AjaxRequestTarget target) {
super.onClick(target);
getModelObject().getValue().setSelected(getModelObject().isSelected());

processSelectOrDeselectItem(getModelObject());
target.add(MultiSelectTileTablePanel.this.get(ID_SELECTED_ITEMS_CONTAINER));
}
};
}

protected void processSelectOrDeselectItem(TemplateTile<SelectableBean<O>> tile) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright (c) 2022 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.component.tile;

import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.impl.page.admin.resource.component.TemplateTile;
import com.evolveum.midpoint.web.component.util.SelectableBean;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

import org.apache.wicket.ajax.AjaxEventBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.model.IModel;
import org.apache.wicket.request.resource.IResource;

/**
* @author lskublik
*/
public class SelectableFocusTilePanel<O extends ObjectType> extends FocusTilePanel<SelectableBean<O>, TemplateTile<SelectableBean<O>>> {

public SelectableFocusTilePanel(String id, IModel<TemplateTile<SelectableBean<O>>> model) {
super(id, model);
}

@Override
protected void initLayout() {
super.initLayout();

add(new AjaxEventBehavior("click") {
@Override
protected void onEvent(AjaxRequestTarget target) {
onClick(target);
}
});

add(AttributeAppender.append("class", "card catalog-tile-panel d-flex flex-column align-items-center bordered p-3 h-100 mb-0 selectable"));
add(AttributeAppender.append("class", () -> getModelObject().isSelected() ? "active" : null));
}

@Override
protected Behavior createDetailsBehaviour() {
return VisibleBehaviour.ALWAYS_INVISIBLE;
}

@Override
protected IModel<IResource> createPreferredImage(IModel<TemplateTile<SelectableBean<O>>> model) {
return new LoadableModel<>(false) {
@Override
protected IResource load() {
O object = model.getObject().getValue().getValue();
if (object instanceof FocusType) {
return WebComponentUtil.createJpegPhotoResource((FocusType) object);
}
return null;
}
};
}
}

0 comments on commit 28cbaa0

Please sign in to comment.