Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into gui-devel
Browse files Browse the repository at this point in the history
Conflicts:
	gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/reports/component/ReportConfigurationPanel.java
	gui/admin-gui/src/main/webapp/WEB-INF/web.xml
  • Loading branch information
1azyman committed Jun 23, 2014
2 parents c398723 + 5664c93 commit 0793bc0
Show file tree
Hide file tree
Showing 21 changed files with 497 additions and 353 deletions.
5 changes: 3 additions & 2 deletions build-system/pom.xml
Expand Up @@ -70,6 +70,7 @@
<activiti-engine.version>5.15.1</activiti-engine.version>
<activiti-spring.version>5.15.1</activiti-spring.version>
<commons-email.version>1.3</commons-email.version>
<connid.version>1.4.0.0-SNAPSHOT</connid.version>
</properties>
<dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -335,12 +336,12 @@
<dependency>
<groupId>org.connid</groupId>
<artifactId>connector-framework</artifactId>
<version>1.4.0.erc2</version>
<version>${connid.version}</version>
</dependency>
<dependency>
<groupId>org.connid</groupId>
<artifactId>connector-framework-internal</artifactId>
<version>1.4.0.erc2</version>
<version>${connid.version}</version>
</dependency>
<dependency>
<groupId>org.forgerock.openicf.connectors</groupId>
Expand Down
Expand Up @@ -26,6 +26,7 @@
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.page.PageBase;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType;
Expand Down Expand Up @@ -71,29 +72,29 @@ public class ContainerWrapper<T extends PrismContainer> implements ItemWrapper,

private PrismContainerDefinition containerDefinition;

public ContainerWrapper(ObjectWrapper object, T container, ContainerStatus status, ItemPath path) {
public ContainerWrapper(ObjectWrapper object, T container, ContainerStatus status, ItemPath path, PageBase pageBase) {
Validate.notNull(container, "Prism object must not be null.");
Validate.notNull(status, "Container status must not be null.");
Validate.notNull(pageBase, "pageBase must not be null.");

this.object = object;
this.container = container;
this.status = status;
this.path = path;
main = path == null;
readonly = object.isReadonly();
readonly = object.isReadonly(); // [pm] this is quite questionable
showInheritedObjectAttributes = object.isShowInheritedObjectAttributes();
//have to be after setting "main" property
containerDefinition = getContainerDefinition();
createProperties();
properties = createProperties(pageBase);
}

protected PrismContainerDefinition getContainerDefinition(){
// if (object.getEditedDefinition() != null){
if (main){
protected PrismContainerDefinition getContainerDefinition() {
if (main) {
return object.getDefinition();
}
} else {
return object.getDefinition().findContainerDefinition(path);

}
}

OperationResult getResult() {
Expand Down Expand Up @@ -121,9 +122,6 @@ public T getItem() {
}

public List<PropertyWrapper> getProperties() {
if (properties == null) {
properties = createProperties();
}
return properties;
}

Expand All @@ -137,7 +135,7 @@ public PropertyWrapper findPropertyWrapper(QName name) {
return null;
}

private List<PropertyWrapper> createProperties() {
private List<PropertyWrapper> createProperties(PageBase pageBase) {
result = new OperationResult(CREATE_PROPERTIES);

List<PropertyWrapper> properties = new ArrayList<PropertyWrapper>();
Expand All @@ -147,23 +145,18 @@ private List<PropertyWrapper> createProperties() {
Class clazz = parent.getCompileTimeClass();
if (ShadowType.class.isAssignableFrom(clazz)) {
QName name = containerDefinition.getName();
// QName name = container.getDefinition().getName();


if (ShadowType.F_ATTRIBUTES.equals(name)) {
try {
definition = object.getRefinedAttributeDefinition();

if (definition == null){
if (definition == null) {
PrismReference resourceRef = parent.findReference(ShadowType.F_RESOURCE_REF);
PrismObject<ResourceType> resource = resourceRef.getValue().getObject();
RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resource,
LayerType.PRESENTATION, parent.getPrismContext());

PrismProperty<QName> objectClassProp = parent.findProperty(ShadowType.F_OBJECT_CLASS);
QName objectClass = objectClassProp != null ? objectClassProp.getRealValue() : null;
definition = refinedSchema.findRefinedDefinitionByObjectClassQName(ShadowKindType.ACCOUNT, objectClass)
.toResourceAttributeContainerDefinition();


definition = pageBase.getModelInteractionService()
.getEditObjectClassDefinition(object.getObject(), resource).toResourceAttributeContainerDefinition();

if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Refined account def:\n{}", definition.debugDump());
}
Expand All @@ -177,11 +170,9 @@ private List<PropertyWrapper> createProperties() {
}
} else {
definition = containerDefinition;
// definition = container.getDefinition();
}
} else {
definition = containerDefinition;
// definition = container.getDefinition();
}

if (definition == null) {
Expand Down Expand Up @@ -219,20 +210,14 @@ private List<PropertyWrapper> createProperties() {
PrismProperty<Object> temp = def.instantiate();

String value = formatAssignmentBrief(assignmentType);
// if (assignmentType.getTarget() != null) {
// value = assignmentType.getTarget().getName().getOrig();
// } else {
// PrismReference targetRef = pcv.findReference(AssignmentType.F_TARGET_REF);
// value = targetRef.getValue().getOid();
// }

temp.setValue(new PrismPropertyValue<Object>(value));
properties.add(new PropertyWrapper(this, temp, this.isReadonly(), ValueStatus.NOT_CHANGED)); // todo this.isReadOnly() - is that OK? (originally it was the default behavior for all cases)
}

} else if (isShadowAssociation()){
if (object.getAssociations() != null){
for (PrismProperty property : object.getAssociations()){
} else if (isShadowAssociation()) {
if (object.getAssociations() != null) {
for (PrismProperty property : object.getAssociations()) {
//TODO: fix this -> for now, read only is supported..
PropertyWrapper propertyWrapper = new PropertyWrapper(this, property, true, ValueStatus.NOT_CHANGED);
properties.add(propertyWrapper);
Expand Down Expand Up @@ -262,18 +247,23 @@ private List<PropertyWrapper> createProperties() {
continue;
}

if (isShadowAssociation()){
if (isShadowAssociation()) {
continue;
}

PrismProperty property = container.findProperty(def.getName());
boolean propertyIsReadOnly;
if (object.getStatus() == ContainerStatus.MODIFYING) { // decision is based on parent object status, not this container's one (because container can be added also to an existing object)
propertyIsReadOnly = !def.canModify();
} else {
propertyIsReadOnly = !def.canAdd();
}
if (property == null) {
properties.add(new PropertyWrapper(this, def.instantiate(), !def.canAdd(), ValueStatus.ADDED));
properties.add(new PropertyWrapper(this, def.instantiate(), propertyIsReadOnly, ValueStatus.ADDED));
} else {
properties.add(new PropertyWrapper(this, property, !def.canModify(), ValueStatus.NOT_CHANGED));
properties.add(new PropertyWrapper(this, property, propertyIsReadOnly, ValueStatus.NOT_CHANGED));
}



}
}
}
Expand All @@ -285,6 +275,11 @@ private List<PropertyWrapper> createProperties() {
return properties;
}

private boolean isPassword(PrismPropertyDefinition def) {
return CredentialsType.F_PASSWORD.equals(container.getElementName()) ||
CredentialsType.F_PASSWORD.equals(def.getName()); // in the future, this option could apply as well
}

private boolean isShadowAssociation() {
if (!ShadowType.class.isAssignableFrom(getObject().getObject().getCompileTimeClass())) {
return false;
Expand Down Expand Up @@ -382,32 +377,25 @@ boolean isPropertyVisible(PropertyWrapper property) {
if (skipProperty(def) || def.isIgnored() || def.isOperational()) {
return false;
}

if (ContainerStatus.ADDING == getStatus() && def.canAdd()){
return true;

// we decide not according to status of this container, but according to the status of the whole object
if (object.getStatus() == ContainerStatus.ADDING) {
return def.canAdd();
}

// otherwise, object.getStatus() is MODIFYING

if (ContainerStatus.MODIFYING == getStatus() && def.canModify()){
property.setReadonly(false); // this might be too late [mederly]
if (def.canModify()) {
return showEmpty(property);
}

if (ContainerStatus.MODIFYING == getStatus() && !def.canModify()){
if (def.canRead()){
property.setReadonly(true); // this might be too late [mederly]
return true;
} else {
if (def.canRead()) {
return showEmpty(property);
}
return false;
}

if (!def.canRead()){
return false;
}

return showEmpty(property);
}

private boolean showEmpty(PropertyWrapper property){
private boolean showEmpty(PropertyWrapper property) {
ObjectWrapper object = getObject();

List<ValueWrapper> values = property.getValues();
Expand Down Expand Up @@ -516,8 +504,8 @@ private boolean skipProperty(PrismPropertyDefinition def) {

public boolean isReadonly() {
PrismContainerDefinition def = getContainerDefinition();
if (def != null){
return (def.canRead() && !def.canAdd() && !def.canModify());
if (def != null) {
return (def.canRead() && !def.canAdd() && !def.canModify()); // todo take into account the containing object status (adding vs. modifying)
}
return readonly;
}
Expand Down

0 comments on commit 0793bc0

Please sign in to comment.