Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/plugin-support
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Sep 12, 2019
2 parents fad7e58 + 34e2f52 commit 6817acc
Show file tree
Hide file tree
Showing 30 changed files with 205 additions and 571 deletions.
Expand Up @@ -635,7 +635,7 @@ public static void iterativeExecuteBulkAction(PageBase pageBase, ExecuteScriptTy
}

public static void executeMemberOperation(Task operationalTask, QName type, ObjectQuery memberQuery,
ExecuteScriptType script, OperationResult parentResult, PageBase pageBase) throws SchemaException {
ExecuteScriptType script, Collection<SelectorOptions<GetOperationOptions>> option, OperationResult parentResult, PageBase pageBase) throws SchemaException {

MidPointPrincipal owner = SecurityUtils.getPrincipalUser();
operationalTask.setOwner(owner.getUser().asPrismObject());
Expand All @@ -661,6 +661,14 @@ public static void executeMemberOperation(Task operationalTask, QName type, Obje
typeProperty.setRealValue(type);
operationalTask.addExtensionProperty(typeProperty);

if (option != null) {
PrismPropertyDefinition propertyDefOption = pageBase.getPrismContext().getSchemaRegistry()
.findPropertyDefinitionByElementName(SchemaConstants.MODEL_EXTENSION_SEARCH_OPTIONS);
PrismProperty<SelectorQualifiedGetOptionsType> optionProperty = propertyDefOption.instantiate();
optionProperty.setRealValue(MiscSchemaUtil.optionsToOptionsType(option));
operationalTask.addExtensionProperty(optionProperty);
}

try {
iterativeExecuteBulkAction(pageBase, script, operationalTask, parentResult);
parentResult.recordInProgress();
Expand Down
Expand Up @@ -56,6 +56,14 @@ <h3 style="margin-left: 20px;">
<div wicket:id="propertyTargetType"/>
</td>
</tr>
<tr>
<td>
<wicket:message key="JasperReportParameterProperties.required"/>
</td>
<td>
<div wicket:id="propertyRequired"/>
</td>
</tr>

</table>
</div>
Expand Down
Expand Up @@ -13,6 +13,7 @@
import org.apache.wicket.model.StringResourceModel;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.component.form.CheckBoxPanel;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.dialog.Popupable;
import com.evolveum.midpoint.web.component.input.TextPanel;
Expand All @@ -26,6 +27,7 @@ public class ParameterPropertiesPopupPanel extends BasePanel<JasperReportParamet
private static final String ID_KEY = "propertyKey";
private static final String ID_LABEL = "propertyLabel";
private static final String ID_TARGET_TYPE = "propertyTargetType";
private static final String ID_REQUIRED = "propertyRequired";
// private static final String ID_MULTIVALUE = "propertyMultivalue";

private static final String ID_BUTTON_UPDATE = "update";
Expand All @@ -42,6 +44,8 @@ private void initLayout() {
addTextPanel(ID_KEY, "key");
addTextPanel(ID_LABEL, "label");
addTextPanel(ID_TARGET_TYPE, "targetType");
CheckBoxPanel multivalue = new CheckBoxPanel(ID_REQUIRED, new PropertyModel<>(getModel(), "mandatory"));
add(multivalue);
// CheckBoxPanel multivalue = new CheckBoxPanel(ID_MULTIVALUE, new PropertyModel<>(getModel(), "multivalue"), Model.of(Boolean.TRUE));
// add(multivalue);

Expand Down
Expand Up @@ -43,6 +43,8 @@ <h3 style="margin-left: 20px;">
<tr wicket:id="paramPanel">
<td>
<label wicket:id="name" />
<span wicket:id="required" style="color: #f00; font-weight: bold;"
wicket:message="title:prismPropertyPanel.required">*</span>
</td>
<td>
<label wicket:id="type" />
Expand Down
Expand Up @@ -63,6 +63,7 @@
import com.evolveum.midpoint.web.component.input.TextPanel;
import com.evolveum.midpoint.web.component.message.FeedbackAlerts;
import com.evolveum.midpoint.web.component.prism.InputPanel;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.model.LookupPropertyModel;
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour;
Expand Down Expand Up @@ -180,6 +181,12 @@ private WebMarkupContainer createParameterPanel(final IModel<JasperReportParamet

paramPanel.add(new Label("name", paramDisplay)); // use display name rather than property name

WebMarkupContainer required = new WebMarkupContainer("required");
JasperReportParameterPropertiesDto properties = parameterModel.getObject().getProperties();
boolean mandatory = (properties != null && properties.getMandatory());
required.add(new VisibleBehaviour(() -> mandatory));
paramPanel.add(required);

String paramClass = new PropertyModel<String>(parameterModel, "nestedTypeAsString").getObject();
if (StringUtils.isBlank(paramClass)) {
paramClass = new PropertyModel<String>(parameterModel, "typeAsString").getObject();
Expand All @@ -193,7 +200,7 @@ private WebMarkupContainer createParameterPanel(final IModel<JasperReportParamet

@Override
protected void populateItem(ListItem<JasperReportValueDto> item) {
item.add(createInputMarkup(item.getModel(), parameterModel.getObject()));
item.add(createInputMarkup(item.getModel(), parameterModel.getObject(), mandatory, paramDisplay));

}

Expand All @@ -204,12 +211,14 @@ protected void populateItem(ListItem<JasperReportValueDto> item) {
return paramPanel;
}

private WebMarkupContainer createInputMarkup(final IModel<JasperReportValueDto> valueModel, JasperReportParameterDto param) {
private WebMarkupContainer createInputMarkup(final IModel<JasperReportValueDto> valueModel, JasperReportParameterDto param, boolean required, IModel<String> name) {
param.setEditing(true);
WebMarkupContainer paramValueMarkup = new WebMarkupContainer("valueMarkup");
paramValueMarkup.setOutputMarkupId(true);

InputPanel input = createTypedInputPanel("inputValue", valueModel, "value", param);
input.getBaseFormComponent().setRequired(required);
input.getBaseFormComponent().setLabel(name);
paramValueMarkup.add(input);

//buttons
Expand Down
Expand Up @@ -15,6 +15,7 @@ public class JasperReportParameterPropertiesDto implements Serializable{
private static final String PROPERTY_LABEL = "label";
private static final String PROPERTY_TARGET_TYPE = "targetType";
private static final String PROPERTY_MULTIVALUE = "multivalue";
private static final String MANDATORY_KEY = "mandatory";


private JRPropertiesMap propertiesMap;
Expand Down Expand Up @@ -87,6 +88,25 @@ public void setKey(String key) {

propertiesMap.setProperty(PROPERTY_KEY, key);
}

public boolean getMandatory() {
if (propertiesMap == null) {
return false;
}
String isMandatory = propertiesMap.getProperty(MANDATORY_KEY);
if (isMandatory != null && Boolean.valueOf(isMandatory)) {
return true;
}
return false;
}

public void setMandatory(boolean isMandatory) {
if (propertiesMap == null) {
propertiesMap = new JRPropertiesMap();
}

propertiesMap.setProperty(MANDATORY_KEY, String.valueOf(isMandatory));
}

public JRPropertiesMap getPropertiesMap() {
return propertiesMap;
Expand Down
Expand Up @@ -30,6 +30,8 @@
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.query.builder.S_AtomicFilterExit;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
Expand Down Expand Up @@ -102,7 +104,7 @@ public static <R extends AbstractRoleType> void unassignMembersPerformed(PageBas
// operationalTask.getResult().recordFatalError("Can not create ObjectQuery from " + query, e);
// }

executeMemberOperation(pageBase, operationalTask, type, query, script, target);
executeMemberOperation(pageBase, operationalTask, type, query, script, null, target);

}

Expand Down Expand Up @@ -131,7 +133,7 @@ public static void assignMembersPerformed(AbstractRoleType targetObject, ObjectQ
// operationalTask.getResult().recordFatalError("Can not create ObjectQuery from " + query, e);
// }

executeMemberOperation(pageBase, operationalTask, type, query, script, target);
executeMemberOperation(pageBase, operationalTask, type, query, script, null, target);
}

public static <R extends AbstractRoleType> void deleteMembersPerformed(PageBase pageBase, QueryScope scope,
Expand Down Expand Up @@ -163,7 +165,7 @@ private static <R extends AbstractRoleType> void recomputeOrDeleteMembersPerform
// operationalTask.getResult().recordFatalError("Can not create ObjectQuery from " + query, e);
// }

executeMemberOperation(pageBase, operationalTask, defaultType, query, script, target);
executeMemberOperation(pageBase, operationalTask, defaultType, query, script, SelectorOptions.createCollection(GetOperationOptions.createDistinct()), target);

}

Expand Down Expand Up @@ -335,11 +337,11 @@ public static <R extends AbstractRoleType> ObjectReferenceType createReference(R
}

protected static void executeMemberOperation(PageBase modelServiceLocator, Task operationalTask, QName type, ObjectQuery memberQuery,
ExecuteScriptType script, AjaxRequestTarget target) {
ExecuteScriptType script, Collection<SelectorOptions<GetOperationOptions>> option, AjaxRequestTarget target) {

OperationResult parentResult = operationalTask.getResult();
try {
WebComponentUtil.executeMemberOperation(operationalTask, type, memberQuery, script, parentResult, modelServiceLocator);
WebComponentUtil.executeMemberOperation(operationalTask, type, memberQuery, script, option, parentResult, modelServiceLocator);
} catch (SchemaException e) {
parentResult.recordFatalError(parentResult.getOperation(), e);
LoggingUtils.logUnexpectedException(LOGGER,
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -149,11 +149,15 @@ public static <T extends PrismValue> Collection<T> resetParentCollection(Collect
}

public static <T> Set<T> getRealValuesOfCollection(Collection<? extends PrismValue> collection) {
Set<T> retval = new HashSet<>(collection.size());
for (PrismValue value : collection) {
retval.add(value.getRealValue());
}
return retval;
if (collection != null) {
Set<T> retval = new HashSet<>(collection.size());
for (PrismValue value : collection) {
retval.add(value.getRealValue());
}
return retval;
} else {
return Collections.emptySet();
}
}


Expand Down
Expand Up @@ -43,7 +43,7 @@ public interface ValueFilter<V extends PrismValue, D extends ItemDefinition> ext

void setMatchingRule(@Nullable QName matchingRule);

@NotNull
//@NotNull
//MatchingRule getMatchingRuleFromRegistry(MatchingRuleRegistry matchingRuleRegistry, Item filterItem);

@Nullable
Expand Down
Expand Up @@ -399,18 +399,18 @@ protected void debugDump(int indent, StringBuilder sb) {
}
}

protected String toString(StringBuilder sb){
protected String toString(StringBuilder sb) {
sb.append(getFullPath().toString());
sb.append(",");
if (getValues() != null){
for (int i = 0; i< getValues().size() ; i++){
if (getValues() != null) {
for (int i = 0; i< getValues().size() ; i++) {
PrismValue value = getValues().get(i);
if (value == null) {
sb.append("null");
} else {
sb.append(value.toString());
}
if ( i != getValues().size() -1){
if (i != getValues().size() -1) {
sb.append(",");
}
}
Expand Down
Expand Up @@ -216,16 +216,12 @@ private boolean checkUniqueness(String oid, PrismProperty identifier, ObjectQuer
return true;
}

// Here was an attempt to call cacheRepositoryService.searchObjects directly (because we use noFetch, so the net result is searching in repo anyway).
// The idea was that it is faster and cacheable. However, it is not correct. We have to apply definition to query before execution, e.g.
// because there could be a matching rule; see ShadowManager.processQueryMatchingRuleFilter.
// Besides that, now the constraint checking is cached at a higher level, so this is not a big issue any more.
// Note that we should not call repository service directly here. The query values need to be normalized according to
// attribute matching rules.
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch());
List<PrismObject<ShadowType>> foundObjects = shadowCache.searchObjects(query, options, task, result);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Uniqueness check of {} resulted in {} results:\n{}\nquery:\n{}",
identifier, foundObjects.size(), foundObjects, query.debugDump(1));
}
LOGGER.trace("Uniqueness check of {} resulted in {} results:\n{}\nquery:\n{}",
identifier, foundObjects.size(), foundObjects, query.debugDumpLazily(1));
if (foundObjects.isEmpty()) {
if (useCache) {
Cache.setOk(resourceType.getOid(), oid, objectClassDefinition.getTypeName(), identifier.getDefinition().getItemName(), identifier.getValues());
Expand Down
Expand Up @@ -477,9 +477,7 @@ public <T extends ObjectType> SearchResultList<PrismObject<T>> searchObjects(Cla
result.addParam("query", query);
result.addContext(OperationResult.CONTEXT_IMPLEMENTATION_CLASS, ProvisioningServiceImpl.class);

if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Start of (non-iterative) search objects. Query:\n{}", query != null ? query.debugDump(1) : " (null)");
}
LOGGER.trace("Start of (non-iterative) search objects. Query:\n{}", query != null ? query.debugDumpLazily(1) : " (null)");

query = simplifyQueryFilter(query);
ObjectFilter filter = query != null ? query.getFilter() : null;
Expand Down Expand Up @@ -541,8 +539,7 @@ private <T extends ObjectType> SearchResultList<PrismObject<T>> searchRepoObject

SearchResultList<PrismObject<T>> newObjListType = new SearchResultList(new ArrayList<PrismObject<T>>());
for (PrismObject<T> repoObject : repoObjects) {
OperationResult objResult = new OperationResult(ProvisioningService.class.getName()
+ ".searchObjects.object");
OperationResult objResult = new OperationResult(ProvisioningService.class.getName() + ".searchObjects.object");

try {

Expand All @@ -565,13 +562,10 @@ private <T extends ObjectType> SearchResultList<PrismObject<T>> searchRepoObject
result.recordPartialError(e);

} catch (RuntimeException e) {
// FIXME: Strictly speaking, the runtime exception should
// not be handled here.
// The runtime exceptions should be considered fatal anyway
// ... but some of the
// ICF exceptions are still translated to system exceptions.
// So this provides
// a better robustness now.
// FIXME: Strictly speaking, the runtime exception should not be handled here.
// The runtime exceptions should be considered fatal anyway ... but some of the
// ICF exceptions are still translated to system exceptions. So this provides
// a better robustness now.
LOGGER.error("System error while completing {}: {}-{}. Using non-complete object.", repoObject, e.getMessage(), e);
objResult.recordFatalError(e);
repoObject.asObjectable().setFetchResult(objResult.createOperationResultType());
Expand Down Expand Up @@ -896,16 +890,10 @@ public List<PrismObject<? extends ShadowType>> listResourceObjects(String resour
ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(resourceOid, objectClass, prismContext);

final List<PrismObject<? extends ShadowType>> objectList = new ArrayList<>();
final ResultHandler<ShadowType> shadowHandler = new ResultHandler<ShadowType>() {
@Override
public boolean handle(PrismObject<ShadowType> shadow, OperationResult objResult) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("listResourceObjects: processing shadow: {}", SchemaDebugUtil.prettyPrint(shadow));
}

objectList.add(shadow);
return true;
}
final ResultHandler<ShadowType> shadowHandler = (shadow, objResult) -> {
LOGGER.trace("listResourceObjects: processing shadow: {}", SchemaDebugUtil.prettyPrintLazily(shadow));
objectList.add(shadow);
return true;
};

try {
Expand Down Expand Up @@ -980,12 +968,12 @@ private <T extends ObjectType> boolean handleRepoObject(final Class<T> type, Pri

}

@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({ "unchecked" })
@Override
public <T extends ObjectType> SearchResultMetadata searchObjectsIterative(final Class<T> type, ObjectQuery query,
final Collection<SelectorOptions<GetOperationOptions>> options,
final ResultHandler<T> handler, Task task, final OperationResult parentResult) throws SchemaException,
ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
public <T extends ObjectType> SearchResultMetadata searchObjectsIterative(Class<T> type, ObjectQuery query,
Collection<SelectorOptions<GetOperationOptions>> options, ResultHandler<T> handler, Task task,
OperationResult parentResult) throws SchemaException, ObjectNotFoundException, CommunicationException,
ConfigurationException, SecurityViolationException, ExpressionEvaluationException {

Validate.notNull(parentResult, "Operation result must not be null.");
Validate.notNull(handler, "Handler must not be null.");
Expand All @@ -994,8 +982,7 @@ public <T extends ObjectType> SearchResultMetadata searchObjectsIterative(final
LOGGER.trace("Start of (iterative) search objects. Query:\n{}", query != null ? query.debugDump(1) : " (null)");
}

final OperationResult result = parentResult.createSubresult(ProvisioningService.class.getName()
+ ".searchObjectsIterative");
OperationResult result = parentResult.createSubresult(ProvisioningService.class.getName() + ".searchObjectsIterative");
result.setSummarizeSuccesses(true);
result.setSummarizeErrors(true);
result.setSummarizePartialErrors(true);
Expand Down
Expand Up @@ -116,21 +116,16 @@ PrismObject<ShadowType> resolve(ProvisioningContext ctx, ResourceObjectReference

// TODO: implement "repo" search strategies, don't forget to apply definitions

Collection<SelectorOptions<GetOperationOptions>> options = null;

final Holder<PrismObject<ShadowType>> shadowHolder = new Holder<>();
ResultHandler<ShadowType> handler = new ResultHandler<ShadowType>() {
@Override
public boolean handle(PrismObject<ShadowType> shadow, OperationResult objResult) {
if (shadowHolder.getValue() != null) {
throw new IllegalStateException("More than one search results for " + desc);
}
shadowHolder.setValue(shadow);
return true;
ResultHandler<ShadowType> handler = (shadow, objResult) -> {
if (shadowHolder.getValue() != null) {
throw new IllegalStateException("More than one search results for " + desc);
}
shadowHolder.setValue(shadow);
return true;
};

shadowCache.searchObjectsIterative(subctx, query, options, handler, true, result);
shadowCache.searchObjectsIterative(subctx, query, null, handler, true, result);

// TODO: implement storage of OID (ONCE search frequency)

Expand Down

0 comments on commit 6817acc

Please sign in to comment.