Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Apr 10, 2018
2 parents 5624dc9 + ff9aabf commit 56c2aa6
Show file tree
Hide file tree
Showing 62 changed files with 289 additions and 176 deletions.
Expand Up @@ -256,7 +256,7 @@ protected void onUpdate(AjaxRequestTarget target) {
}
}

private class PasswordModel implements IModel<String> {
private static class PasswordModel implements IModel<String> {

IModel<ProtectedStringType> psModel;

Expand Down
Expand Up @@ -713,8 +713,7 @@ public static void addIncludeOptionsForExportOrView(Collection<SelectorOptions<G
}
}

public static boolean isEnableExperimentalFeature(ModelServiceLocator pageBase) {
Task task = pageBase.createSimpleTask("Load admin gui config");
public static boolean isEnableExperimentalFeature(Task task, ModelServiceLocator pageBase) {
OperationResult result = task.getResult();

ModelInteractionService mInteractionService = pageBase.getModelInteractionService();
Expand All @@ -737,6 +736,12 @@ public static boolean isEnableExperimentalFeature(ModelServiceLocator pageBase)
return BooleanUtils.isTrue(adminGuiConfig.isEnableExperimentalFeatures());

}

public static boolean isEnableExperimentalFeature(ModelServiceLocator pageBase) {
Task task = pageBase.createSimpleTask("Load admin gui config");
return isEnableExperimentalFeature(task, pageBase);

}

public static AccessCertificationConfigurationType getCertificationConfiguration(PageBase pageBase) {
OperationResult result = new OperationResult(WebModelServiceUtils.class.getName() + ".getCertificationConfiguration");
Expand Down
Expand Up @@ -71,11 +71,11 @@ private void appendOptions(StringBuilder sb) {
}

sb.append('{');
Iterator<String> keys = map.keySet().iterator();
Iterator<Map.Entry<String, String>> keys = map.entrySet().iterator();
while (keys.hasNext()) {
String key = keys.next();
sb.append(key).append(":");
sb.append('\'').append(map.get(key)).append('\'');
final Map.Entry<String, String> key = keys.next();
sb.append(key.getKey()).append(":");
sb.append('\'').append(key.getValue()).append('\'');
if (keys.hasNext()) {
sb.append(",\n");
}
Expand Down
Expand Up @@ -51,6 +51,7 @@
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.query.builder.QueryBuilder;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.form.Form;
import com.evolveum.midpoint.web.component.input.DropDownChoicePanel;
Expand Down
Expand Up @@ -27,6 +27,7 @@
import com.evolveum.midpoint.prism.query.builder.QueryBuilder;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.data.column.IsolatedCheckBoxPanel;
Expand Down Expand Up @@ -171,13 +172,15 @@ private void onPolicyAddedOrRemoved(PrismObject<AbstractRoleType> assignmentTarg
assignmentsModel.getObject().getValues().remove(assignmentToRemove);
} else {
if (added){
//TODO: not sure if this is correct way of creating new value.. this value is added directly to the origin object... what about deltas??
PrismContainerValue<AssignmentType> newAssignment = assignmentsModel.getObject().getItem().createNewValue();
ObjectReferenceType ref = ObjectTypeUtil.createObjectRef(assignmentTargetObject);
AssignmentType assignmentType = newAssignment.asContainerable();
assignmentType.setTargetRef(ref);
Task task = getPageBase().createSimpleTask("Creating new applicable policy");
ContainerWrapperFactory factory = new ContainerWrapperFactory(getPageBase());
ContainerValueWrapper<AssignmentType> valueWrapper = factory.createContainerValueWrapper(assignmentsModel.getObject(), newAssignment,
assignmentsModel.getObject().getObjectStatus(), ValueStatus.ADDED, assignmentsModel.getObject().getPath());
assignmentsModel.getObject().getObjectStatus(), ValueStatus.ADDED, assignmentsModel.getObject().getPath(), task);
valueWrapper.setShowEmpty(true, false);
assignmentsModel.getObject().getValues().add(valueWrapper);
}
Expand Down
Expand Up @@ -50,6 +50,7 @@
import com.evolveum.midpoint.prism.query.ObjectPaging;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.AjaxIconButton;
import com.evolveum.midpoint.web.component.data.BoxedTablePanel;
Expand Down Expand Up @@ -459,8 +460,9 @@ protected void deleteAssignmentPerformed(AjaxRequestTarget target, List<Containe

protected ContainerValueWrapper<AssignmentType> createNewAssignmentContainerValueWrapper(PrismContainerValue<AssignmentType> newAssignment) {
ContainerWrapperFactory factory = new ContainerWrapperFactory(getPageBase());
Task task = getPageBase().createSimpleTask("Creating new assignment");
ContainerValueWrapper<AssignmentType> valueWrapper = factory.createContainerValueWrapper(getModelObject(), newAssignment,
getModelObject().getObjectStatus(), ValueStatus.ADDED, getModelObject().getPath());
getModelObject().getObjectStatus(), ValueStatus.ADDED, getModelObject().getPath(), task);
valueWrapper.setShowEmpty(true, false);
getModelObject().getValues().add(valueWrapper);
return valueWrapper;
Expand Down
Expand Up @@ -281,6 +281,7 @@ private List<ObjectReferenceType> getAssociationsShadowRefs(boolean compareName,
private void addNewShadowRefValuePerformed(AjaxRequestTarget target, RefinedAssociationDefinition def){
ObjectFilter filter = WebComponentUtil.createAssociationShadowRefFilter(def,
getPageBase().getPrismContext(), resourceModel.getObject().getOid());
Task task = getPageBase().createAnonymousTask("Adding new shadow");
ObjectBrowserPanel<ShadowType> objectBrowserPanel = new ObjectBrowserPanel<ShadowType>(
getPageBase().getMainPopupBodyId(), ShadowType.class, Arrays.asList(ShadowType.COMPLEX_TYPE),
false, getPageBase(),
Expand All @@ -304,7 +305,7 @@ protected void onSelectPerformed(AjaxRequestTarget target, ShadowType object) {
ContainerWrapperFactory factory = new ContainerWrapperFactory(getPageBase());
ContainerValueWrapper<ResourceObjectAssociationType> valueWrapper =
factory.createContainerValueWrapper(associationWrapper, newAssociation,
associationWrapper.getObjectStatus(), ValueStatus.ADDED, associationWrapper.getPath());
associationWrapper.getObjectStatus(), ValueStatus.ADDED, associationWrapper.getPath(), task);
// valueWrapper.setShowEmpty(true, false);
associationWrapper.getValues().add(valueWrapper);

Expand Down
Expand Up @@ -141,6 +141,7 @@ protected void newAssignmentClickPerformed(AjaxRequestTarget target) {
newAssignment.asContainerable().setPolicyRule(new PolicyRuleType());
ContainerValueWrapper<AssignmentType> newAssignmentWrapper = createNewAssignmentContainerValueWrapper(newAssignment);
newAssignmentWrapper.setShowEmpty(true, false);
newAssignmentWrapper.computeStripes();
assignmentDetailsPerformed(target, Arrays.asList(newAssignmentWrapper));
}

Expand Down
Expand Up @@ -155,15 +155,17 @@ public void computeStripes() {
}
int visibleProperties = 0;

for (ItemWrapper item : properties) {
for (ItemWrapper item : properties) {
if (item.isVisible()) {
visibleProperties++;
}

if (visibleProperties % 2 == 0) {
item.setStripe(true);
} else {
item.setStripe(false);
}

}
}

Expand Down Expand Up @@ -284,16 +286,64 @@ public void sort() {
if (isSorted()) {
collator.setStrength(Collator.SECONDARY); // e.g. "a" should be different from "á"
collator.setDecomposition(Collator.FULL_DECOMPOSITION); // slower but more precise

// List<ItemWrapper> containerWrappers = new ArrayList<>();
// List<ItemWrapper> propertyOrReferenceWrapper = new ArrayList<>();
// for(ItemWrapper w : properties) {
// if (w instanceof ContainerWrapper) {
// containerWrappers.add(w);
// continue;
// }
//
// if (PropertyOrReferenceWrapper.class.isAssignableFrom(w.getClass())) {
// propertyOrReferenceWrapper.add(w);
// }
// }

Collections.sort(properties, new Comparator<ItemWrapper>() {
@Override
public int compare(ItemWrapper pw1, ItemWrapper pw2) {

if (pw1 instanceof ContainerWrapper) {
((ContainerWrapper) pw1).sort();
}

if (pw2 instanceof ContainerWrapper) {
((ContainerWrapper) pw2).sort();
}

if (PropertyOrReferenceWrapper.class.isAssignableFrom(pw1.getClass()) && pw2 instanceof ContainerWrapper) {
return -1;
}

if (PropertyOrReferenceWrapper.class.isAssignableFrom(pw2.getClass()) && pw1 instanceof ContainerWrapper) {
return 1;
}
//
return compareByDisplayNames(pw1, pw2, collator);
}
});
} else {
Collections.sort(properties, new Comparator<ItemWrapper>() {
@Override
public int compare(ItemWrapper pw1, ItemWrapper pw2) {

if (pw1 instanceof ContainerWrapper) {
((ContainerWrapper) pw1).sort();
}

if (pw2 instanceof ContainerWrapper) {
((ContainerWrapper) pw2).sort();
}

if (PropertyOrReferenceWrapper.class.isAssignableFrom(pw1.getClass()) && pw2 instanceof ContainerWrapper) {
return -1;
}

if (PropertyOrReferenceWrapper.class.isAssignableFrom(pw2.getClass()) && pw1 instanceof ContainerWrapper) {
return 1;
}

ItemDefinition id1 = pw1.getItemDefinition();
ItemDefinition id2 = pw2.getItemDefinition();

Expand All @@ -307,6 +357,7 @@ public int compare(ItemWrapper pw1, ItemWrapper pw2) {
}
});
}

}

private int compareByDisplayNames(ItemWrapper pw1, ItemWrapper pw2, Collator collator) {
Expand Down Expand Up @@ -548,25 +599,7 @@ private void addItemDelta(PropertyOrReferenceWrapper itemWrapper, ItemDelta pDel
}
}

public void addNewChildContainerValue(QName path, PageBase pageBase){
ContainerWrapper<C> childContainerWrapper = getContainer().findContainerWrapper(new ItemPath(getPath(), path));
if (childContainerWrapper == null){
return;
}
boolean isSingleValue = childContainerWrapper.getItemDefinition().isSingleValue();
if (isSingleValue){
return;
}
PrismContainerValue<C> newContainerValue = childContainerWrapper.getItem().createNewValue();
ContainerWrapperFactory factory = new ContainerWrapperFactory(pageBase);
ContainerValueWrapper newValueWrapper = factory.createContainerValueWrapper(childContainerWrapper,
newContainerValue, objectStatus,
ValueStatus.ADDED, new ItemPath(path));
newValueWrapper.setShowEmpty(true, false);
childContainerWrapper.getValues().add(newValueWrapper);

}


private Item createItem(PropertyOrReferenceWrapper itemWrapper, ItemDefinition propertyDef) {
List<PrismValue> prismValues = new ArrayList<>();
for (Object vWrapper : itemWrapper.getValues()) {
Expand Down
Expand Up @@ -376,7 +376,9 @@ public boolean isStripe() {

@Override
public void setStripe(boolean isStripe) {
// Does not make much sense, but it is given by the interface
for (ContainerValueWrapper value : values) {
value.computeStripes();
}
}

public PrismContainer<C> createContainerAddDelta() throws SchemaException {
Expand Down

0 comments on commit 56c2aa6

Please sign in to comment.