Skip to content

Commit

Permalink
Merge pull request #6914 from deutschebank/db-contrib/waltz-6069-add-…
Browse files Browse the repository at this point in the history
…is-read-only-to-phsyical-spec

add is read only to phsyical spec
  • Loading branch information
davidwatkins73 authored Dec 11, 2023
2 parents 9076aec + 970d940 commit f889080
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@

import java.sql.Timestamp;
import java.util.Collection;
import java.util.List;
import java.util.Set;

import static org.finos.waltz.common.Checks.checkFalse;
Expand All @@ -75,7 +74,12 @@
import static org.finos.waltz.schema.tables.PhysicalFlow.PHYSICAL_FLOW;
import static org.finos.waltz.schema.tables.PhysicalSpecDataType.PHYSICAL_SPEC_DATA_TYPE;
import static org.finos.waltz.schema.tables.PhysicalSpecification.PHYSICAL_SPECIFICATION;
import static org.jooq.impl.DSL.*;
import static org.jooq.impl.DSL.concat;
import static org.jooq.impl.DSL.count;
import static org.jooq.impl.DSL.exists;
import static org.jooq.impl.DSL.notExists;
import static org.jooq.impl.DSL.select;
import static org.jooq.impl.DSL.val;

@Repository
public class PhysicalSpecificationDao {
Expand Down Expand Up @@ -110,6 +114,7 @@ public class PhysicalSpecificationDao {
.provenance(record.getProvenance())
.isRemoved(record.getIsRemoved())
.created(UserTimestamp.mkForUser(record.getCreatedBy(), record.getCreatedAt()))
.isReadOnly(record.getIsReadonly())
.build();
};

Expand Down Expand Up @@ -219,6 +224,7 @@ public Long create(PhysicalSpecification specification) {

record.setCreatedAt(specification.created().get().atTimestamp());
record.setCreatedBy(specification.created().get().by());
record.setIsReadonly(specification.isReadOnly());

record.store();
return record.getId();
Expand All @@ -241,7 +247,8 @@ public int updateExternalId(long specificationId, String externalId) {
return dsl
.update(PHYSICAL_SPECIFICATION)
.set(PHYSICAL_SPECIFICATION.EXTERNAL_ID, externalId)
.where(PHYSICAL_SPECIFICATION.ID.eq(specificationId))
.where(PHYSICAL_SPECIFICATION.ID.eq(specificationId)
.and(PHYSICAL_SPECIFICATION.IS_READONLY.isFalse()))
.execute();
}

Expand All @@ -258,7 +265,8 @@ public int makeActive(Long specificationId) {
return dsl
.update(PHYSICAL_SPECIFICATION)
.set(PHYSICAL_SPECIFICATION.IS_REMOVED, false)
.where(PHYSICAL_SPECIFICATION.ID.eq(specificationId))
.where(PHYSICAL_SPECIFICATION.ID.eq(specificationId)
.and(PHYSICAL_SPECIFICATION.IS_READONLY.isFalse()))
.execute();
}

Expand Down Expand Up @@ -401,7 +409,8 @@ public int updateFormat(long specId, DataFormatKindValue format) {
return dsl
.update(PHYSICAL_SPECIFICATION)
.set(PHYSICAL_SPECIFICATION.FORMAT, format.value())
.where(PHYSICAL_SPECIFICATION.ID.eq(specId))
.where(PHYSICAL_SPECIFICATION.ID.eq(specId)
.and(PHYSICAL_SPECIFICATION.IS_READONLY.isFalse()))
.execute();
}

Expand All @@ -410,7 +419,8 @@ public int updateDescription(long specId, String description) {
return dsl
.update(PHYSICAL_SPECIFICATION)
.set(PHYSICAL_SPECIFICATION.DESCRIPTION, description)
.where(PHYSICAL_SPECIFICATION.ID.eq(specId))
.where(PHYSICAL_SPECIFICATION.ID.eq(specId)
.and(PHYSICAL_SPECIFICATION.IS_READONLY.isFalse()))
.execute();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import org.finos.waltz.common.DateTimeUtilities;
import org.finos.waltz.data.licence.LicenceDao;
import org.finos.waltz.model.ApprovalStatus;
import org.finos.waltz.model.EntityKind;
import org.finos.waltz.schema.tables.records.BookmarkRecord;
import org.finos.waltz.schema.tables.records.LicenceRecord;
Expand Down Expand Up @@ -101,7 +100,6 @@ private void importData(String path) throws IOException, URISyntaxException {
record.setName(l.name());
record.setExternalId(l.licenseId());
record.setProvenance(PROVENANCE);
record.setApprovalStatus(ApprovalStatus.PENDING_APPROVAL.name());
record.setCreatedAt(now);
record.setCreatedBy("admin");
record.setLastUpdatedAt(now);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public abstract class PhysicalSpecification implements
ProvenanceProvider,
LastUpdatedProvider,
WaltzEntity,
EntityKindProvider {
EntityKindProvider,
IsReadOnlyProvider {

public abstract EntityReference owningEntity();

Expand Down
10 changes: 10 additions & 0 deletions waltz-ng/client/logical-flow/pages/view/logical-flow-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@
</span>
</div>
</div>
<div class="row"
ng-if="ctrl.logicalFlow.isReadOnly">
<div class="col-sm-1 waltz-display-field-label">
Read Only
</div>
<div class="col-sm-11">
<waltz-icon name="lock"></waltz-icon>
<span>This flow is marked read only and cannot be edited</span>
</div>
</div>
<div class="small text-muted"
ng-if="ctrl.logicalFlow.lastUpdatedBy && ctrl.logicalFlow.lastUpdatedAt && ctrl.logicalFlow">
Last updated by
Expand Down
12 changes: 8 additions & 4 deletions waltz-ng/client/logical-flow/pages/view/logical-flow-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import template from "./logical-flow-view.html";
import {CORE_API} from "../../../common/services/core-api-utils";
import toasts from "../../../svelte-stores/toast-store";
import _ from "lodash";
import {displayError} from "../../../common/error-utils";


const initialState = {
Expand Down Expand Up @@ -60,15 +61,16 @@ function controller($q,

const permissionPromise = serviceBroker
.loadViewData(
CORE_API.LogicalFlowStore.findPermissionsForParentRef,
[vm.entityReference])
CORE_API.LogicalFlowStore.findPermissionsForFlow,
[ flowId ])
.then(r => {
vm.canEdit = _.some(r.data, d => _.includes(["ADD", "UPDATE", "REMOVE"], d));
});

$q.all([flowPromise, permissionPromise]).then(() => {
vm.isDraft = vm.logicalFlow.entityLifecycleStatus === "PENDING";
vm.isRemoved = vm.logicalFlow.entityLifecycleStatus === "REMOVED" || vm.logicalFlow.isRemoved;
vm.isReadOnly = vm.logicalFlow.isReadOnly;
vm.canRemove = vm.canEdit && !vm.isRemoved;
vm.canRestore = vm.canEdit && vm.isRemoved;
});
Expand All @@ -85,7 +87,8 @@ function controller($q,
toasts.error(r.message);
}
$window.location.reload();
});
})
.catch(e => displayError("Unable to remove flow", e));
};

const restoreLogicalFlow = () => {
Expand All @@ -98,7 +101,8 @@ function controller($q,
toasts.error(r.message);
}
$window.location.reload();
});
})
.catch(e => displayError("Unable to restore flow", e));
};

const handleRemoveFlowResponse = (response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,17 @@
<span ng-bind="$ctrl.specification.provenance"></span>
</div>
</div>

<div class="row"
ng-if="$ctrl.specification.isReadOnly">
<div class="col-sm-4 waltz-display-field-label">
Read Only
</div>
<div class="col-sm-8">
<waltz-icon name="lock"></waltz-icon>
<span>This specification is marked read only and cannot be edited</span>
</div>
</div>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ const initialState = {
environmentDescription: "",
licenseGridCols: [
mkLinkGridCell("Name", "name", "id", "main.licence.view"),
{field: "externalId", displayName: "External Id"},
{field: "approvalStatus", displayName: "Approval Status", cellFilter: "toDisplayName:'ApprovalStatus'"},
{field: "externalId", displayName: "External Id"}
],
visibility: {
servers: false,
Expand Down
35 changes: 35 additions & 0 deletions waltz-schema/src/main/resources/liquibase/db.changelog-1.57.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,39 @@
<tagDatabase tag="v1.56"/> <!-- tag the current db version, i.e. the last -->
</changeSet>

<changeSet id="20231207-6033-1"
author="woodjes">
<comment>6033: increase survey predicate column size</comment>
<modifyDataType columnName="inclusion_predicate"
newDataType="${long-expression.type}"
tableName="survey_question" />
</changeSet>

<changeSet id="20231207-5254-1"
author="woodjes">
<comment>5254: add unique constraint to cost on entity, type and year</comment>
<addUniqueConstraint columnNames="cost_kind_id, entity_kind, entity_id, year"
constraintName="idx_cost_entity_year_kind_unique"
tableName="cost"/>
</changeSet>

<changeSet id="20231207-6825-1"
author="woodjes">
<comment>6825: remove approval_status field from licence</comment>
<dropColumn tableName="licence"
columnName="approval_status" />
</changeSet>

<changeSet id="20231207-6069-1"
author="woodjes">
<comment>6069: add is_readonly to physical specification</comment>
<addColumn tableName="physical_specification">
<column name="is_readonly"
type="boolean"
defaultValueBoolean="false">
<constraints nullable="false"/>
</column>
</addColumn>
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
<property name="email.type" value="VARCHAR(255)"></property>
<property name="enum.type" value="VARCHAR(64)"></property>
<property name="expression.type" value="VARCHAR(500)"></property>
<property name="long-expression.type" value="${longvarchar.type}"></property>
<property name="external-id.type" value="VARCHAR(200)"></property>
<property name="group.type" value="VARCHAR(128)"></property>
<property name="guid.type" value="VARCHAR(64)"></property>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ public Set<Operation> findPermissionsForSpec(long specId, String username) {

PhysicalSpecification specification = physicalSpecificationDao.getById(specId);

return findSpecPermissionsForParentEntity(specification.owningEntity(), username);
if (specification.isReadOnly()) {
return emptySet();
} else {
return findSpecPermissionsForParentEntity(specification.owningEntity(), username);
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.finos.waltz.web.WebUtilities;
import org.jooq.DSLContext;
import org.jooq.Record1;
import org.jooq.Record7;
import org.jooq.Record8;
import org.jooq.Select;
import org.jooq.SelectConditionStep;
Expand Down Expand Up @@ -61,13 +62,12 @@ public void register() {
IdSelectionOptions selectionOptions = mkOpts(entityRef);
Select<Record1<Long>> appIdSelector = applicationIdSelectorFactory.apply(selectionOptions);

SelectConditionStep<Record8<Long, String, String, String, String, Timestamp, String, String>> qry = dsl
SelectConditionStep<Record7<Long, String, String, String, Timestamp, String, String>> qry = dsl
.selectDistinct(
LICENCE.ID.as("Licence Id"),
LICENCE.NAME.as("Licence Name"),
LICENCE.DESCRIPTION.as("Description"),
LICENCE.EXTERNAL_ID.as("External Id"),
LICENCE.APPROVAL_STATUS.as("Approval Status"),
LICENCE.LAST_UPDATED_AT.as("Last Updated At"),
LICENCE.LAST_UPDATED_BY.as("Last Updated By"),
LICENCE.PROVENANCE.as("Provenance"))
Expand Down

0 comments on commit f889080

Please sign in to comment.