Skip to content

Commit

Permalink
fix for confirmation message and getting object class from schema (de…
Browse files Browse the repository at this point in the history
…fault of only one)
  • Loading branch information
skublik committed Apr 5, 2023
1 parent 3aefd8b commit 3052dfe
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.evolveum.midpoint.web.component.input.validator.NotNullValidator;
import com.evolveum.midpoint.web.component.prism.InputPanel;
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour;
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;

Expand Down Expand Up @@ -148,6 +149,7 @@ protected <C> IConverter<C> getAutoCompleteConverter(Class<C> type, IConverter<C
}
};
panel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
panel.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
return panel;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
import javax.xml.datatype.DatatypeFactory;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.util.exception.CommonException;

import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
Expand Down Expand Up @@ -623,7 +624,7 @@ private ResourceContentResourcePanel initResourceContent(IModel<PrismObjectWrapp
String searchMode = isRepoSearch ? SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT :
SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT;
ResourceContentResourcePanel resourceContent = new ResourceContentResourcePanel(ID_TABLE, loadResourceModel(),
getObjectClass(), getKind(), getIntent(), searchMode, getPanelConfiguration()) {
getObjectClassFromSearch(), getKind(), getIntent(), searchMode, getPanelConfiguration()) {
@Override
protected ResourceSchema getRefinedSchema() throws SchemaException, ConfigurationException {
try {
Expand Down Expand Up @@ -671,7 +672,7 @@ private ResourceContentRepositoryPanel initRepoContent(IModel<PrismObjectWrapper
String searchMode = isRepoSearch ? SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT :
SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT;
ResourceContentRepositoryPanel repositoryContent = new ResourceContentRepositoryPanel(ID_TABLE, loadResourceModel(),
getObjectClass(), getKind(), getIntent(), searchMode, getPanelConfiguration()) {
getObjectClassFromSearch(), getKind(), getIntent(), searchMode, getPanelConfiguration()) {
@Override
protected ResourceSchema getRefinedSchema() throws SchemaException, ConfigurationException {
try {
Expand Down Expand Up @@ -716,10 +717,50 @@ protected String getIntent() {
return resourceContentSearch.getObject().getIntent();
}

protected QName getObjectClass() {
protected QName getObjectClassFromSearch() {
return resourceContentSearch.getObject().getObjectClass();
}

protected QName getObjectClass() {
QName objectClass = null;
IModel<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>> model = getResourceObjectTypeValue(null);
if (model != null) {
ResourceObjectTypeDefinitionType objectType = model.getObject().getRealValue();
if (objectType.getDelineation() != null) {
objectClass = objectType.getDelineation().getObjectClass();
}
if (objectClass == null) {
objectClass = objectType.getObjectClass();
}
}
if (objectClass == null) {
objectClass = getObjectClassFromSearch();
}

if (objectClass == null) {
ResourceSchema refinedSchema = null;
try {
refinedSchema = ResourceSchemaFactory.getCompleteSchema(getObjectWrapper().getObject());
} catch (SchemaException | ConfigurationException e) {
// ignore it
}
if (refinedSchema == null) {
return null;
}
String intent = getIntent();
ResourceObjectDefinition ocDef;
if (ShadowUtil.isKnown(getIntent())) {
ocDef = refinedSchema.findObjectDefinition(getKind(), intent);
} else {
ocDef = refinedSchema.findDefaultDefinitionForKind(getKind());
}
if (ocDef != null) {
objectClass = ocDef.getObjectClassName();
}
}
return objectClass;
}

protected boolean isResourceSearch() {
Boolean isResourceSearch = resourceContentSearch.getObject().isResourceSearch();
if (isResourceSearch == null) {
Expand Down Expand Up @@ -763,19 +804,10 @@ private Collection<? extends Component> createToolbarButtonsList(String buttonId
@Override
public void onClick(AjaxRequestTarget target) {
IModel<String> confirmModel;
IModel<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>> objectType = getResourceObjectTypeValue(null);
if (objectType != null) {
ResourceObjectTypeDefinitionType value = objectType.getObject().getRealValue();
String objectTypeLabel = getPageBase().createStringResource(value.getKind()).getString()
+ "/" + value.getIntent();
confirmModel = getPageBase().createStringResource(
"ResourceCategorizedPanel.button.reclassify.confirmation.objectType",
objectTypeLabel);
} else {
confirmModel = getPageBase().createStringResource(
"ResourceCategorizedPanel.button.reclassify.confirmation.objectClass",
getObjectClass().getLocalPart());
}

confirmModel = getPageBase().createStringResource(
"ResourceCategorizedPanel.button.reclassify.confirmation.objectClass",
getObjectClass().getLocalPart());

ConfirmationPanel confirmationPanel = new ConfirmationPanel(getPageBase().getMainPopupBodyId(), confirmModel) {
@Override
Expand All @@ -791,9 +823,7 @@ public void yesPerformed(AjaxRequestTarget target) {
reclassify.add(AttributeAppender.append("class", "btn btn-primary btn-sm mr-2"));
reclassify.setOutputMarkupId(true);
reclassify.showTitleAsLabel(true);
reclassify.add(new VisibleBehaviour(() ->
(isTopTableButtonsVisible() || getObjectClass() != null)
&& isReclassifyButtonVisible()));
reclassify.add(new VisibleBehaviour(() -> getObjectClass() != null && isReclassifyButtonVisible()));
buttonsList.add(reclassify);

return buttonsList;
Expand Down Expand Up @@ -826,29 +856,12 @@ private void createReclassifyTask(AjaxRequestTarget target) {
.beginConfigurationToUse()
.predefined(PredefinedConfigurationType.DEVELOPMENT);

QName objectClass = null;

IModel<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>> model = getResourceObjectTypeValue(null);
if (model != null) {
ResourceObjectTypeDefinitionType objectType = model.getObject().getRealValue();
if (objectType.getDelineation() != null) {
objectClass = objectType.getDelineation().getObjectClass();
}
if (objectClass == null) {
objectClass = objectType.getObjectClass();
}
}
QName searchObjectClass = getObjectClass();
if (searchObjectClass != null) {
objectClass = searchObjectClass;
}

task.getUpdatedTaskObject().getRealValue()
.getActivity()
.getWork()
.getImport()
.getResourceObjects()
.objectclass(objectClass)
.objectclass(getObjectClass())
.intent(null)
.kind(null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,17 @@ protected String getIntent() {
}

@Override
protected QName getObjectClass() {
return resourceObjectType.getObject().getRealValue().getObjectClass();
protected QName getObjectClassFromSearch() {
QName objectClass = null;
ResourceObjectTypeDefinitionType objectType = resourceObjectType.getObject().getRealValue();
if (objectType.getDelineation() != null) {
objectClass = objectType.getDelineation().getObjectClass();
}
if (objectClass == null) {
objectClass = objectType.getObjectClass();
}

return objectClass;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ protected void initLayout() {
private List<WizardStep> createBasicSteps() {
List<WizardStep> steps = new ArrayList<>();

steps.add(new AccessApplicationStepPanel(getHelper().getDetailsModel()));
steps.add(new AccessApplicationStepPanel(getHelper().getDetailsModel()){
@Override
protected void onExitPerformed(AjaxRequestTarget target) {
ApplicationRoleWizardPanel.this.onExitPerformed(target);
}
});

steps.add(new BasicInformationStepPanel(getHelper().getDetailsModel()) {

Expand All @@ -51,6 +56,11 @@ protected void onSubmitPerformed(AjaxRequestTarget target) {
super.onSubmitPerformed(target);
ApplicationRoleWizardPanel.this.onFinishBasicWizardPerformed(target);
}

@Override
protected void onExitPerformed(AjaxRequestTarget target) {
ApplicationRoleWizardPanel.this.onExitPerformed(target);
}
});

return steps;
Expand Down

0 comments on commit 3052dfe

Please sign in to comment.