Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Jan 17, 2016
2 parents d9ad79b + 280937f commit 49a967a
Show file tree
Hide file tree
Showing 76 changed files with 3,614 additions and 501 deletions.
1 change: 1 addition & 0 deletions build-system/pom.xml
Expand Up @@ -1043,6 +1043,7 @@
<License-URL>http://www.apache.org/licenses/LICENSE-2.0.txt</License-URL>
</manifestEntries>
</archive>
<attachClasses>true</attachClasses>
</configuration>
</plugin>
<!--plugin> <groupId>org.apache.maven.plugins</groupId>
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2013 Evolveum
* Copyright (c) 2010-2016 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -113,6 +113,25 @@ public AssignmentEditorDto(UserDtoStatus status, AssignmentType assignment, Page
this.isOrgUnitManager = determineUserOrgRelation(assignment);
}

public static AssignmentEditorDto createDtoAddFromSelectedObject(ObjectType object, PageBase pageBase) {
AssignmentEditorDtoType aType = AssignmentEditorDtoType.getType(object.getClass());

ObjectReferenceType targetRef = new ObjectReferenceType();
targetRef.setOid(object.getOid());
targetRef.setType(aType.getQname());
targetRef.setTargetName(object.getName());

AssignmentType assignment = new AssignmentType();
assignment.setTargetRef(targetRef);

AssignmentEditorDto dto = new AssignmentEditorDto(UserDtoStatus.ADD, assignment,
pageBase);
dto.setMinimized(false);
dto.setShowEmpty(true);

return dto;
}

private AssignmentEditorDtoType getType(AssignmentType assignment) {
if (assignment.getTarget() != null) {
// object assignment
Expand Down Expand Up @@ -376,6 +395,10 @@ public String getName() {
public ObjectReferenceType getTargetRef() {
return newAssignment.getTargetRef();
}

public ExtensionType getExtension() {
return newAssignment.getExtension();
}

public AssignmentEditorDtoType getType() {
return type;
Expand All @@ -389,11 +412,11 @@ public boolean isModified(PrismContext prismContext) throws SchemaException {
return !getOldValue().equivalent(getNewValue(prismContext));
}

public PrismContainerValue getOldValue() {
public PrismContainerValue<AssignmentType> getOldValue() {
return oldAssignment.asPrismContainerValue();
}

public PrismContainerValue getNewValue(PrismContext prismContext) throws SchemaException {
public PrismContainerValue<AssignmentType> getNewValue(PrismContext prismContext) throws SchemaException {
if (AssignmentEditorDtoType.ORG_UNIT.equals(getType())) {
if (isOrgUnitManager()) {
newAssignment.getTargetRef().setRelation(SchemaConstants.ORG_MANAGER);
Expand Down Expand Up @@ -581,4 +604,12 @@ public int hashCode() {
result = 31 * result + (attributes != null ? attributes.hashCode() : 0);
return result;
}

@Override
public String toString() {
return "AssignmentEditorDto(name=" + name + ", status=" + status + ", showEmpty=" + showEmpty + ", minimized=" + minimized
+ ", isOrgUnitManager=" + isOrgUnitManager + ")";
}


}
Expand Up @@ -67,8 +67,6 @@ public class AssignmentTablePanel<T extends ObjectType> extends BasePanel<List<A
private static final Trace LOGGER = TraceManager.getTrace(AssignmentTablePanel.class);

private static final String DOT_CLASS = AssignmentTablePanel.class.getName() + ".";
private static final String OPERATION_LOAD_ASSIGNMENTS = DOT_CLASS + "loadAssignments";
private static final String OPERATION_LOAD_ASSIGNMENT = DOT_CLASS + "loadAssignment";

private static final String ID_ASSIGNMENTS = "assignments";
private static final String ID_CHECK_ALL = "assignmentsCheckAll";
Expand Down Expand Up @@ -392,21 +390,7 @@ private void addSelectedAssignablePerformed(AjaxRequestTarget target, List<Objec
continue;
}

AssignmentEditorDtoType aType = AssignmentEditorDtoType.getType(object.getClass());

ObjectReferenceType targetRef = new ObjectReferenceType();
targetRef.setOid(object.getOid());
targetRef.setType(aType.getQname());
targetRef.setTargetName(object.getName());

AssignmentType assignment = new AssignmentType();
assignment.setTargetRef(targetRef);

AssignmentEditorDto dto = new AssignmentEditorDto(UserDtoStatus.ADD, assignment,
getPageBase());
dto.setMinimized(false);
dto.setShowEmpty(true);

AssignmentEditorDto dto = AssignmentEditorDto.createDtoAddFromSelectedObject(object, getPageBase());
assignments.add(dto);
} catch (Exception e) {
error(getString("AssignmentTablePanel.message.couldntAssignObject", object.getName(),
Expand Down Expand Up @@ -531,32 +515,13 @@ private void handleModifyAssignmentDelta(AssignmentEditorDto assDto,
ItemPath deltaPath = delta.getPath().rest();
ItemDefinition deltaDef = assignmentDef.findItemDefinition(deltaPath);

delta.setParentPath(joinPath(oldValue.getPath(), delta.getPath().allExceptLast()));
delta.setParentPath(WebMiscUtil.joinPath(oldValue.getPath(), delta.getPath().allExceptLast()));
delta.applyDefinition(deltaDef);

userDelta.addModification(delta);
}
}

private ItemPath joinPath(ItemPath path, ItemPath deltaPath) {
List<ItemPathSegment> newPath = new ArrayList<ItemPathSegment>();

ItemPathSegment firstDeltaSegment = deltaPath != null ? deltaPath.first() : null;
if (path != null) {
for (ItemPathSegment seg : path.getSegments()) {
if (seg.equivalent(firstDeltaSegment)) {
break;
}
newPath.add(seg);
}
}
if (deltaPath != null) {
newPath.addAll(deltaPath.getSegments());
}

return new ItemPath(newPath);
}

/**
* remove this method after model is updated - it has to remove resource
* from accountConstruction
Expand Down
@@ -0,0 +1,63 @@
<!--
~ Copyright (c) 2016 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div>
<div class="row">
<div class="col-xs-5">
<div class="list-group-label" wicket:id="labelParam"/>
<div class="list-group">
<div wicket:id="listParam">
<a class="list-group-item" wicket:id="itemParam"/>
</div>
</div>
<div>
<div class="col-xs-9">
<div class="input-group input-group-sm">
<input class="form-control" type="text" wicket:id="addInput">
<span class="input-group-btn">
<a class="btn btn-success btn-flat" wicket:id="addLink"><i class="glyphicon glyphicon-plus"></i></a>
</span>
</div>
</div>
<div class="col-xs-3">
<div class="input-group input-group-sm">
<span class="input-group-btn">
<a class="btn btn-danger btn-flat" wicket:id="deleteLink"><i class="glyphicon glyphicon-minus"></i></a>
</span>
</div>
</div>
</div>
</div>
<div class="col-xs-5">
<div class="list-group-label" wicket:id="labelRole"/>
<div class="list-group">
<div wicket:id="list">
<a class="list-group-item" wicket:id="item"/>
</div>
</div>
</div>
<div class="col-xs-2">
<div class="btn-group-vertical" role="group">
<a class="btn btn-default btn-small" wicket:id="buttonReset"/>
</div>
</div>
</div>
</div>
</wicket:panel>
</html>

0 comments on commit 49a967a

Please sign in to comment.