use of com.evolveum.midpoint.prism.PrismContainerDefinition in project midpoint by Evolveum.
the class ListContainersPopup method initLayout.
private void initLayout() {
IModel<List<ContainersPopupDto>> popupModel = new LoadableModel<>(false) {
private static final long serialVersionUID = 1L;
@Override
protected List<ContainersPopupDto> load() {
List<PrismContainerDefinition<C>> defs;
try {
defs = getModelObject().getChildContainers();
} catch (SchemaException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Cannot get children containers for {}, reason {}", e, getModelObject(), e.getMessage());
getSession().error("ListContainersPopup.children.list.failed");
defs = new ArrayList<>();
}
List<ContainersPopupDto> modelObject = defs.stream().filter(def -> def.isExperimental() ? WebModelServiceUtils.isEnableExperimentalFeature(getPageBase()) : true).map(def -> createContainersPopupDto(def)).collect(Collectors.toList());
return modelObject;
}
};
ListView<ContainersPopupDto> listView = new ListView<ContainersPopupDto>(ID_CONTAINERS, popupModel) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<ContainersPopupDto> item) {
CheckFormGroup checkFormGroup = new CheckFormGroup(ID_SELECTED, new PropertyModel<>(item.getModel(), "selected"), new StringResourceModel("ListContainersPopup.selected"), "col-md-2", "col-md-10") {
protected boolean getLabelVisible() {
return false;
}
};
checkFormGroup.getCheck().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
checkFormGroup.add(AttributeAppender.append("class", " checkbox-without-margin-bottom "));
checkFormGroup.setOutputMarkupId(true);
item.add(checkFormGroup);
String displayNameKey = item.getModelObject() != null ? item.getModelObject().getDisplayName() : "";
Label definition = new Label(ID_DEFINITION, new StringResourceModel(displayNameKey));
definition.setOutputMarkupId(true);
item.add(definition);
}
};
listView.setOutputMarkupId(true);
listView.setReuseItems(true);
add(listView);
AjaxButton select = new AjaxButton(ID_SELECT, new StringResourceModel("ListContainerPopup.select")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
getPageBase().hideMainPopup(target);
ListView<ContainersPopupDto> listView = (ListView<ContainersPopupDto>) ListContainersPopup.this.get(ID_CONTAINERS);
List<PrismContainerDefinition<?>> selected = new ArrayList<>();
listView.getModelObject().forEach(child -> {
if (child.isSelected()) {
selected.add(child.getDef());
}
});
processSelectedChildren(target, selected);
}
};
select.setOutputMarkupId(true);
add(select);
AjaxButton cancel = new AjaxButton(ID_BUTTON_CANCEL, createStringResource("PageBase.button.cancel")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
getPageBase().hideMainPopup(target);
}
};
add(cancel);
}
use of com.evolveum.midpoint.prism.PrismContainerDefinition in project midpoint by Evolveum.
the class PrismValueMetadataPanel method createMetadataListModel.
private ReadOnlyModel<List<ContainersPopupDto>> createMetadataListModel() {
return new ReadOnlyModel<>(() -> {
ValueMetadataWrapperImpl metadataWrapper = getValueMetadata();
List<PrismContainerDefinition<? extends Containerable>> childContainers;
try {
childContainers = metadataWrapper != null ? metadataWrapper.getChildContainers() : Collections.emptyList();
} catch (SchemaException e) {
LOGGER.error("Cannot get child containers: {}", e.getMessage(), e);
childContainers = Collections.emptyList();
}
List<ContainersPopupDto> navigation = childContainers.stream().map(c -> new ContainersPopupDto(false, c)).collect(Collectors.toList());
List<? extends ItemDefinition> childNonContainers = metadataWrapper != null ? metadataWrapper.getChildNonContainers() : Collections.emptyList();
if (!childNonContainers.isEmpty()) {
navigation.add(new ContainersPopupDto(false, metadataWrapper));
}
return navigation;
});
}
use of com.evolveum.midpoint.prism.PrismContainerDefinition in project midpoint by Evolveum.
the class ItemPathPanel method initLayout.
private void initLayout() {
ItemPathSegmentPanel itemDefPanel = new ItemPathSegmentPanel(ID_DEFINITION, new AbstractReadOnlyModel<ItemPathDto>() {
private static final long serialVersionUID = 1L;
public ItemPathDto getObject() {
return ItemPathPanel.this.getModelObject();
}
}) {
private static final long serialVersionUID = 1L;
@Override
protected Map<QName, Collection<ItemDefinition<?>>> getSchemaDefinitionMap() {
return initNamspaceDefinitionMap();
}
};
itemDefPanel.setOutputMarkupId(true);
add(itemDefPanel);
AjaxButton plusButton = new AjaxButton(ID_PLUS) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
refreshItemPathPanel(new ItemPathDto(ItemPathPanel.this.getModelObject()), true, target);
}
};
plusButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
if (getModelObject().getParentPath() == null || getModelObject().getParentPath().toItemPath() == null) {
return true;
}
return (getModelObject().getParentPath().getItemDef() instanceof PrismContainerDefinition);
}
});
plusButton.setOutputMarkupId(true);
add(plusButton);
AjaxButton minusButton = new AjaxButton(ID_MINUS) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
ItemPathDto path = ItemPathPanel.this.getModelObject();
// ItemPathDto parent = null;
// if (path.getItemDef() == null){
// parent = path.getParentPath();
// } else {
// parent = path;
// }
refreshItemPathPanel(path, false, target);
}
};
minusButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getModelObject().getParentPath() != null && getModelObject().getParentPath().toItemPath() != null;
}
});
minusButton.setOutputMarkupId(true);
add(minusButton);
DropDownChoicePanel<QName> namespacePanel = new DropDownChoicePanel<QName>(ID_NAMESPACE, new PropertyModel<QName>(getModel(), "objectType"), new ListModel<QName>(WebComponentUtil.createObjectTypeList()), new QNameChoiceRenderer());
namespacePanel.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
refreshItemPath(ItemPathPanel.this.getModelObject(), target);
}
});
namespacePanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getModelObject().getParentPath() == null || getModelObject().getParentPath().toItemPath() == null;
}
});
namespacePanel.setOutputMarkupId(true);
add(namespacePanel);
}
use of com.evolveum.midpoint.prism.PrismContainerDefinition in project midpoint by Evolveum.
the class TaskQuartzImpl method setExtensionContainerValue.
// use this method to avoid cloning the value
@Override
public <T extends Containerable> void setExtensionContainerValue(QName containerName, T value) throws SchemaException {
PrismContainerDefinition containerDef = getPrismContext().getSchemaRegistry().findContainerDefinitionByElementName(containerName);
if (containerDef == null) {
throw new SchemaException("Unknown container item " + containerName);
}
ArrayList<PrismContainerValue<T>> values = new ArrayList(1);
values.add(value.asPrismContainerValue());
processModificationBatched(setExtensionContainerAndPrepareDelta(containerName, containerDef, values));
}
use of com.evolveum.midpoint.prism.PrismContainerDefinition in project midpoint by Evolveum.
the class Construction method evaluateAssociation.
private Mapping<PrismContainerValue<ShadowAssociationType>, PrismContainerDefinition<ShadowAssociationType>> evaluateAssociation(ResourceObjectAssociationType associationDefinitionType, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException {
QName assocName = ItemPathUtil.getOnlySegmentQName(associationDefinitionType.getRef());
if (assocName == null) {
throw new SchemaException("Missing 'ref' in association in construction in " + getSource());
}
MappingType outboundMappingType = associationDefinitionType.getOutbound();
if (outboundMappingType == null) {
throw new SchemaException("No outbound section in definition of association " + assocName + " in construction in " + getSource());
}
PrismContainerDefinition<ShadowAssociationType> outputDefinition = getAssociationContainerDefinition();
Mapping.Builder<PrismContainerValue<ShadowAssociationType>, PrismContainerDefinition<ShadowAssociationType>> mappingBuilder = mappingFactory.<PrismContainerValue<ShadowAssociationType>, PrismContainerDefinition<ShadowAssociationType>>createMappingBuilder().mappingType(outboundMappingType).contextDescription("for association " + PrettyPrinter.prettyPrint(assocName) + " in " + getSource()).originType(OriginType.ASSIGNMENTS).originObject(getSource());
RefinedAssociationDefinition rAssocDef = refinedObjectClassDefinition.findAssociationDefinition(assocName);
if (rAssocDef == null) {
throw new SchemaException("No association " + assocName + " in object class " + refinedObjectClassDefinition.getHumanReadableName() + " in construction in " + getSource());
}
Mapping<PrismContainerValue<ShadowAssociationType>, PrismContainerDefinition<ShadowAssociationType>> evaluatedMapping = evaluateMapping(mappingBuilder, assocName, outputDefinition, rAssocDef.getAssociationTarget(), task, result);
LOGGER.trace("Evaluated mapping for association " + assocName + ": " + evaluatedMapping);
return evaluatedMapping;
}
Aggregations