use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType in project midpoint by Evolveum.
the class PageAccounts method createObjectQuery.
private ObjectQuery createObjectQuery() {
AccountDetailsSearchDto dto = searchModel.getObject();
String searchText = dto.getText();
ShadowKindType kind = dto.getKind();
String intent = dto.getIntent();
String objectClass = dto.getObjectClass();
FailedOperationTypeType failedOperatonType = dto.getFailedOperationType();
S_AtomicFilterEntry q = QueryBuilder.queryFor(ShadowType.class, getPrismContext());
if (StringUtils.isNotEmpty(searchText)) {
PolyStringNormalizer normalizer = getPrismContext().getDefaultPolyStringNormalizer();
String normalized = normalizer.normalize(searchText);
q = q.item(ShadowType.F_NAME).contains(normalized).matchingNorm().and();
}
if (kind != null) {
q = q.item(ShadowType.F_KIND).eq(kind).and();
}
if (StringUtils.isNotEmpty(intent)) {
q = q.item(ShadowType.F_INTENT).eq(intent).and();
}
if (failedOperatonType != null) {
q = q.item(ShadowType.F_FAILED_OPERATION_TYPE).eq(failedOperatonType).and();
}
if (StringUtils.isNotEmpty(objectClass)) {
QName objClass = new QName(objectClass);
for (QName qn : dto.getObjectClassList()) {
if (objectClass.equals(qn.getLocalPart())) {
objClass = qn;
}
}
q = q.item(ShadowType.F_OBJECT_CLASS).eq(objClass).and();
}
return appendResourceQueryFilter(q);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType in project midpoint by Evolveum.
the class ResourceTypeAssignmentPopupTabPanel method initParametersPanel.
@Override
protected void initParametersPanel(Fragment parametersPanel) {
initModels();
WebMarkupContainer kindContainer = new WebMarkupContainer(ID_KIND_CONTAINER);
kindContainer.setOutputMarkupId(true);
parametersPanel.add(kindContainer);
DropDownChoicePanel<ShadowKindType> kindSelector = WebComponentUtil.createEnumPanel(ShadowKindType.class, ID_KIND, WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), Model.of(), ResourceTypeAssignmentPopupTabPanel.this, true);
kindSelector.setOutputMarkupId(true);
kindSelector.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
kindValueUpdatePerformed(target);
}
});
kindSelector.getBaseFormComponent().add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return getSelectedObjectsList() != null && getSelectedObjectsList().size() > 0;
}
});
kindSelector.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
kindSelector.setOutputMarkupPlaceholderTag(true);
kindContainer.add(kindSelector);
WebMarkupContainer intentContainer = new WebMarkupContainer(ID_INTENT_CONTAINER);
intentContainer.setOutputMarkupId(true);
parametersPanel.add(intentContainer);
DropDownChoicePanel<String> intentSelector = new DropDownChoicePanel<String>(ID_INTENT, Model.of(), intentValues, true);
intentSelector.getBaseFormComponent().add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return getKindValue() != null && getSelectedObjectsList() != null && getSelectedObjectsList().size() > 0;
}
});
intentSelector.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
intentValueUpdatePerformed(target);
}
});
intentSelector.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
intentSelector.setOutputMarkupId(true);
intentSelector.setOutputMarkupPlaceholderTag(true);
intentContainer.add(intentSelector);
WebMarkupContainer associationContainer = new WebMarkupContainer(ID_ASSOCIATION_CONTAINER);
associationContainer.setOutputMarkupId(true);
associationContainer.add(new VisibleBehaviour(() -> isEntitlementAssignment()));
parametersPanel.add(associationContainer);
DropDownChoicePanel<ResourceAssociationDefinition> associationSelector = new DropDownChoicePanel<>(ID_ASSOCIATION, Model.of(), associationValuesModel, new IChoiceRenderer<ResourceAssociationDefinition>() {
private static final long serialVersionUID = 1L;
@Override
public Object getDisplayValue(ResourceAssociationDefinition refinedAssociationDefinition) {
return WebComponentUtil.getAssociationDisplayName(refinedAssociationDefinition);
}
@Override
public String getIdValue(ResourceAssociationDefinition refinedAssociationDefinition, int index) {
return Integer.toString(index);
}
@Override
public ResourceAssociationDefinition getObject(String id, IModel<? extends List<? extends ResourceAssociationDefinition>> choices) {
return StringUtils.isNotBlank(id) ? choices.getObject().get(Integer.parseInt(id)) : null;
}
}, true);
associationSelector.setOutputMarkupId(true);
associationSelector.getBaseFormComponent().add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return getSelectedObjectsList() != null && getSelectedObjectsList().size() > 0 && getKindValue() != null && StringUtils.isNotEmpty(getIntentValue());
}
});
associationSelector.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
associationSelector.setOutputMarkupPlaceholderTag(true);
associationContainer.add(associationSelector);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType in project midpoint by Evolveum.
the class SynchronizationUtils method isPolicyApplicable.
/**
* Checks if the synchronization policy matches given "parameters" (object class, kind, intent).
*/
public static boolean isPolicyApplicable(QName objectClass, ShadowKindType kind, String intent, @NotNull ObjectSynchronizationType synchronizationPolicy, PrismObject<ResourceType> resource, boolean strictIntent) throws SchemaException {
if (objectClassDefinedAndNotMatching(objectClass, synchronizationPolicy.getObjectClass())) {
return false;
}
ResourceSchema schema = ResourceSchemaFactory.getCompleteSchema(resource);
Objects.requireNonNull(schema, "No schema defined in resource. Possible configuration problem?");
ShadowKindType policyKind = requireNonNullElse(synchronizationPolicy.getKind(), ACCOUNT);
String policyIntent = synchronizationPolicy.getIntent();
ResourceObjectDefinition policyObjectClass;
if (StringUtils.isEmpty(policyIntent)) {
// TODO check this
policyObjectClass = schema.findObjectDefinition(policyKind, null);
if (policyObjectClass instanceof ResourceObjectTypeDefinition) {
policyIntent = ((ResourceObjectTypeDefinition) policyObjectClass).getIntent();
}
} else {
policyObjectClass = schema.findObjectDefinition(policyKind, policyIntent);
}
if (policyObjectClass == null) {
return false;
}
// re-check objectClass if wasn't defined
if (objectClassDefinedAndNotMatching(objectClass, List.of(policyObjectClass.getTypeName()))) {
return false;
}
// kind
LOGGER.trace("Comparing kinds, policy kind: {}, current kind: {}", policyKind, kind);
if (kind != null && kind != UNKNOWN && !policyKind.equals(kind)) {
LOGGER.trace("Kinds don't match, skipping policy {}", synchronizationPolicy);
return false;
}
// intent
// TODO is the intent always present in shadow at this time? [med]
LOGGER.trace("Comparing intents, policy intent: {}, current intent: {}", policyIntent, intent);
if (!strictIntent) {
if (intent != null && !SchemaConstants.INTENT_UNKNOWN.equals(intent) && !MiscSchemaUtil.equalsIntent(intent, policyIntent)) {
LOGGER.trace("Intents don't match, skipping policy {}", synchronizationPolicy);
return false;
}
} else {
if (!MiscSchemaUtil.equalsIntent(intent, policyIntent)) {
LOGGER.trace("Intents don't match, skipping policy {}", synchronizationPolicy);
return false;
}
}
return true;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType in project midpoint by Evolveum.
the class ResourceObjectClassifierImpl method createClassification.
@NotNull
private Classification createClassification(PrismObject<ShadowType> combinedObject, SynchronizationContext<?> syncCtx) throws SchemaException {
ShadowType objectBean = combinedObject.asObjectable();
// This is how original synchronization service was implemented: it did not overwrite previously known values.
ShadowKindType newKind = ShadowUtil.isKnown(objectBean.getKind()) ? objectBean.getKind() : syncCtx.getKind();
String newIntent = ShadowUtil.isKnown(objectBean.getIntent()) ? objectBean.getIntent() : syncCtx.getIntent();
// And as for the tag, currently it creates syncCtx.tag value only if it really wants it to be changed.
// Otherwise it is null.
String newTag = objectBean.getTag() != null ? objectBean.getTag() : syncCtx.getTag();
return new Classification(newKind, newIntent, newTag);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method createConstructionAssignment.
protected AssignmentType createConstructionAssignment(String resourceOid, ShadowKindType kind, String intent) {
AssignmentType assignmentType = new AssignmentType();
ConstructionType constructionType = new ConstructionType();
constructionType.setKind(kind);
assignmentType.setConstruction(constructionType);
ObjectReferenceType resourceRef = new ObjectReferenceType();
resourceRef.setOid(resourceOid);
resourceRef.setType(ResourceType.COMPLEX_TYPE);
constructionType.setResourceRef(resourceRef);
constructionType.setIntent(intent);
return assignmentType;
}
Aggregations