Skip to content

Commit

Permalink
simulation: sequence prototyping started
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Nov 2, 2022
1 parent e3f2f9f commit 2909b83
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16154,12 +16154,13 @@
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="createOnDemand" type="tns:CreateOnDemandOptionsType"/>
<xsd:element name="createOnDemand" type="tns:SimulationOptionType" minOccurs="0"/>
<xsd:element name="sequence" type="tns:SimulationOptionType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>

<xsd:simpleType name="CreateOnDemandOptionsType">
<xsd:simpleType name="SimulationOptionType">
<xsd:annotation>
<xsd:documentation>
<!-- todo -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,18 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.model.api.ModelExecuteOptions;
import com.evolveum.midpoint.model.common.expression.ModelExpressionThreadLocalHolder;

import org.apache.commons.lang3.BooleanUtils;
import org.jetbrains.annotations.NotNull;

import com.evolveum.midpoint.common.LocalizationService;
import com.evolveum.midpoint.model.api.ModelExecuteOptions;
import com.evolveum.midpoint.model.api.ModelInteractionService;
import com.evolveum.midpoint.model.api.ModelService;
import com.evolveum.midpoint.model.api.context.ModelContext;
import com.evolveum.midpoint.model.api.context.ModelElementContext;
import com.evolveum.midpoint.model.common.expression.ModelExpressionThreadLocalHolder;
import com.evolveum.midpoint.model.common.expression.evaluator.caching.AbstractSearchExpressionEvaluatorCache;
import com.evolveum.midpoint.model.common.expression.evaluator.transformation.AbstractValueTransformationExpressionEvaluator;
import com.evolveum.midpoint.model.common.util.PopulatorUtil;
Expand Down Expand Up @@ -514,11 +512,7 @@ private PrismObject createOnDemand(Class<O> targetTypeClass, VariablesMap variab
try {
ModelContext<O> context = modelInteractionService.previewChanges(deltas, null, task, result);
ModelElementContext focusContext = context.getFocusContext();
PrismObject<O> newCodObject = focusContext.getObjectNew();
// if (newCodObject.getOid() == null) {
// newObject.setOid(UUID.randomUUID().toString());
// }
return newCodObject;
return focusContext.getObjectNew();
} catch (Exception ex) {
throw new ExpressionEvaluationException(ex.getMessage(), ex);
}
Expand Down Expand Up @@ -549,7 +543,7 @@ protected boolean isCreateOnDemandSafe() {
return isCreateOnDemandSafe;
}

return CreateOnDemandOptionsType.SAFE.equals(simulation.getCreateOnDemand());
return SimulationOptionType.SAFE.equals(simulation.getCreateOnDemand());
}

// Override the default in this case. It makes more sense like this.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,13 @@ protected QName getDefaultTargetType() {
public String shortDebugDump() {
return "associationExpression";
}

/**
* Create on demand used in AssociationTargetSearch would fail
* @return false
*/
@Override
protected boolean isCreateOnDemandSafe() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,24 @@ static long getSequenceCounterValue(String sequenceOid, RepositoryService reposi
if (alreadyObtainedValue != null) {
return alreadyObtainedValue;
} else {
long freshValue = repositoryService.advanceSequence(sequenceOid, result);
ctx.setSequenceCounter(sequenceOid, freshValue);
return freshValue;
if (!isAdvanceSequenceSafe()) {
long freshValue = repositoryService.advanceSequence(sequenceOid, result);
ctx.setSequenceCounter(sequenceOid, freshValue);
return freshValue;
} else {
// todo implement

return -1;
}
}
}

private static boolean isAdvanceSequenceSafe() {
boolean isAdvanceSequenceSafe = false;

return isAdvanceSequenceSafe;
}

@NotNull
private Item<V, D> addValueToOutputProperty(Object value) throws SchemaException {
//noinspection unchecked
Expand Down

0 comments on commit 2909b83

Please sign in to comment.