use of com.evolveum.midpoint.web.page.admin.home.dto.AssignmentItemDto in project midpoint by Evolveum.
the class MyAssignmentsPanel method initLayout.
private void initLayout() {
List<IColumn<AssignmentItemDto, String>> columns = new ArrayList<IColumn<AssignmentItemDto, String>>();
columns.add(new IconColumn<AssignmentItemDto>(null) {
private static final long serialVersionUID = 1L;
@Override
protected IModel<String> createIconModel(final IModel<AssignmentItemDto> rowModel) {
return new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
AssignmentItemDto item = rowModel.getObject();
if (item.getType() == null) {
return OperationResultStatusPresentationProperties.FATAL_ERROR.getIcon() + " fa-lg";
}
return item.getType().getIconCssClass();
}
};
}
@Override
protected IModel<String> createTitleModel(final IModel<AssignmentItemDto> rowModel) {
return new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
AssignmentItemDto item = rowModel.getObject();
if (item.getType() == null) {
return MyAssignmentsPanel.this.getString("MyAssignmentsPanel.type.error");
}
switch(item.getType()) {
case CONSTRUCTION:
return MyAssignmentsPanel.this.getString("MyAssignmentsPanel.type.accountConstruction");
case ORG_UNIT:
return MyAssignmentsPanel.this.getString("MyAssignmentsPanel.type.orgUnit");
case ROLE:
return MyAssignmentsPanel.this.getString("MyAssignmentsPanel.type.role");
default:
return MyAssignmentsPanel.this.getString("MyAssignmentsPanel.type.error");
}
}
};
}
});
columns.add(new AbstractColumn<AssignmentItemDto, String>(createStringResource("MyAssignmentsPanel.assignment.displayName")) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<AssignmentItemDto>> cellItem, String componentId, final IModel<AssignmentItemDto> rowModel) {
AssignmentHeaderPanel panel = new AssignmentHeaderPanel(componentId, rowModel);
panel.add(new AttributeModifier("class", "dash-assignment-header"));
cellItem.add(panel);
}
});
ISortableDataProvider provider = new ListDataProvider(this, getModel());
TablePanel accountsTable = new TablePanel<AssignmentItemDto>(ID_ASSIGNMETNS_TABLE, provider, columns);
accountsTable.setShowPaging(false);
add(accountsTable);
}
use of com.evolveum.midpoint.web.page.admin.home.dto.AssignmentItemDto in project midpoint by Evolveum.
the class PageSelfDashboard method initAssignments.
private void initAssignments() {
AsyncDashboardPanel<Object, List<AssignmentItemDto>> assignedOrgUnits = new AsyncDashboardPanel<Object, List<AssignmentItemDto>>(ID_ASSIGNMENTS, createStringResource("PageDashboard.assignments"), GuiStyleConstants.CLASS_ICON_ASSIGNMENTS, GuiStyleConstants.CLASS_OBJECT_ROLE_BOX_CSS_CLASSES, true) {
private static final long serialVersionUID = 1L;
@Override
protected SecurityContextAwareCallable<CallableResult<List<AssignmentItemDto>>> createCallable(Authentication auth, IModel callableParameterModel) {
return new SecurityContextAwareCallable<CallableResult<List<AssignmentItemDto>>>(getSecurityEnforcer(), auth) {
@Override
public CallableResult<List<AssignmentItemDto>> callWithContextPrepared() throws Exception {
return loadAssignments();
}
};
}
@Override
protected Component getMainComponent(String markupId) {
return new MyAssignmentsPanel(markupId, new PropertyModel<List<AssignmentItemDto>>(getModel(), CallableResult.F_VALUE));
}
};
assignedOrgUnits.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
UserInterfaceElementVisibilityType visibilityType = getComponentVisibility(PredefinedDashboardWidgetId.MY_ASSIGNMENTS);
return WebComponentUtil.getElementVisibility(visibilityType);
}
});
add(assignedOrgUnits);
}
use of com.evolveum.midpoint.web.page.admin.home.dto.AssignmentItemDto in project midpoint by Evolveum.
the class PageSelfDashboard method createAssignmentItem.
private AssignmentItemDto createAssignmentItem(PrismObject<UserType> user, PrismContainerValue<AssignmentType> assignment, Task task, OperationResult result) {
ActivationType activation = assignment.asContainerable().getActivation();
if (activation != null && activation.getAdministrativeStatus() != null && !activation.getAdministrativeStatus().equals(ActivationStatusType.ENABLED)) {
return null;
}
PrismReference targetRef = assignment.findReference(AssignmentType.F_TARGET_REF);
if (targetRef == null || targetRef.isEmpty()) {
// account construction
PrismContainer construction = assignment.findContainer(AssignmentType.F_CONSTRUCTION);
String name = null;
String description = "";
if (construction.getValue().asContainerable() != null && !construction.isEmpty()) {
ConstructionType constr = (ConstructionType) construction.getValue().asContainerable();
if (constr.getResourceRef() != null) {
ObjectReferenceType resourceRef = constr.getResourceRef();
PrismObject resource = WebModelServiceUtils.loadObject(ResourceType.class, resourceRef.getOid(), this, task, result);
name = WebComponentUtil.getName(resource);
description = constr.getDescription();
}
}
return new AssignmentItemDto(AssignmentEditorDtoType.CONSTRUCTION, name, description, null);
}
PrismReferenceValue refValue = targetRef.getValue();
PrismObject value = refValue.getObject();
if (value == null) {
// resolve reference
value = WebModelServiceUtils.loadObject(ObjectType.class, refValue.getOid(), this, task, result);
}
if (value == null) {
// we couldn't resolve assignment details
return new AssignmentItemDto(null, null, null, null);
}
String name = WebComponentUtil.getDisplayNameOrName(value);
AssignmentEditorDtoType type = AssignmentEditorDtoType.getType(value.getCompileTimeClass());
String relation = refValue.getRelation() != null ? refValue.getRelation().getLocalPart() : null;
return new AssignmentItemDto(type, name, getAssignmentDescription(value), relation);
}
use of com.evolveum.midpoint.web.page.admin.home.dto.AssignmentItemDto in project midpoint by Evolveum.
the class PageSelfDashboard method loadAssignments.
private CallableResult<List<AssignmentItemDto>> loadAssignments() throws Exception {
LOGGER.debug("Loading assignments.");
CallableResult callableResult = new CallableResult();
List<AssignmentItemDto> list = new ArrayList<AssignmentItemDto>();
callableResult.setValue(list);
PrismObject<UserType> user = principalModel.getObject();
if (user == null || user.findContainer(UserType.F_ASSIGNMENT) == null) {
return callableResult;
}
Task task = createSimpleTask(OPERATION_LOAD_ASSIGNMENTS);
OperationResult result = task.getResult();
callableResult.setResult(result);
PrismContainer assignments = user.findContainer(UserType.F_ASSIGNMENT);
List<PrismContainerValue> values = assignments.getValues();
for (PrismContainerValue assignment : values) {
AssignmentItemDto item = createAssignmentItem(user, assignment, task, result);
if (item != null) {
list.add(item);
}
}
result.recordSuccessIfUnknown();
result.recomputeStatus();
Collections.sort(list);
LOGGER.debug("Finished assignments loading.");
return callableResult;
}
Aggregations