Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
Conflicts:
	model/report-impl/src/test/resources/common/user-administrator.xml

fixing MID-1910.
  • Loading branch information
katkav committed May 26, 2014
2 parents c815c0b + fc3d621 commit d92957e
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 20 deletions.
Expand Up @@ -25,6 +25,7 @@
import com.evolveum.midpoint.schema.SchemaConstantsGenerated;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ReportTypeUtil;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.Holder;
Expand All @@ -41,6 +42,7 @@
import com.evolveum.midpoint.web.security.MidPointApplication;
import com.evolveum.midpoint.web.util.WebMiscUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;

import org.apache.commons.lang.StringUtils;
Expand Down Expand Up @@ -228,6 +230,18 @@ public void editPerformed(AjaxRequestTarget target, boolean editable) {
editor.setReadonly(!editable);
editor.refreshReadonly(target);
}

private boolean isReport(PrismObject object){
if (object.getCompileTimeClass() != null && object.getCompileTimeClass() == ReportType.class){
return true;
}

if (object.getDefinition() != null && object.getDefinition().getName().equals(ReportType.COMPLEX_TYPE)){
return true;
}

return false;
}

public void savePerformed(AjaxRequestTarget target) {
ObjectViewDto dto = model.getObject();
Expand Down Expand Up @@ -259,6 +273,11 @@ public void savePerformed(AjaxRequestTarget target) {
LOGGER.warn("No prism context in delta {} after diff, adding it", delta);
delta.setPrismContext(getPrismContext());
}

//quick fix for now (MID-1910), maybe it should be somewhere in model..
if (isReport(oldObject)){
ReportTypeUtil.applyConfigurationDefinition((PrismObject)newObject, delta, getPrismContext());
}

Collection<ObjectDelta<? extends ObjectType>> deltas = (Collection) MiscUtil.createCollection(delta);
ModelExecuteOptions options = ModelExecuteOptions.createRaw();
Expand Down
Expand Up @@ -95,8 +95,8 @@ public static <T extends ObjectType> List<T> toObjectableList(List<PrismObject<T
public static ImportOptionsType getDefaultImportOptions() {
ImportOptionsType options = new ImportOptionsType();
options.setOverwrite(false);
options.setValidateStaticSchema(true);
options.setValidateDynamicSchema(true);
options.setValidateStaticSchema(false);
options.setValidateDynamicSchema(false);
options.setEncryptProtectedValues(true);
options.setFetchResourceSchema(false);
options.setSummarizeErrors(true);
Expand Down
Expand Up @@ -16,7 +16,12 @@

package com.evolveum.midpoint.schema.util;

import java.util.Collection;

import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.schema.PrismSchema;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportConfigurationType;
Expand Down Expand Up @@ -77,5 +82,30 @@ public static void applyDefinition(PrismObject<ReportType> report, PrismContext
}

configuration.applyDefinition(definition, true);
}

public static void applyConfigurationDefinition(PrismObject<ReportType> report, ObjectDelta delta, PrismContext prismContext)
throws SchemaException {

PrismSchema schema = ReportTypeUtil.parseReportConfigurationSchema(report, prismContext);
PrismContainerDefinition<ReportConfigurationType> definition = ReportTypeUtil.findReportConfigurationDefinition(schema);
if (definition == null) {
//no definition found for container
throw new SchemaException("Couldn't find definitions for report type " + report + ".");
}
Collection<ItemDelta> modifications = delta.getModifications();
for (ItemDelta itemDelta : modifications){
if (itemDelta.hasCompleteDefinition()){
continue;
}
ItemDefinition def = definition.findItemDefinition(itemDelta.getPath().tail());
if (def != null){
itemDelta.applyDefinition(def);
}
}




}
}
Expand Up @@ -667,27 +667,31 @@ public void test002CreateReportFromFile() throws Exception {
//WHEN
TestUtil.displayWhen(TEST_NAME);
PrismObject<ReportType> reportType = prismContext.parseObject(TEST_REPORT_FILE);
LOGGER.info("report template: " + new String(Base64.decodeBase64(reportType.asObjectable().getTemplate())));
LOGGER.info("report template style: " + new String(Base64.decodeBase64(reportType.asObjectable().getTemplateStyle())));
LOGGER.info("Parsed: " + reportType.debugDump());
// LOGGER.info("report template: " + new String(Base64.decodeBase64(reportType.asObjectable().getTemplate())));
// LOGGER.info("report template style: " + new String(Base64.decodeBase64(reportType.asObjectable().getTemplateStyle())));
// LOGGER.info("Parsed: " + reportType.debugDump());
repoAddObject(ReportType.class, reportType, result);
// importObjectFromFile(TEST_REPORT_FILE);

PrismObject<ReportType> reportFromRepo = modelService.getObject(ReportType.class, TEST_REPORT_OID, null, task, result);
LOGGER.info("REPO: " + reportFromRepo.debugDump());
LOGGER.info("report template: " + new String(Base64.decodeBase64(reportFromRepo.asObjectable().getTemplate())));
LOGGER.info("report template style: " + new String(Base64.decodeBase64(reportFromRepo.asObjectable().getTemplateStyle())));
ObjectDelta delta = reportType.diff(reportFromRepo);
AssertJUnit.assertTrue("Delta must be null", delta.isEmpty());
LOGGER.info("delta: " + delta.debugDump());
// LOGGER.info("REPO: " + reportFromRepo.debugDump());
// LOGGER.info("report template: " + new String(Base64.decodeBase64(reportFromRepo.asObjectable().getTemplate())));
// LOGGER.info("report template style: " + new String(Base64.decodeBase64(reportFromRepo.asObjectable().getTemplateStyle())));

// ObjectDelta delta = reportType.diff(reportFromRepo);
// LOGGER.info("delta: " + delta.debugDump());
// AssertJUnit.assertTrue("Delta must be null", delta.isEmpty());


PrismObject<ReportType> reportFromutils = ReportUtils.getReport(TEST_REPORT_OID, result, modelService).asPrismObject();
LOGGER.info("UTILS: " + reportFromutils.debugDump());
LOGGER.info("report template: " + new String(Base64.decodeBase64(reportFromutils.asObjectable().getTemplate())));
LOGGER.info("report template style: " + new String(Base64.decodeBase64(reportFromutils.asObjectable().getTemplateStyle())));
ObjectDelta delta2 = reportFromRepo.diff(reportFromutils);
AssertJUnit.assertTrue("Delta must be null", delta2.isEmpty());
LOGGER.info("delta: " + delta2.debugDump());
// LOGGER.info("UTILS: " + reportFromutils.debugDump());
// LOGGER.info("report template: " + new String(Base64.decodeBase64(reportFromutils.asObjectable().getTemplate())));
// LOGGER.info("report template style: " + new String(Base64.decodeBase64(reportFromutils.asObjectable().getTemplateStyle())));

// ObjectDelta delta2 = reportFromRepo.diff(reportFromutils);
// LOGGER.info("delta: " + delta2.debugDump());
// AssertJUnit.assertTrue("Delta must be null", delta2.isEmpty());



//THEN
Expand Down
Expand Up @@ -41,9 +41,8 @@
</c:activation>
<c:credentials xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3">
<c:password>
<c:value xmlns:enc="http://www.w3.org/2001/04/xmlenc#"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<t:clearValue>5ecr3t</t:clearValue>
<c:value>
<t:clearValue>5ecr3t</t:clearValue>
</c:value>
</c:password>
</c:credentials>
Expand Down

0 comments on commit d92957e

Please sign in to comment.