Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Sep 28, 2021
2 parents f472893 + aebf8ba commit 00dfab4
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 41 deletions.
13 changes: 2 additions & 11 deletions config/initial-objects/024-archetype-operation-request.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,10 @@
<cssClass>fa fa-circle-o</cssClass>
</icon>
</display>
<displayOrder>1</displayOrder>
<panelType>operationRequestCase</panelType>
<type>c:CaseType</type>
</panel>
<panel>
<identifier>operationRequestCase</identifier>
<display>
<label>Operation request</label>
<icon>
<cssClass>fa fa-circle-o</cssClass>
</icon>
</display>
<panelType>operationRequestCase</panelType>
<type>c:CaseType</type>
<default>true</default>
</panel>
</objectDetails>
</adminGuiConfiguration>
Expand Down
2 changes: 2 additions & 0 deletions config/initial-objects/025-archetype-approval-case.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@
<cssClass>fa fa-circle-o</cssClass>
</icon>
</display>
<displayOrder>1</displayOrder>
<panelType>approvalCase</panelType>
<type>c:CaseType</type>
<default>true</default>
</panel>
</objectDetails>
</adminGuiConfiguration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,21 @@
import com.evolveum.midpoint.gui.impl.prism.panel.SingleContainerPanel;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.application.PanelDisplay;
import com.evolveum.midpoint.web.application.PanelInstance;
import com.evolveum.midpoint.web.application.PanelInstances;
import com.evolveum.midpoint.web.application.PanelType;
import com.evolveum.midpoint.web.application.PanelDisplay;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ContainerPanelConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType;

@PanelType(name = "basic", defaultContainerPath = "empty")
@PanelInstances(instances = {
@PanelInstance(identifier = "basic",
applicableForType = AssignmentHolderType.class,
excludeTypes = {TaskType.class, ResourceType.class},
defaultPanel = true,
display = @PanelDisplay(label = "pageAdminFocus.basic", icon = GuiStyleConstants.CLASS_CIRCLE_FULL, order = 10)),
@PanelInstance(identifier = "basic",
applicableForType = CaseType.class,
defaultPanel = true,
display = @PanelDisplay(label = "pageAdminFocus.basic", icon = GuiStyleConstants.CLASS_CIRCLE_FULL, order = 30))
}
)
@PanelInstance(identifier = "basic",
applicableForType = AssignmentHolderType.class,
excludeTypes = { TaskType.class, ResourceType.class },
defaultPanel = true,
display = @PanelDisplay(label = "pageAdminFocus.basic", icon = GuiStyleConstants.CLASS_CIRCLE_FULL, order = 10))

public class AssignmentHolderBasicPanel<AH extends AssignmentHolderType> extends AbstractObjectMainPanel<AH, ObjectDetailsModels<AH>> {

private static final String ID_MAIN_PANEL = "properties";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,8 @@ private void stopCaseProcessConfirmed(AjaxRequestTarget target) {
target.add(getPageBase().getFeedbackPanel());
}

@Override
protected boolean getVisibilityForSaveButton() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ protected void onError(AjaxRequestTarget target) {
target.add(getPageBase().getFeedbackPanel());
}
};
// save.add(getVisibilityForSaveButton());
save.add(new VisibleBehaviour(this::getVisibilityForSaveButton));
save.titleAsLabel(true);
save.setOutputMarkupId(true);
save.add(AttributeAppender.append("class", "btn btn-success btn-sm"));
Expand All @@ -166,6 +166,10 @@ protected void savePerformed(AjaxRequestTarget target) {

}

protected boolean getVisibilityForSaveButton() {
return true; //todo check if the object is editable? or look at old page behavior
}

private void backPerformed(AjaxRequestTarget target) {
getPageBase().redirectBack();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* @author mederly
*/
public class StatisticsPanel extends BasePanel<StatisticsDto> {
private static final long serialVersionUID = 1L;

private static final String ID_CONTENTS_PANEL = "contents";

Expand Down Expand Up @@ -87,6 +88,7 @@ protected void populateItem(final ListItem<ProvisioningStatisticsLineDto> item)

ListDataProvider<ProvisioningStatisticsOperationDto> provider = new ListDataProvider<>(StatisticsPanel.this, new PropertyModel<>(item.getModel(), ProvisioningStatisticsLineDto.F_OPERATIONS));
BoxedTablePanel<ProvisioningStatisticsOperationDto> provisioningTable = new BoxedTablePanel<>(ID_PROVISIONING_OPERATIONS, provider, createProvisioningStatisticsColumns()) {
private static final long serialVersionUID = 1L;

@Override
protected WebMarkupContainer createHeader(String headerId) {
Expand Down Expand Up @@ -119,6 +121,7 @@ protected boolean hideFooterIfSinglePage() {

ListDataProvider<MappingsLineDto> mappingsProvider = new ListDataProvider<>(this, new PropertyModel<>(getModel(), StatisticsDto.F_MAPPINGS_LINES));
BoxedTablePanel<MappingsLineDto> mappingsLines = new BoxedTablePanel<>(ID_MAPPINGS_STATISTICS_LINES, mappingsProvider, createMappingsColumn()) {
private static final long serialVersionUID = 1L;

@Override
protected WebMarkupContainer createHeader(String headerId) {
Expand All @@ -137,6 +140,7 @@ protected boolean hideFooterIfSinglePage() {

ListDataProvider<NotificationsLineDto> notificationsProvider = new ListDataProvider<>(this, new PropertyModel<>(getModel(), StatisticsDto.F_NOTIFICATIONS_LINES));
BoxedTablePanel<NotificationsLineDto> notificationsLines = new BoxedTablePanel<>(ID_NOTIFICATIONS_STATISTICS_LINES, notificationsProvider, createNotificationColumns()) {
private static final long serialVersionUID = 1L;

@Override
protected WebMarkupContainer createHeader(String headerId) {
Expand Down Expand Up @@ -223,6 +227,7 @@ public void hide() {

class TableHeaderFragment extends Fragment {

private static final long serialVersionUID = 1L;
private static final String ID_LABEL = "headerLabel";

public TableHeaderFragment(String id, String markupId, MarkupContainer markupProvider, IModel<String> model) {
Expand All @@ -247,6 +252,7 @@ private void initLayout() {
}

class ProvisioningStatisticsHeaderFragment extends Fragment {
private static final long serialVersionUID = 1L;

public ProvisioningStatisticsHeaderFragment(String id, String markupId, MarkupContainer markupProvider, IModel<ProvisioningStatisticsLineDto> model) {
super(id, markupId, markupProvider, model);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public TaskInfoBoxPanel(String id, IModel<ActivityInfoBoxDto> model) {
@Override
protected void customInitLayout(WebMarkupContainer parentInfoBox, IModel<ActivityInfoBoxDto> model, Class<? extends IRequestablePage> linkPage) {

Label duration = new Label(ID_DURATION, new ReadOnlyModel<>(() -> WebComponentUtil.formatDurationWordsForLocal(model.getObject().getDuration(), true, true, getPageBase())));
Label duration = new Label(ID_DURATION, new ReadOnlyModel<>(() -> model != null && model.getObject() != null ?
WebComponentUtil.formatDurationWordsForLocal(model.getObject().getDuration(), true, true, getPageBase()) : ""));
parentInfoBox.add(duration);

Label errorMessage = new Label(ID_ERROR_MESSAGE, new PropertyModel<>(model, ActivityInfoBoxDto.F_ERROR_MESSAGE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@
<panelType>childCases</panelType>
<type>c:CaseType</type>
</panel>
<panel>
<identifier>operationRequestCase</identifier>
<display>
<label>Operation request</label>
<icon>
<cssClass>fa fa-circle-o</cssClass>
</icon>
</display>
<displayOrder>1</displayOrder>
<panelType>operationRequestCase</panelType>
<type>c:CaseType</type>
<default>true</default>
</panel>
</objectDetails>
</adminGuiConfiguration>
</archetypePolicy>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@
<cssClass>fa fa-circle-o</cssClass>
</icon>
</display>
<displayOrder>1</displayOrder>
<panelType>approvalCase</panelType>
<type>c:CaseType</type>
<default>true</default>
</panel>
</objectDetails>
</adminGuiConfiguration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,16 @@
*/
public class SqaleRepositoryService extends SqaleServiceBase implements RepositoryService {

public static final String REPOSITORY_IMPL_NAME = "SQaLe";

public static final int INITIAL_VERSION_NUMBER = 0;
public static final String INITIAL_VERSION_STRING = String.valueOf(INITIAL_VERSION_NUMBER);

private static final int MAX_CONFLICT_WATCHERS = 10;

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

public static final String REPOSITORY_IMPL_NAME = "SQaLe";

private final SqlQueryExecutor sqlQueryExecutor;

@Autowired private SystemConfigurationChangeDispatcher systemConfigurationChangeDispatcher;
Expand Down Expand Up @@ -641,7 +644,8 @@ RootUpdateContext<S, Q, R> prepareUpdateContext(
return prepareUpdateContext(jdbcSession, schemaType, Collections.emptyList(), oid, null);
}

/** Read object for update and returns update context that contains it.
/**
* 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(
Expand All @@ -654,7 +658,6 @@ RootUpdateContext<S, Q, R> prepareUpdateContext(
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ public MAssignment newRowObject(OR ownerRow) {
public MAssignment insert(AssignmentType assignment, OR ownerRow, JdbcSession jdbcSession) {
MAssignment row = initRowObject(assignment, ownerRow);

row.ownerType = ownerRow.objectType;
row.lifecycleState = assignment.getLifecycleState();
row.orderValue = assignment.getOrder();
setReference(assignment.getOrgRef(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
package com.evolveum.midpoint.repo.sqale.update;

import static com.evolveum.midpoint.repo.sqale.SqaleRepositoryService.INITIAL_VERSION_STRING;

import java.util.Objects;
import java.util.UUID;

Expand Down Expand Up @@ -51,7 +53,7 @@ public AddObjectContext(
public String execute()
throws SchemaException, ObjectAlreadyExistsException {
try (JdbcSession jdbcSession = repositoryContext.newJdbcSession().startTransaction()) {
object.setVersion("0"); // initial add always uses 1 as version number
object.setVersion(INITIAL_VERSION_STRING);
initContexts();
if (object.getOid() == null) {
return addObjectWithoutOid(jdbcSession);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
import org.testng.annotations.Test;

import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.Objectable;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.path.ItemName;
import com.evolveum.midpoint.prism.polystring.PolyString;
import com.evolveum.midpoint.repo.api.DeleteObjectResult;
import com.evolveum.midpoint.repo.api.RepositoryService;
import com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest;
import com.evolveum.midpoint.repo.sqale.SqaleRepositoryService;
import com.evolveum.midpoint.repo.sqale.jsonb.Jsonb;
import com.evolveum.midpoint.repo.sqale.qmodel.accesscert.*;
import com.evolveum.midpoint.repo.sqale.qmodel.assignment.*;
Expand Down Expand Up @@ -104,7 +104,8 @@ public void test100AddNamedUserWithoutOidWorksOk()
MUser row = selectOne(u, u.nameOrig.eq(userName));
assertThat(row.oid).isEqualTo(UUID.fromString(returnedOid));
assertThat(row.nameNorm).isNotNull(); // normalized name is stored
assertThat(row.version).isEqualTo(1); // initial version is set, ignoring provided version
// initial version is set, ignoring provided version
assertThat(row.version).isEqualTo(SqaleRepositoryService.INITIAL_VERSION_NUMBER);
// read-only column with value generated/stored in the database
assertThat(row.objectType).isEqualTo(MObjectType.USER);
assertThat(row.subtypes).isNull(); // we don't store empty lists as empty arrays
Expand Down Expand Up @@ -180,7 +181,7 @@ public void test110AddWithOverwriteOption()
assertThat(row.fullNameOrig).isEqualTo("Overwritten User");

and("provided version for overwrite is ignored");
assertThat(row.version).isEqualTo(2);
assertThat(row.version).isEqualTo(SqaleRepositoryService.INITIAL_VERSION_NUMBER + 1);
}

@Test
Expand Down Expand Up @@ -209,7 +210,7 @@ public void test111AddWithOverwriteOptionWithNewOidActsLikeNormalAdd()
MUser row = selectObjectByOid(QUser.class, userType.getOid());

and("provided version for overwrite is ignored");
assertThat(row.version).isEqualTo(1);
assertThat(row.version).isEqualTo(SqaleRepositoryService.INITIAL_VERSION_NUMBER);
}

// detailed container tests are from test200 on, this one has overwrite priority :-)
Expand Down Expand Up @@ -270,7 +271,7 @@ public void test112OverwriteWithContainers()
assertThat(assRow.targetRefTargetType).isEqualTo(MObjectType.ROLE);

and("provided version for overwrite is ignored");
assertThat(row.version).isEqualTo(2);
assertThat(row.version).isEqualTo(SqaleRepositoryService.INITIAL_VERSION_NUMBER + 1);
}

@Test
Expand All @@ -297,7 +298,7 @@ public void test120AddUserWithProvidedOidWorksOk()

MUser mUser = users.get(0);
assertThat(mUser.oid).isEqualTo(providedOid);
assertThat(mUser.version).isEqualTo(1); // initial version is set
assertThat(mUser.version).isEqualTo(SqaleRepositoryService.INITIAL_VERSION_NUMBER);
}

@Test
Expand Down Expand Up @@ -349,7 +350,7 @@ public void test122AddSecondObjectWithTheSameOidWithOverwriteIsOk()
assertThatOperationResult(result).isSuccess();
assertCount(QObject.CLASS, baseCount); // no new object was created
MUser row = selectObjectByOid(QUser.class, providedOid);
assertThat(row.version).isEqualTo(1); // version is still initial, no change
assertThat(row.version).isEqualTo(SqaleRepositoryService.INITIAL_VERSION_NUMBER); // no change
}

@Test
Expand Down

0 comments on commit 00dfab4

Please sign in to comment.