Skip to content

Commit

Permalink
WIP: Server Information: Ability to associate a servers with physical…
Browse files Browse the repository at this point in the history
… flow

finos#3803
  • Loading branch information
kamransaleem committed Feb 5, 2019
1 parent cbdd759 commit bf19f79
Show file tree
Hide file tree
Showing 19 changed files with 571 additions and 15 deletions.
5 changes: 3 additions & 2 deletions docs/design/physical_flow_nodes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ flows are restored.

### Physical Flow Node table

Nodes for physical flows will be captured in the `physical_flow_node`
Nodes for physical flows will be captured in the `physical_flow_participant`
table. A row in this table will effectively reference actual servers or
databases that are participating in a physical flow, along with a
designation indicating which side of the flow the node is acting.

| Column | Type | Mandatory | Description |
|:-------------------|:----------|:----------|:--------------------------------------------------------------|
| `id` | seq | **y** | PK |
| `physical_flow_id` | long | **y** | id of the physical flow |
| `side` | enum | **y** | one of: `SOURCE` or `TARGET` to indicate the side of the flow |
| `node_entity_kind` | enum | **y** | flow node entity kind |
| `node_entity_id` | long | **y** | flow node entity id |
Expand All @@ -85,6 +85,7 @@ designation indicating which side of the flow the node is acting.
| `last_updated_at` | timestamp | **y** | when this record was created |
| `provenance` | string | **y** | the provenance of the record |

primary key on (`physical_flow_id`, `side`, `node_entity_kind`, `node_entity_id`)

### Server Information and Database Information tables

Expand Down
50 changes: 50 additions & 0 deletions waltz-data/src/main/ddl/liquibase/db.changelog-1.16.xml
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,54 @@
<dropTable tableName="tour"/>
</changeSet>


<!-- 3803: Physical Flow Participant table-->
<changeSet id="20190131-3803-1"
author="kamransaleem">
<comment>3803: Physical Flow Participant table</comment>
<createTable tableName="physical_flow_participant">
<column name="physical_flow_id"
type="${id.type}">
<constraints nullable="false" />
</column>
<column name="kind"
type="${enum.type}">
<constraints nullable="false" />
</column>
<column name="participant_entity_kind"
type="${enum.type}">
<constraints nullable="false" />
</column>
<column name="participant_entity_id"
type="${id.type}">
<constraints nullable="false" />
</column>
<column name="description"
type="${description.type}">
<constraints nullable="true" />
</column>
<column name="last_updated_at"
type="TIMESTAMP"
defaultValueComputed="${now.value}">
<constraints nullable="false" />
</column>
<column name="last_updated_by"
type="${name.type}">
<constraints nullable="false" />
</column>
<column name="provenance"
type="${provenance.type}">
<constraints nullable="false" />
</column>
</createTable>
</changeSet>

<changeSet id="20190131-3803-2"
author="kamransaleem">
<addPrimaryKey columnNames="physical_flow_id, participant_entity_id, participant_entity_kind, kind"
constraintName="physical_flow_participant_pkey"
tableName="physical_flow_participant" />
</changeSet>


</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ private static Map<EntityKind, Tuple3<Table, Field<Long>, Field<String>>> mkName
mappings.put(EntityKind.ORG_UNIT, tuple(ORGANISATIONAL_UNIT, ORGANISATIONAL_UNIT.ID, ORGANISATIONAL_UNIT.NAME));
mappings.put(EntityKind.PERSON, tuple(PERSON, PERSON.ID, PERSON.DISPLAY_NAME));
mappings.put(EntityKind.PHYSICAL_SPECIFICATION, tuple(PHYSICAL_SPECIFICATION, PHYSICAL_SPECIFICATION.ID, PHYSICAL_SPECIFICATION.NAME));
mappings.put(EntityKind.SERVER, tuple(SERVER_INFORMATION, SERVER_INFORMATION.ID, SERVER_INFORMATION.HOSTNAME));
return mappings;
}

Expand All @@ -132,6 +133,7 @@ private static Map<EntityKind,Tuple3<Table,Field<Long>,Field<String>>> mkExterna
mappings.put(EntityKind.PERSON, tuple(PERSON, PERSON.ID, PERSON.EMPLOYEE_ID));
mappings.put(EntityKind.PHYSICAL_SPECIFICATION, tuple(PHYSICAL_SPECIFICATION, PHYSICAL_SPECIFICATION.ID, PHYSICAL_SPECIFICATION.EXTERNAL_ID));
mappings.put(EntityKind.PHYSICAL_FLOW, tuple(PHYSICAL_FLOW, PHYSICAL_FLOW.ID, PHYSICAL_FLOW.EXTERNAL_ID));
mappings.put(EntityKind.SERVER, tuple(SERVER_INFORMATION, SERVER_INFORMATION.ID, SERVER_INFORMATION.EXTERNAL_ID));
return mappings;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Waltz - Enterprise Architecture
* Copyright (C) 2016, 2017 Waltz open source project
* See README.md for more information
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.khartec.waltz.data.physical_flow_participant;

import com.khartec.waltz.data.InlineSelectFieldFactory;
import com.khartec.waltz.data.physical_flow.PhysicalFlowDao;
import com.khartec.waltz.model.EntityKind;
import com.khartec.waltz.model.EntityReference;
import com.khartec.waltz.model.physical_flow_participant.ImmutablePhysicalFlowParticipant;
import com.khartec.waltz.model.physical_flow_participant.ParticipationKind;
import com.khartec.waltz.model.physical_flow_participant.PhysicalFlowParticipant;
import com.khartec.waltz.schema.tables.records.PhysicalFlowParticipantRecord;
import org.jooq.DSLContext;
import org.jooq.Field;
import org.jooq.Record;
import org.jooq.RecordMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

import static com.khartec.waltz.common.Checks.checkNotNull;
import static com.khartec.waltz.schema.tables.PhysicalFlowParticipant.PHYSICAL_FLOW_PARTICIPANT;

@Repository
public class PhysicalFlowParticipantDao {

private static final Logger LOG = LoggerFactory.getLogger(PhysicalFlowDao.class);

private static final Field<String> PARTICIPANT_NAME_FIELD = InlineSelectFieldFactory.mkNameField(
PHYSICAL_FLOW_PARTICIPANT.PARTICIPANT_ENTITY_ID,
PHYSICAL_FLOW_PARTICIPANT.PARTICIPANT_ENTITY_KIND);

public static final RecordMapper<Record, PhysicalFlowParticipant> TO_DOMAIN_MAPPER = r -> {
PhysicalFlowParticipantRecord record = r.into(PHYSICAL_FLOW_PARTICIPANT);

EntityReference ref = EntityReference.mkRef(
EntityKind.valueOf(record.getParticipantEntityKind()),
record.getParticipantEntityId(),
r.get(PARTICIPANT_NAME_FIELD));

return ImmutablePhysicalFlowParticipant.builder()
.physicalFlowId(record.getPhysicalFlowId())
.kind(ParticipationKind.valueOf(record.getKind()))
.participant(ref)
.provenance(record.getProvenance())
.description(record.getDescription())
.lastUpdatedBy(record.getLastUpdatedBy())
.lastUpdatedAt(record.getLastUpdatedAt().toLocalDateTime())
.build();
};

private final DSLContext dsl;


@Autowired
public PhysicalFlowParticipantDao(DSLContext dsl) {
checkNotNull(dsl, "dsl cannot be null");
this.dsl = dsl;
}


public List<PhysicalFlowParticipant> findByPhysicalFlowId(long id) {
return dsl.select(PHYSICAL_FLOW_PARTICIPANT.fields())
.select(PARTICIPANT_NAME_FIELD)
.from(PHYSICAL_FLOW_PARTICIPANT)
.where(PHYSICAL_FLOW_PARTICIPANT.PHYSICAL_FLOW_ID.eq(id))
.fetch(TO_DOMAIN_MAPPER);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -111,24 +111,21 @@ public List<ServerInformation> findByAppId(long appId) {


public ServerInformation getById(long id) {
return dsl.select(SERVER_INFORMATION.fields())
.from(SERVER_INFORMATION)
return dsl.selectFrom(SERVER_INFORMATION)
.where(SERVER_INFORMATION.ID.eq(id))
.fetchOne(TO_DOMAIN_MAPPER);
}


public ServerInformation getByExternalId(String externalId) {
return dsl.select(SERVER_INFORMATION.fields())
.from(SERVER_INFORMATION)
return dsl.selectFrom(SERVER_INFORMATION)
.where(SERVER_INFORMATION.EXTERNAL_ID.eq(externalId))
.fetchOne(TO_DOMAIN_MAPPER);
}


public ServerInformation getByHostname(String hostname) {
return dsl.select(SERVER_INFORMATION.fields())
.from(SERVER_INFORMATION)
return dsl.selectFrom(SERVER_INFORMATION)
.where(SERVER_INFORMATION.HOSTNAME.eq(hostname))
.fetchOne(TO_DOMAIN_MAPPER);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Waltz - Enterprise Architecture
* Copyright (C) 2016, 2017 Waltz open source project
* See README.md for more information
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.khartec.waltz.model.physical_flow_participant;

public enum ParticipationKind {
SOURCE,
FLOW,
TARGET
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Waltz - Enterprise Architecture
* Copyright (C) 2016, 2017 Waltz open source project
* See README.md for more information
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.khartec.waltz.model.physical_flow_participant;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.khartec.waltz.model.DescriptionProvider;
import com.khartec.waltz.model.EntityReference;
import com.khartec.waltz.model.LastUpdatedProvider;
import com.khartec.waltz.model.ProvenanceProvider;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutablePhysicalFlowParticipant.class)
@JsonDeserialize(as = ImmutablePhysicalFlowParticipant.class)
public abstract class PhysicalFlowParticipant implements
DescriptionProvider,
LastUpdatedProvider,
ProvenanceProvider {

public abstract long physicalFlowId();
public abstract ParticipationKind kind();
public abstract EntityReference participant();

}
2 changes: 1 addition & 1 deletion waltz-ng/client/common/grid-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function mkEntityLinkGridCell(columnHeading, entityRefField, iconPlacemen
cellTemplate: `
<div class="ui-grid-cell-contents">
<waltz-entity-link entity-ref="row.entity.${entityRefField}"
icon-placement="'${iconPlacement}'">
icon-placement="${iconPlacement}">
</waltz-entity-link>
</div>`
};
Expand Down
4 changes: 3 additions & 1 deletion waltz-ng/client/common/services/core-api-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ import {MeasurableStore_API as MeasurableStore} from "../../measurable/services/
import {NotificationStore_API as NotificationStore} from "../../notification/services/notification-store";
import {OrgUnitStore_API as OrgUnitStore} from "../../org-units/services/org-unit-store";
import {PersonStore_API as PersonStore} from "../../person/services/person-store";
import {PhysicalFlowStore_API as PhysicalFlowStore} from "../../physical-flows/service/physical-flow-store";
import {PhysicalFlowStore_API as PhysicalFlowStore} from "../../physical-flows/services/physical-flow-store";
import {PhysicalFlowParticipantStore_API as PhysicalFlowParticipantStore} from "../../physical-flows/services/physical-flow-participant-store";
import {PhysicalSpecDataTypeStore_API as PhysicalSpecDataTypeStore} from "../../physical-specifications/services/physical-spec-data-type-store";
import {PhysicalSpecDefinitionFieldStore_API as PhysicalSpecDefinitionFieldStore} from "../../physical-specifications/services/physical-spec-definition-field-store";
import {PhysicalSpecDefinitionStore_API as PhysicalSpecDefinitionStore} from "../../physical-specifications/services/physical-spec-definition-store";
Expand Down Expand Up @@ -130,6 +131,7 @@ export const CORE_API = {
OrgUnitStore,
PersonStore,
PhysicalFlowStore,
PhysicalFlowParticipantStore,
PhysicalSpecDataTypeStore,
PhysicalSpecDefinitionFieldStore,
PhysicalSpecDefinitionStore,
Expand Down
2 changes: 2 additions & 0 deletions waltz-ng/client/common/services/enums/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {lifecyclePhase} from "./lifecycle-phase";
import {lifecycleStatus} from "./lifecycle-status";
import {usageKind} from "./usage-kind";
import {orgUnitKind} from "./org-unit-kind";
import {participantKind} from "./participation-kind";
import {rag} from "./rag";
import {relationshipKind} from "./relationship-kind";
import {releaseLifecycleStatus} from "./release-lifecycle-status";
Expand Down Expand Up @@ -79,6 +80,7 @@ export const enums = {
dataFormatKind,
lifecycleStatus,
fieldDataType,
participantKind,
physicalSpecDefinitionType,
rag,
relationshipKind,
Expand Down
42 changes: 42 additions & 0 deletions waltz-ng/client/common/services/enums/participation-kind.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Waltz - Enterprise Architecture
* Copyright (C) 2016, 2017 Waltz open source project
* See README.md for more information
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

export const participantKind = {
SOURCE: {
key: "SOURCE",
name: "Source",
icon: null,
description: null,
position: 10
},
FLOW: {
key: "FLOW",
name: "Flow",
icon: null,
description: null,
position: 20
},
TARGET: {
key: "TARGET",
name: "Target",
icon: null,
description: null,
position: 30
}
};
Loading

0 comments on commit bf19f79

Please sign in to comment.