Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Sep 21, 2021
2 parents 5d0bf0d + ff4e73a commit d3608d5
Show file tree
Hide file tree
Showing 16 changed files with 361 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ private CompositedIcon createCompositedIcon(CompiledObjectCollectionView collect
CompositedIconBuilder builder = new CompositedIconBuilder();

builder.setBasicIcon(WebComponentUtil.getIconCssClass(additionalButtonDisplayType), IconCssStyle.IN_ROW_STYLE)
.appendColorHtmlValue(WebComponentUtil.getIconColor(additionalButtonDisplayType));
.appendColorHtmlValue(WebComponentUtil.getIconColor(additionalButtonDisplayType))
.setTitle(WebComponentUtil.getTranslatedPolyString(additionalButtonDisplayType.getTooltip()));
// .appendLayerIcon(WebComponentUtil.createIconType(GuiStyleConstants.CLASS_PLUS_CIRCLE, "green"), IconCssStyle.BOTTOM_RIGHT_STYLE);

return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ public void test510OpenNextStage() throws Exception { // next stage is
display("campaign in stage 2", campaign);
assertSanityAfterStageOpen(campaign, certificationDefinition, 2, 2, 5); // stage 1 in iteration 2 was skipped

List<AccessCertificationCaseType> caseList = queryHelper.searchCases(campaignOid, null, null, result);
List<AccessCertificationCaseType> caseList = new ArrayList<>(queryHelper.searchCases(campaignOid, null, null, result));
caseList.removeIf(c -> norm(c.getIteration()) != 2);
assertEquals("Wrong number of certification cases", 3, caseList.size());
AccessCertificationCaseType administratorCeoCase = findCase(caseList, USER_ADMINISTRATOR_OID, ROLE_CEO_OID);
Expand Down
3 changes: 2 additions & 1 deletion repo/repo-sqale/sql/pgnew-repo.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,9 @@ CREATE TABLE m_task (
category TEXT, -- TODO revise, deprecated, probably can go away soon
completionTimestamp TIMESTAMPTZ,
executionState TaskExecutionStateType,
-- Logically fullResult and resultStatus are related, managed by Task manager.
fullResult BYTEA,
resultStatus OperationResultStatusType,
handlerUriId INTEGER REFERENCES m_uri(id),
lastRunStartTimestamp TIMESTAMPTZ,
lastRunFinishTimestamp TIMESTAMPTZ,
Expand All @@ -1164,7 +1166,6 @@ CREATE TABLE m_task (
ownerRefRelationId INTEGER REFERENCES m_uri(id),
parent TEXT, -- value of taskIdentifier
recurrence TaskRecurrenceType,
resultStatus OperationResultStatusType,
schedulingState TaskSchedulingStateType,
autoScalingMode TaskAutoScalingModeType, -- autoScaling/mode
threadStopAction ThreadStopActionType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public ContainerValueIdGenerator forModifyObject(long containerIdSeq) throws Sch
LOGGER.warn("Current CID sequence (" + containerIdSeq + ") is not above max used CID ("
+ maxUsedId + ") for " + object.toDebugType() + "/" + object.getOid()
+ ". CID sequence will be fixed, but it's suspicious!");
} else {
// TODO: Is this correct? containerIdSeq is used to reboot sequence of cids (eg. if
// cids are not in full object, but other items
maxUsedId = containerIdSeq != 0 ? containerIdSeq - 1 : 0;
}
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.evolveum.midpoint.repo.sqale;

import java.lang.reflect.Array;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Set;
import javax.annotation.PostConstruct;
Expand All @@ -19,6 +20,7 @@
import org.jetbrains.annotations.Nullable;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.SerializationOptions;
import com.evolveum.midpoint.prism.delta.ChangeType;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.repo.sqale.jsonb.Jsonb;
Expand All @@ -33,9 +35,12 @@
import com.evolveum.midpoint.repo.sqlbase.JdbcRepositoryConfiguration;
import com.evolveum.midpoint.repo.sqlbase.SqlRepoContext;
import com.evolveum.midpoint.repo.sqlbase.mapping.QueryModelMappingRegistry;
import com.evolveum.midpoint.schema.SchemaConstantsGenerated;
import com.evolveum.midpoint.schema.SchemaService;
import com.evolveum.midpoint.schema.util.FullTextSearchUtil;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventStageType;
import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventTypeType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
Expand Down Expand Up @@ -187,4 +192,18 @@ public <S extends ObjectType> boolean requiresFullTextReindex(
return FullTextSearchUtil.isObjectTextInfoRecomputationNeeded(
fullTextSearchConfig, prismObject.getCompileTimeClass(), modifications);
}

public byte[] createFullResult(OperationResultType operationResult) {
try {
// Note that escaping invalid characters and using toString for unsupported types
// is safe in the context of operation result serialization.
return createStringSerializer()
.options(SerializationOptions.createEscapeInvalidCharacters()
.serializeUnsupportedTypesAsString(true))
.serializeRealValue(operationResult, SchemaConstantsGenerated.C_OPERATION_RESULT)
.getBytes(StandardCharsets.UTF_8);
} catch (SchemaException e) {
throw new SystemException("Unexpected schema exception", e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public class SqaleRepositoryService extends SqaleServiceBase implements Reposito
private static final int MAX_CONFLICT_WATCHERS = 10;

private static final Collection<SelectorOptions<GetOperationOptions>> GET_FOR_UPDATE_OPTIONS =
SchemaService.get().getOperationOptionsBuilder().retrieve().build();
SchemaService.get().getOperationOptionsBuilder().build();

public static final String REPOSITORY_IMPL_NAME = "SQaLe";

Expand Down Expand Up @@ -474,7 +474,7 @@ private <T extends ObjectType> ModifyObjectResult<T> executeModifyObject(

try (JdbcSession transaction = sqlRepoContext.newJdbcSession().startTransaction()) {
RootUpdateContext<T, QObject<MObject>, MObject> updateContext =
prepareUpdateContext(transaction, type, oidUuid);
prepareUpdateContext(transaction, type, modifications, oidUuid, options);

// commit is executed inside this method
return modifyObjectInternal(updateContext, modifications,
Expand Down Expand Up @@ -537,7 +537,7 @@ private <T extends ObjectType> ModifyObjectResult<T> executeModifyObjectDynamica

try (JdbcSession transaction = sqlRepoContext.newJdbcSession().startTransaction()) {
RootUpdateContext<T, QObject<MObject>, MObject> updateContext =
prepareUpdateContext(transaction, type, oidUuid, getOptions);
prepareUpdateContext(transaction, type, oidUuid, getOptions, modifyOptions);

PrismObject<T> object = updateContext.getPrismObject();
Collection<? extends ItemDelta<?, ?>> modifications =
Expand Down Expand Up @@ -625,14 +625,30 @@ private <T extends ObjectType> ModifyObjectResult<T> modifyObjectInternal(
return new ModifyObjectResult<>(originalObject, prismObject, modifications);
}

/** Read object for update and returns update context that contains it. */
private <S extends ObjectType, Q extends QObject<R>, R extends MObject>
RootUpdateContext<S, Q, R> prepareUpdateContext(
@NotNull JdbcSession jdbcSession,
@NotNull Class<S> schemaType,
@NotNull UUID oid)
throws SchemaException, ObjectNotFoundException {
return prepareUpdateContext(jdbcSession, schemaType, oid, GET_FOR_UPDATE_OPTIONS);
return prepareUpdateContext(jdbcSession, schemaType, Collections.emptyList(), oid, null);
}

/** Read object for update and returns update context that contains it.
**/
private <S extends ObjectType, Q extends QObject<R>, R extends MObject>
RootUpdateContext<S, Q, R> prepareUpdateContext(
@NotNull JdbcSession jdbcSession,
@NotNull Class<S> schemaType,
@NotNull Collection<? extends ItemDelta<?, ?>> modifications,
@NotNull UUID oid, RepoModifyOptions options)
throws SchemaException, ObjectNotFoundException {

QueryTableMapping<S, FlexibleRelationalPathBase<Object>, Object> rootMapping = sqlRepoContext.getMappingBySchemaType(schemaType);
Collection<SelectorOptions<GetOperationOptions>> getOptions = rootMapping.updateGetOptions(GET_FOR_UPDATE_OPTIONS, modifications);


return prepareUpdateContext(jdbcSession, schemaType, oid, getOptions, options);
}

/** Read object for update and returns update context that contains it with specific get options. */
Expand All @@ -641,7 +657,8 @@ RootUpdateContext<S, Q, R> prepareUpdateContext(
@NotNull JdbcSession jdbcSession,
@NotNull Class<S> schemaType,
@NotNull UUID oid,
Collection<SelectorOptions<GetOperationOptions>> getOptions)
Collection<SelectorOptions<GetOperationOptions>> getOptions,
RepoModifyOptions options)
throws SchemaException, ObjectNotFoundException {

SqaleTableMapping<S, QObject<R>, R> rootMapping =
Expand All @@ -664,7 +681,7 @@ RootUpdateContext<S, Q, R> prepareUpdateContext(
}

S object = rootMapping.toSchemaObject(
result, entityPath, getOptions, jdbcSession, true);
result, entityPath, getOptions, jdbcSession, RepoModifyOptions.isForceReindex(options));

R rootRow = rootMapping.newRowObject();
rootRow.oid = oid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import com.evolveum.midpoint.prism.Item;
import com.evolveum.midpoint.prism.ItemDefinition;
import com.evolveum.midpoint.prism.PrismValue;
import com.evolveum.midpoint.prism.SerializationOptions;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.path.CanonicalItemPath;
import com.evolveum.midpoint.prism.path.ItemPath;
Expand Down Expand Up @@ -128,6 +127,11 @@ private void executeAudit(AuditEventRecord record) {

/**
* Inserts audit event record aggregate root without any subentities.
* Traditional Sqale "insert root first, then insert children" is not optimal here,
* because to insert root we need to collect some information from children anyway.
* So we prepare the subentities in collections, gather the needed information
* (e.g. changed item paths) and then insert root entity.
* Subentities are inserted later out of this method.
*
* @return inserted row with transient deltas prepared for insertion
*/
Expand Down Expand Up @@ -195,16 +199,12 @@ private MAuditDelta convertDelta(ObjectDeltaOperation<?> deltaOperation) {

OperationResult executionResult = deltaOperation.getExecutionResult();
if (executionResult != null) {
OperationResultType jaxb = executionResult.createOperationResultType();
if (jaxb != null) {
deltaRow.status = jaxb.getStatus();
OperationResultType operationResult = executionResult.createOperationResultType();
if (operationResult != null) {
deltaRow.status = operationResult.getStatus();
// Note that escaping invalid characters and using toString for unsupported types is safe in the
// context of operation result serialization.
deltaRow.fullResult = sqlRepoContext.createStringSerializer()
.options(SerializationOptions.createEscapeInvalidCharacters()
.serializeUnsupportedTypesAsString(true))
.serializeRealValue(jaxb, SchemaConstantsGenerated.C_OPERATION_RESULT)
.getBytes(StandardCharsets.UTF_8);
deltaRow.fullResult = sqlRepoContext.createFullResult(operationResult);
}
}
deltaRow.resourceOid = SqaleUtils.oidToUUid(deltaOperation.getResourceOid());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ public <Q extends FlexibleRelationalPathBase<R>, R> UriItemDeltaProcessor(

@Override
public @Nullable Integer convertRealValue(Object realValue) {
return context.repositoryContext().processCacheableUri((String) realValue);
return context.repositoryContext().processCacheableUri(realValue);
}
}

0 comments on commit d3608d5

Please sign in to comment.