Skip to content

Commit

Permalink
fix for creating child org unit
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Nov 15, 2015
1 parent 895a70c commit b63c805
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
Expand Up @@ -65,7 +65,7 @@ protected void prepareFocusDeltaForModify(ObjectDelta<T> focusDelta) throws Sche
@Override
protected void prepareFocusForAdd(PrismObject<T> focus) throws SchemaException {
super.prepareFocusForAdd(focus);
handleAssignmentForAdd(focus, AbstractRoleType.F_INDUCEMENT, focus.asObjectable().getInducement());
handleAssignmentForAdd(focus, AbstractRoleType.F_INDUCEMENT, inducementsModel.getObject());

}

Expand Down
Expand Up @@ -1092,7 +1092,7 @@ protected void prepareFocusForAdd(PrismObject<T> focus) throws SchemaException {
focusType.getParentOrg().addAll(orgsToAdd);
}

handleAssignmentForAdd(focus, UserType.F_ASSIGNMENT, focusType.getAssignment());
handleAssignmentForAdd(focus, UserType.F_ASSIGNMENT, assignmentsModel.getObject());

// PrismObjectDefinition userDef = focus.getDefinition();
// PrismContainerDefinition assignmentDef =
Expand Down Expand Up @@ -1120,14 +1120,18 @@ protected void prepareFocusForAdd(PrismObject<T> focus) throws SchemaException {
}

protected void handleAssignmentForAdd(PrismObject<T> focus, QName containerName,
List<AssignmentType> assignmentTypes) throws SchemaException {
List<AssignmentEditorDto> assignments) throws SchemaException {
PrismObjectDefinition userDef = focus.getDefinition();
PrismContainerDefinition assignmentDef = userDef.findContainerDefinition(containerName);

// handle added assignments
// existing user assignments are not relevant -> delete them
assignmentTypes.clear();
List<AssignmentEditorDto> assignments = getFocusAssignments();
PrismContainer<AssignmentType> assignmentContainer = focus.findContainer(containerName);
if (assignmentContainer != null && !assignmentContainer.isEmpty()){
assignmentContainer.clear();
}

// List<AssignmentEditorDto> assignments = getFocusAssignments();
for (AssignmentEditorDto assDto : assignments) {
if (UserDtoStatus.DELETE.equals(assDto.getStatus())) {
continue;
Expand All @@ -1137,7 +1141,7 @@ protected void handleAssignmentForAdd(PrismObject<T> focus, QName containerName,
PrismContainerValue value = assDto.getNewValue();
assignment.setupContainerValue(value);
value.applyDefinition(assignmentDef, false);
assignmentTypes.add(assignment.clone());
assignmentContainer.add(assignment.clone().asPrismContainerValue());

// todo remove this block [lazyman] after model is updated - it has
// to remove resource from accountConstruction
Expand Down Expand Up @@ -1298,12 +1302,6 @@ protected ContainerDelta handleAssignmentDeltas(ObjectDelta<T> focusDelta,
List<AssignmentEditorDto> assignments, PrismContainerDefinition def) throws SchemaException {
ContainerDelta assDelta = new ContainerDelta(new ItemPath(), def.getName(), def, getPrismContext());

// PrismObject<UserType> user = getFocusWrapper().getObject();
// PrismObjectDefinition userDef = user.getDefinition();
// PrismContainerDefinition assignmentDef =
// userDef.findContainerDefinition(UserType.F_ASSIGNMENT);

// List<AssignmentEditorDto> assignments = getFocusAssignments();
for (AssignmentEditorDto assDto : assignments) {
PrismContainerValue newValue = assDto.getNewValue();

Expand Down

0 comments on commit b63c805

Please sign in to comment.