use of com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto in project midpoint by Evolveum.
the class PageCertCampaigns method initLayout.
private void initLayout() {
Form mainForm = new MidpointForm(ID_MAIN_FORM);
add(mainForm);
CertCampaignListItemDtoProvider provider = createProvider();
provider.setQuery(createCampaignsQuery());
BoxedTablePanel<CertCampaignListItemDto> table = new BoxedTablePanel<CertCampaignListItemDto>(ID_CAMPAIGNS_TABLE, provider, initColumns(), UserProfileStorage.TableId.PAGE_CERT_CAMPAIGNS_PANEL) {
@Override
protected WebMarkupContainer createHeader(String headerId) {
return new SearchFragment(headerId, ID_TABLE_HEADER, PageCertCampaigns.this, searchModel);
}
};
table.setShowPaging(true);
table.setOutputMarkupId(true);
mainForm.add(table);
}
use of com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto in project midpoint by Evolveum.
the class PageCertCampaigns method actOnCampaignsPerformed.
private void actOnCampaignsPerformed(AjaxRequestTarget target, String operationName, List<CertCampaignListItemDto> items) {
int processed = 0;
AccessCertificationService acs = getCertificationService();
OperationResult result = new OperationResult(operationName);
for (CertCampaignListItemDto item : items) {
try {
AccessCertificationCampaignType campaign = item.getCampaign();
Task task = createSimpleTask(operationName);
if (OPERATION_START_CAMPAIGN.equals(operationName)) {
if (campaign.getState() == AccessCertificationCampaignStateType.CREATED) {
acs.openNextStage(campaign.getOid(), task, result);
processed++;
}
} else if (OPERATION_CLOSE_CAMPAIGN.equals(operationName)) {
if (campaign.getState() != AccessCertificationCampaignStateType.CLOSED) {
acs.closeCampaign(campaign.getOid(), task, result);
processed++;
}
} else if (OPERATION_REITERATE_CAMPAIGN.equals(operationName)) {
if (item.isReiterable()) {
acs.reiterateCampaign(campaign.getOid(), task, result);
processed++;
}
} else {
throw new IllegalStateException("Unknown action: " + operationName);
}
} catch (Exception ex) {
result.recordPartialError(createStringResource("PageCertCampaigns.message.actOnCampaignsPerformed.partialError").getString(), ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't process campaign", ex);
}
}
if (processed == 0) {
warn(getString("PageCertCampaigns.message.noCampaignsSelected"));
target.add(getFeedbackPanel());
return;
}
result.recomputeStatus();
if (result.isSuccess()) {
result.recordStatus(OperationResultStatus.SUCCESS, createStringResource("PageCertCampaigns.message.actOnCampaignsPerformed.success", processed).getString());
}
WebComponentUtil.safeResultCleanup(result, LOGGER);
showResult(result);
target.add(getFeedbackPanel(), (Component) getCampaignsTable());
}
use of com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto in project midpoint by Evolveum.
the class PageCertCampaigns method createInlineMenuForItem.
private List<InlineMenuItem> createInlineMenuForItem() {
List<InlineMenuItem> menuItems = new ArrayList<>();
InlineMenuItem item = new InlineMenuItem(createStringResource("PageCertCampaigns.menu.close")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<CertCampaignListItemDto>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
closeCampaignConfirmation(target, getRowModel().getObject());
}
};
}
@Override
public boolean isHeaderMenuItem() {
return false;
}
};
item.setVisibilityChecker((rowModel, header) -> isNotClosed(rowModel));
menuItems.add(item);
item = new InlineMenuItem(createStringResource("PageCertCampaigns.menu.reiterate")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<CertCampaignListItemDto>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
reiterateCampaignConfirmation(target, getRowModel().getObject());
}
};
}
@Override
public boolean isHeaderMenuItem() {
return false;
}
};
item.setVisibilityChecker((rowModel, header) -> isReiterable(rowModel));
menuItems.add(item);
menuItems.add(new InlineMenuItem(createStringResource("PageCertCampaigns.menu.delete")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<CertCampaignListItemDto>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
deleteCampaignConfirmation(target, getRowModel().getObject());
}
};
}
@Override
public boolean isHeaderMenuItem() {
return false;
}
});
return menuItems;
}
use of com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto in project midpoint by Evolveum.
the class PageCertCampaigns method initColumns.
private List<IColumn<CertCampaignListItemDto, String>> initColumns() {
List<IColumn<CertCampaignListItemDto, String>> columns = new ArrayList<>();
IColumn column;
column = new CheckBoxHeaderColumn<>();
columns.add(column);
column = new LinkColumn<CertCampaignListItemDto>(createStringResource("PageCertCampaigns.table.name"), AccessCertificationCampaignType.F_NAME.getLocalPart(), CertCampaignListItemDto.F_NAME) {
@Override
public void onClick(AjaxRequestTarget target, IModel<CertCampaignListItemDto> rowModel) {
campaignDetailsPerformed(target, rowModel.getObject().getOid());
}
};
columns.add(column);
column = new PropertyColumn(createStringResource("PageCertCampaigns.table.description"), CertCampaignListItemDto.F_DESCRIPTION);
columns.add(column);
column = new EnumPropertyColumn(createStringResource("PageCertCampaigns.table.state"), CertCampaignListItemDto.F_STATE) {
@Override
protected String translate(Enum en) {
return createStringResourceStatic(getPage(), en).getString();
}
};
columns.add(column);
column = new PropertyColumn(createStringResource("PageCertCampaigns.table.stage"), CertCampaignListItemDto.F_CURRENT_STAGE_NUMBER);
columns.add(column);
column = new PropertyColumn(createStringResource("PageCertCampaigns.table.escalationLevel"), CertCampaignListItemDto.F_ESCALATION_LEVEL_NUMBER);
columns.add(column);
column = new PropertyColumn(createStringResource("PageCertCampaigns.table.stages"), CertCampaignListItemDto.F_NUMBER_OF_STAGES);
columns.add(column);
column = new PropertyColumn(createStringResource("PageCertCampaigns.table.deadline"), CertCampaignListItemDto.F_DEADLINE_AS_STRING);
columns.add(column);
column = new SingleButtonColumn<CertCampaignListItemDto>(new Model(), null) {
@Override
public boolean isButtonEnabled(IModel<CertCampaignListItemDto> model) {
final AccessCertificationCampaignType campaign = model.getObject().getCampaign();
String button = determineAction(campaign);
return button != null;
}
@Override
public boolean isButtonVisible(IModel<CertCampaignListItemDto> model) {
final AccessCertificationCampaignType campaign = model.getObject().getCampaign();
return campaign.getState() != AccessCertificationCampaignStateType.IN_REMEDIATION && campaign.getState() != AccessCertificationCampaignStateType.CLOSED;
}
@Override
public String getCaption() {
AccessCertificationCampaignType campaign = getRowModel().getObject().getCampaign();
String button = determineAction(campaign);
if (button != null) {
return PageCertCampaigns.this.createStringResource(button).getString();
} else {
return "";
}
}
@Override
public String getButtonCssColorClass() {
return DoubleButtonColumn.BUTTON_COLOR_CLASS.PRIMARY.toString();
}
@Override
public String getButtonCssSizeClass() {
return DoubleButtonColumn.BUTTON_SIZE_CLASS.SMALL.toString();
}
@Override
public void clickPerformed(AjaxRequestTarget target, IModel<CertCampaignListItemDto> model) {
AccessCertificationCampaignType campaign = model.getObject().getCampaign();
String action = determineAction(campaign);
switch(action) {
case OP_START_CAMPAIGN:
case OP_OPEN_NEXT_STAGE:
openNextStagePerformed(target, campaign);
break;
case OP_CLOSE_STAGE:
closeStageConfirmation(target, model.getObject());
break;
case OP_START_REMEDIATION:
startRemediationPerformed(target, campaign);
break;
// not used
case OP_CLOSE_CAMPAIGN:
default:
throw new IllegalStateException("Unknown action: " + action);
}
}
};
columns.add(column);
columns.add(new InlineMenuHeaderColumn(createInlineMenu()));
return columns;
}
use of com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto in project midpoint by Evolveum.
the class PageCertCampaigns method deleteCampaignsPerformed.
private void deleteCampaignsPerformed(AjaxRequestTarget target, List<CertCampaignListItemDto> itemsToDelete) {
if (itemsToDelete.isEmpty()) {
warn(getString("PageCertCampaigns.message.noCampaignsSelected"));
target.add(getFeedbackPanel());
return;
}
OperationResult result = new OperationResult(OPERATION_DELETE_CAMPAIGNS);
for (CertCampaignListItemDto itemToDelete : itemsToDelete) {
try {
Task task = createSimpleTask(OPERATION_DELETE_CAMPAIGNS);
ObjectDelta<AccessCertificationCampaignType> delta = getPrismContext().deltaFactory().object().createDeleteDelta(AccessCertificationCampaignType.class, itemToDelete.getOid());
getModelService().executeChanges(MiscUtil.createCollection(delta), null, task, result);
} catch (Exception ex) {
result.recordPartialError(createStringResource("PageCertCampaigns.message.deleteCampaignsPerformed.partialError").getString(), ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete campaign", ex);
}
}
result.recomputeStatus();
if (result.isSuccess()) {
result.recordStatus(OperationResultStatus.SUCCESS, createStringResource("PageCertCampaigns.message.deleteCampaignsPerformed.success").getString());
}
Table campaignsTable = getCampaignsTable();
ObjectDataProvider provider = (ObjectDataProvider) campaignsTable.getDataTable().getDataProvider();
provider.clearCache();
WebComponentUtil.safeResultCleanup(result, LOGGER);
showResult(result);
target.add(getFeedbackPanel(), (Component) campaignsTable);
}
Aggregations