use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDefinitionType in project midpoint by Evolveum.
the class PageCertDefinitions method initColumns.
private List<IColumn<SelectableBean<AccessCertificationDefinitionType>, String>> initColumns() {
List<IColumn<SelectableBean<AccessCertificationDefinitionType>, String>> columns = new ArrayList<>();
IColumn column;
column = new PropertyColumn(createStringResource("PageCertDefinitions.table.description"), "value.description");
columns.add(column);
column = new MultiButtonColumn<SelectableBean<AccessCertificationDefinitionType>>(new Model(), 3) {
private final String[] captionKeys = { "PageCertDefinitions.button.createCampaign", "PageCertDefinitions.button.showCampaigns", "PageCertDefinitions.button.deleteDefinition" };
private final DoubleButtonColumn.BUTTON_COLOR_CLASS[] colors = { DoubleButtonColumn.BUTTON_COLOR_CLASS.PRIMARY, DoubleButtonColumn.BUTTON_COLOR_CLASS.DEFAULT, DoubleButtonColumn.BUTTON_COLOR_CLASS.DANGER };
@Override
public String getCaption(int id) {
return PageCertDefinitions.this.createStringResource(captionKeys[id]).getString();
}
@Override
public String getButtonColorCssClass(int id) {
return colors[id].toString();
}
@Override
public void clickPerformed(int id, AjaxRequestTarget target, IModel<SelectableBean<AccessCertificationDefinitionType>> model) {
switch(id) {
case 0:
createCampaignPerformed(target, model.getObject().getValue());
break;
case 1:
showCampaignsPerformed(target, model.getObject().getValue());
break;
case 2:
deleteConfirmation(target, model.getObject().getValue());
break;
}
}
};
columns.add(column);
return columns;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDefinitionType in project midpoint by Evolveum.
the class PageCertDefinitions method initLayout.
private void initLayout() {
Form mainForm = new Form(ID_MAIN_FORM);
add(mainForm);
MainObjectListPanel<AccessCertificationDefinitionType> mainPanel = new MainObjectListPanel<AccessCertificationDefinitionType>(ID_TABLE, AccessCertificationDefinitionType.class, TableId.PAGE_CERT_DEFINITIONS_PANEL, null, this) {
private static final long serialVersionUID = 1L;
@Override
protected IColumn<SelectableBean<AccessCertificationDefinitionType>, String> createCheckboxColumn() {
return null;
}
@Override
public void objectDetailsPerformed(AjaxRequestTarget target, AccessCertificationDefinitionType service) {
PageCertDefinitions.this.detailsPerformed(target, service);
}
@Override
protected List<IColumn<SelectableBean<AccessCertificationDefinitionType>, String>> createColumns() {
return PageCertDefinitions.this.initColumns();
}
@Override
protected List<InlineMenuItem> createInlineMenu() {
return null;
}
@Override
protected void newObjectPerformed(AjaxRequestTarget target) {
navigateToNext(PageCertDefinition.class);
}
};
mainPanel.setAdditionalBoxCssClasses(GuiStyleConstants.CLASS_OBJECT_CERT_DEF_BOX_CSS_CLASSES);
mainForm.add(mainPanel);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDefinitionType in project midpoint by Evolveum.
the class RAccessCertificationDefinition method toJAXB.
@Override
public AccessCertificationDefinitionType toJAXB(PrismContext prismContext, Collection<SelectorOptions<GetOperationOptions>> options) throws DtoTranslationException {
AccessCertificationDefinitionType object = new AccessCertificationDefinitionType();
RUtil.revive(object, prismContext);
RAccessCertificationDefinition.copyToJAXB(this, object, prismContext, options);
return object;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDefinitionType in project midpoint by Evolveum.
the class ReportFunctions method searchCertificationDefinitions.
// TODO implement if needed
// <O extends Containerable> RefFilter createReferenceEqualFilter(QName propertyName, Class<O> type, String... oids) {
// return RefFilter.createReferenceEqual(propertyName, type, prismContext, oids);
// }
// <O extends Containerable> RefFilter createReferenceEqualFilter(ItemPath propertyPath, Class<O> type, String... oids) throws SchemaException {
// return RefFilter.createReferenceEqual(propertyPath, type, prismContext, oids);
// }
// Object parseObjectFromXML (String xml) throws SchemaException {
// return prismContext.parserFor(xml).xml().parseAnyData();
// }
/**
* Retrieves all definitions.
* Augments them by count of campaigns (all + open ones).
*
* TODO query parameters, customizable sorting
* definitions and campaigns counts are expected to be low, so we can afford to go through all of them here
*/
public Collection<PrismObject<AccessCertificationDefinitionForReportType>> searchCertificationDefinitions() throws ConfigurationException, SchemaException, ObjectNotFoundException, CommunicationException, SecurityViolationException, ExpressionEvaluationException {
Task task = taskManager.createTaskInstance();
OperationResult result = task.getResult();
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createResolveNames());
List<PrismObject<AccessCertificationDefinitionType>> definitions = model.searchObjects(AccessCertificationDefinitionType.class, null, options, task, result);
final Map<String, PrismObject<AccessCertificationDefinitionForReportType>> definitionsForReportMap = new HashMap<>();
for (PrismObject<AccessCertificationDefinitionType> definition : definitions) {
// create subclass with the values copied from the superclass
PrismObject<AccessCertificationDefinitionForReportType> definitionForReport = prismContext.createObjectable(AccessCertificationDefinitionForReportType.class).asPrismObject();
for (Item<?, ?> item : definition.getValue().getItems()) {
definitionForReport.getValue().add(item.clone());
}
definitionsForReportMap.put(definition.getOid(), definitionForReport);
}
ResultHandler<AccessCertificationCampaignType> handler = (campaignObject, parentResult) -> {
AccessCertificationCampaignType campaign = campaignObject.asObjectable();
if (campaign.getDefinitionRef() != null) {
String definitionOid = campaign.getDefinitionRef().getOid();
PrismObject<AccessCertificationDefinitionForReportType> definitionObject = definitionsForReportMap.get(definitionOid);
if (definitionObject != null) {
AccessCertificationDefinitionForReportType definition = definitionObject.asObjectable();
int campaigns = definition.getCampaigns() != null ? definition.getCampaigns() : 0;
definition.setCampaigns(campaigns + 1);
AccessCertificationCampaignStateType state = campaign.getState();
if (state != AccessCertificationCampaignStateType.CREATED && state != CLOSED) {
int openCampaigns = definition.getOpenCampaigns() != null ? definition.getOpenCampaigns() : 0;
definition.setOpenCampaigns(openCampaigns + 1);
}
}
}
return true;
};
model.searchObjectsIterative(AccessCertificationCampaignType.class, null, handler, null, task, result);
List<PrismObject<AccessCertificationDefinitionForReportType>> rv = new ArrayList<>(definitionsForReportMap.values());
Collections.sort(rv, (o1, o2) -> {
String n1 = o1.asObjectable().getName().getOrig();
String n2 = o2.asObjectable().getName().getOrig();
if (n1 == null) {
n1 = "";
}
return n1.compareTo(n2);
});
for (PrismObject<AccessCertificationDefinitionForReportType> defObject : rv) {
AccessCertificationDefinitionForReportType def = defObject.asObjectable();
if (def.getCampaigns() == null) {
def.setCampaigns(0);
}
if (def.getOpenCampaigns() == null) {
def.setOpenCampaigns(0);
}
}
return rv;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDefinitionType in project midpoint by Evolveum.
the class PageCertCampaigns method createPageTitleModel.
// endregion
// region Layout
@Override
protected IModel<String> createPageTitleModel() {
return new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
if (definitionOid == null) {
return createStringResource("PageCertCampaigns.title", "").getString();
}
Task task = createSimpleTask("dummy");
PrismObject<AccessCertificationDefinitionType> definitionPrismObject = WebModelServiceUtils.loadObject(AccessCertificationDefinitionType.class, definitionOid, PageCertCampaigns.this, task, task.getResult());
String name = definitionPrismObject == null ? "" : WebComponentUtil.getName(definitionPrismObject);
return createStringResource("PageCertCampaigns.title", name).getString();
}
};
}
Aggregations