Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Jun 13, 2017
2 parents 117c05b + 7e55d2d commit 8d5fb46
Show file tree
Hide file tree
Showing 39 changed files with 719 additions and 202 deletions.
Expand Up @@ -34,8 +34,8 @@ public class LookupPropertyModel<T> extends AbstractPropertyModel<T> {
private static final long serialVersionUID = 1L;

protected final String expression;
private final LookupTableType lookupTable;
private boolean isStrict = true; // if true, allow only values found in lookupTable, false - allow also input that is not in the lookupTable
protected final LookupTableType lookupTable;
protected boolean isStrict = true; // if true, allow only values found in lookupTable, false - allow also input that is not in the lookupTable

public LookupPropertyModel(Object modelObject, String expression, LookupTableType lookupTable) {
super(modelObject);
Expand All @@ -49,6 +49,10 @@ public LookupPropertyModel(Object modelObject, String expression, LookupTableTyp
this.lookupTable = lookupTable;
this.isStrict = isStrict;
}

public boolean isSupportsDisplayName() {
return false;
}

/**
* @see org.apache.wicket.model.AbstractPropertyModel#propertyExpression()
Expand All @@ -63,9 +67,17 @@ protected String propertyExpression() {
public T getObject() {

final Object target = getInnermostModelOrObject();

if (target != null) {
Object value = PropertyResolver.getValue(expression, target);

Object value = null;
if (isSupportsDisplayName()) {
value = PropertyResolver.getValue("displayName", target);
if (value != null) {
return (T) value;
}
}

value = PropertyResolver.getValue(expression, target);
if (value == null) {
return null;
}
Expand All @@ -80,16 +92,14 @@ public T getObject() {
}
return (T) key;
}

return null;
return null;
}

@Override
public void setObject(T object) {
final String expression = propertyExpression();

PropertyResolverConverter prc;
prc = new PropertyResolverConverter(Application.get().getConverterLocator(),
PropertyResolverConverter prc = new PropertyResolverConverter(Application.get().getConverterLocator(),
Session.get().getLocale());

if (object instanceof String) {
Expand All @@ -107,6 +117,9 @@ public void setObject(T object) {
if (label.equals(WebComponentUtil.getOrigStringFromPoly(row.getLabel()))) {
key = row.getKey();
PropertyResolver.setValue(expression, getInnermostModelOrObject(), key, prc);
if (isSupportsDisplayName()) {
PropertyResolver.setValue("displayName", getInnermostModelOrObject(), label, prc);
}
}
}
}
Expand Down
Expand Up @@ -24,10 +24,14 @@
import javax.xml.namespace.QName;

import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.Application;
import org.apache.wicket.Component;
import org.apache.wicket.RestartResponseException;
import org.apache.wicket.Session;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.core.util.lang.PropertyResolver;
import org.apache.wicket.core.util.lang.PropertyResolverConverter;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
Expand Down Expand Up @@ -264,7 +268,7 @@ private InputPanel createTypedInputPanel(String componentId, IModel<JasperReport
panel = new DatePanel(componentId, new PropertyModel<>(model, expression));
} else if (param.getProperties() != null && param.getProperties().getTargetType() != null) { // render autocomplete box
LookupTableType lookup = new LookupTableType();
panel = new AutoCompleteTextPanel<String>(componentId, new LookupPropertyModel<>(model, expression, lookup, false), String.class) {
panel = new AutoCompleteTextPanel<String>(componentId, new LookupReportPropertyModel(model, expression, lookup, false), String.class) {

private static final long serialVersionUID = 1L;

Expand All @@ -284,7 +288,6 @@ public Iterator<String> getIterator(String input) {
return panel;
}


private void addValue(WebMarkupContainer paramValueMarkup, JasperReportParameterDto valueModel, AjaxRequestTarget target) {
valueModel.addValue();
//reload just current parameter container panel
Expand Down Expand Up @@ -563,5 +566,21 @@ public StringResourceModel getTitle() {
public Component getComponent() {
return this;
}

class LookupReportPropertyModel extends LookupPropertyModel<String> {

private static final long serialVersionUID = 1L;


public LookupReportPropertyModel(IModel<JasperReportValueDto> modelObject, String expression, LookupTableType lookupTable, boolean isStrict) {
super(modelObject, expression, lookupTable, isStrict);
}

@Override
public boolean isSupportsDisplayName() {
return true;
}

}

}
Expand Up @@ -7,6 +7,7 @@ public class JasperReportValueDto implements Serializable {
private static final long serialVersionUID = 1L;

private Object value;
private String displayName;

public JasperReportValueDto() {

Expand All @@ -19,5 +20,13 @@ public Object getValue() {
public void setValue(Object value) {
this.value = value;
}

public String getDisplayName() {
return displayName;
}

public void setDisplayName(String displayName) {
this.displayName = displayName;
}

}
Expand Up @@ -409,6 +409,10 @@ public void addAuxiliaryObjectClass(String name, DummyObjectClass objectClass) {
auxiliaryObjectClassMap.put(name, objectClass);
}

public int getNumberOfObjectclasses() {
return 4 + auxiliaryObjectClassMap.size();
}

public Collection<DummyAccount> listAccounts() throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
checkBlockOperations();
breakIt(getBreakMode, "get");
Expand Down
Expand Up @@ -605,4 +605,10 @@ public void revive(PrismContext prismContext) {
refinedObjectClassDefinition.revive(prismContext);
}

@Override
public String toString() {
return "LROCDef("+layer+": "
+ refinedObjectClassDefinition + ")";
}

}
Expand Up @@ -139,6 +139,7 @@ default PrismObject<ShadowType> createBlankShadow() {

ResourceShadowDiscriminator getShadowDiscriminator();

@Override
boolean matches(ShadowType shadowType);
//endregion

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2016 Evolveum
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,6 @@
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismObjectDefinition;
import com.evolveum.midpoint.prism.schema.PrismSchema;
import com.evolveum.midpoint.schema.ResourceShadowDiscriminator;
import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition;
import com.evolveum.midpoint.schema.processor.ResourceSchema;
Expand Down Expand Up @@ -97,6 +96,6 @@ static RefinedResourceSchema getRefinedSchema(PrismObject<ResourceType> resource

static ResourceSchema getResourceSchema(PrismObject<ResourceType> resource, PrismContext prismContext)
throws SchemaException {
return RefinedResourceSchemaImpl.getRefinedSchema(resource, prismContext);
return RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2016 Evolveum
* Copyright (c) 2010-2017 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 @@ -35,25 +35,33 @@
import java.util.*;

/**
* TODO: this whole class would benefit from more refactoring.
* TODO: especially the parsing part.
*
* @author semancik
*
* @author mederly
*/
public class RefinedResourceSchemaImpl implements RefinedResourceSchema {

private static final String USER_DATA_KEY_PARSED_RESOURCE_SCHEMA = RefinedResourceSchema.class.getName()+".parsedResourceSchema";
private static final String USER_DATA_KEY_REFINED_SCHEMA = RefinedResourceSchema.class.getName()+".refinedSchema";

// TODO really don't remember why we include originalResourceSchema here instead of simply extending ResourceSchemaImpl ...
// TODO Maybe that's because we need to create new RefinedResourceSchema(s) based on existing ResourceSchema(s)?
// Original resource schema is there to make parsing easier.
// But it is also useful in some cases, e.g. we do not need to pass both refined schema and
// original schema as a metod parameter.
private ResourceSchema originalResourceSchema;

// This object contains the real data of the refined schema
private ResourceSchema resourceSchema;

private RefinedResourceSchemaImpl(@NotNull ResourceSchema originalResourceSchema) {
this.originalResourceSchema = originalResourceSchema;
this.resourceSchema = new ResourceSchemaImpl(originalResourceSchema.getNamespace(), originalResourceSchema.getPrismContext());
}

@Override
public List<? extends RefinedObjectClassDefinition> getRefinedDefinitions() {
return originalResourceSchema.getDefinitions(RefinedObjectClassDefinition.class);
return resourceSchema.getDefinitions(RefinedObjectClassDefinition.class);
}

@Override
Expand Down Expand Up @@ -401,6 +409,7 @@ public static RefinedResourceSchema parse(ResourceType resourceType, PrismContex
// return false;
// }

// TODO: The whole parsing is a big mess. TODO: refactor parsing
private static void parseObjectTypeDefsFromSchemaHandling(RefinedResourceSchemaImpl rSchema, ResourceType resourceType,
SchemaHandlingType schemaHandling, Collection<ResourceObjectTypeDefinitionType> resourceObjectTypeDefs,
ShadowKindType impliedKind, PrismContext prismContext, String contextDescription) throws SchemaException {
Expand Down Expand Up @@ -466,106 +475,106 @@ private static void parseObjectTypesFromSchema(RefinedResourceSchemaImpl rSchema
//endregion

private void add(RefinedObjectClassDefinition rOcDef) {
((ResourceSchemaImpl) originalResourceSchema).add(rOcDef); // TODO FIXME
((ResourceSchemaImpl) resourceSchema).add(rOcDef);
}

//region Delegations
@Override
public ObjectClassComplexTypeDefinition findObjectClassDefinition(QName objectClassQName) {
return originalResourceSchema.findObjectClassDefinition(objectClassQName);
return resourceSchema.findObjectClassDefinition(objectClassQName);
}

@Override
public ObjectClassComplexTypeDefinition findObjectClassDefinition(ShadowKindType kind, String intent) {
return originalResourceSchema.findObjectClassDefinition(kind, intent);
return resourceSchema.findObjectClassDefinition(kind, intent);
}

@Override
public ObjectClassComplexTypeDefinition findDefaultObjectClassDefinition(ShadowKindType kind) {
return originalResourceSchema.findDefaultObjectClassDefinition(kind);
return resourceSchema.findDefaultObjectClassDefinition(kind);
}

@Override
public String getNamespace() {
return originalResourceSchema.getNamespace();
return resourceSchema.getNamespace();
}

@Override
@NotNull
public Collection<Definition> getDefinitions() {
return originalResourceSchema.getDefinitions();
return resourceSchema.getDefinitions();
}

@Override
@NotNull
public <T extends Definition> List<T> getDefinitions(@NotNull Class<T> type) {
return originalResourceSchema.getDefinitions(type);
return resourceSchema.getDefinitions(type);
}

@Override
public PrismContext getPrismContext() {
return originalResourceSchema.getPrismContext();
return resourceSchema.getPrismContext();
}

@Override
@NotNull
public Document serializeToXsd() throws SchemaException {
return originalResourceSchema.serializeToXsd();
return resourceSchema.serializeToXsd();
}

@Override
public boolean isEmpty() {
return originalResourceSchema.isEmpty();
return resourceSchema.isEmpty();
}

@NotNull
@Override
public <ID extends ItemDefinition> List<ID> findItemDefinitionsByCompileTimeClass(
@NotNull Class<?> compileTimeClass, @NotNull Class<ID> definitionClass) {
return originalResourceSchema.findItemDefinitionsByCompileTimeClass(compileTimeClass, definitionClass);
return resourceSchema.findItemDefinitionsByCompileTimeClass(compileTimeClass, definitionClass);
}

@Nullable
@Override
public <TD extends TypeDefinition> TD findTypeDefinitionByCompileTimeClass(@NotNull Class<?> compileTimeClass, @NotNull Class<TD> definitionClass) {
return originalResourceSchema.findTypeDefinitionByCompileTimeClass(compileTimeClass, definitionClass);
return resourceSchema.findTypeDefinitionByCompileTimeClass(compileTimeClass, definitionClass);
}

@Override
@Nullable
public <TD extends TypeDefinition> TD findTypeDefinitionByType(@NotNull QName typeName, @NotNull Class<TD> definitionClass) {
return originalResourceSchema.findTypeDefinitionByType(typeName, definitionClass);
return resourceSchema.findTypeDefinitionByType(typeName, definitionClass);
}

@Override
public String debugDump() {
return originalResourceSchema.debugDump();
return resourceSchema.debugDump();
}

@Override
public String debugDump(int indent) {
return originalResourceSchema.debugDump(indent);
return resourceSchema.debugDump(indent);
}

@Nullable
@Override
public <ID extends ItemDefinition> ID findItemDefinitionByType(
@NotNull QName typeName, @NotNull Class<ID> definitionType) {
return originalResourceSchema.findItemDefinitionByType(typeName, definitionType);
return resourceSchema.findItemDefinitionByType(typeName, definitionType);
}

@Override
@NotNull
public <ID extends ItemDefinition> List<ID> findItemDefinitionsByElementName(@NotNull QName elementName,
@NotNull Class<ID> definitionClass) {
return originalResourceSchema.findItemDefinitionsByElementName(elementName, definitionClass);
return resourceSchema.findItemDefinitionsByElementName(elementName, definitionClass);
}

@NotNull
@Override
public <TD extends TypeDefinition> Collection<? extends TD> findTypeDefinitionsByType(@NotNull QName typeName,
@NotNull Class<TD> definitionClass) {
return originalResourceSchema.findTypeDefinitionsByType(typeName, definitionClass);
return resourceSchema.findTypeDefinitionsByType(typeName, definitionClass);
}

//endregion
Expand Down

0 comments on commit 8d5fb46

Please sign in to comment.