Skip to content

Commit 0bed102

Browse files
Merge pull request #201 from davidwatkins73/master
Nullable columns and ratings explorer
2 parents edf0440 + 446e6e9 commit 0bed102

49 files changed

Lines changed: 1057 additions & 410 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<module>waltz-jobs</module>
1414
<module>waltz-data</module>
1515
<module>waltz-schema</module>
16+
<module>waltz-local-config</module>
1617
</modules>
1718
<packaging>pom</packaging>
1819

@@ -24,7 +25,7 @@
2425
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2526

2627
<hikari.version>2.4.5</hikari.version>
27-
<immutables.version>2.1.15</immutables.version>
28+
<immutables.version>2.2.5</immutables.version>
2829
<jackson.version>2.7.0</jackson.version>
2930
<jackson-jsr310.version>2.4.0</jackson-jsr310.version>
3031
<jbcrypt.version>0.4</jbcrypt.version>

waltz-common/src/main/java/com/khartec/waltz/common/StringUtilities.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,10 @@ public static Long parseLong(String value, Long dflt) {
5555
return dflt;
5656
}
5757
}
58+
59+
public static String mkSafe(String str) {
60+
return str == null
61+
? ""
62+
: str;
63+
}
5864
}

waltz-data/src/main/ddl/liquibase/db.changelog-1.0.xml

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,16 +1762,46 @@
17621762
</addColumn>
17631763

17641764
</changeSet>
1765-
1765+
1766+
1767+
<!-- 193 server_information - operating_system NULLABLE -->
1768+
<changeSet author="dwatkins" id="20160609-193-1">
1769+
<dropNotNullConstraint columnDataType="VARCHAR(128)"
1770+
columnName="operating_system"
1771+
tableName="server_information"/>
1772+
1773+
</changeSet>
1774+
1775+
1776+
<!-- 195 server_information - operating_system should NOT be nullable -->
1777+
<changeSet author="dwatkins" id="20160613-195-1">
1778+
<addNotNullConstraint columnDataType="VARCHAR(128)"
1779+
columnName="operating_system"
1780+
defaultNullValue="UNKNOWN"
1781+
tableName="server_information"/>
1782+
<addNotNullConstraint columnDataType="VARCHAR(128)"
1783+
columnName="operating_system_version"
1784+
defaultNullValue="UNKNOWN"
1785+
tableName="server_information"/>
1786+
<addNotNullConstraint columnDataType="VARCHAR(128)"
1787+
columnName="location"
1788+
defaultNullValue="UNKNOWN"
1789+
tableName="server_information"/>
1790+
<addNotNullConstraint columnDataType="VARCHAR(128)"
1791+
columnName="country"
1792+
defaultNullValue="UNKNOWN"
1793+
tableName="server_information"/>
1794+
</changeSet>
1795+
17661796
<!-- last_import for source_data_rating #196 -->
17671797
<changeSet author="dwatkins" id="20160614-196-1">
1768-
<addColumn tableName="source_data_rating">
1769-
<column name="last_import"
1770-
type="TIMESTAMP"
1771-
defaultValueComputed="${now.value}">
1772-
<constraints nullable="true"/>
1773-
</column>
1774-
</addColumn>
1798+
<addColumn tableName="source_data_rating">
1799+
<column name="last_import"
1800+
type="TIMESTAMP"
1801+
defaultValueComputed="${now.value}">
1802+
<constraints nullable="true"/>
1803+
</column>
1804+
</addColumn>
17751805
</changeSet>
17761806

17771807
</databaseChangeLog>

waltz-data/src/main/java/com/khartec/waltz/data/app_group/AppGroupDao.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.util.Set;
1414
import java.util.stream.Collectors;
1515

16+
import static com.khartec.waltz.common.StringUtilities.mkSafe;
1617
import static com.khartec.waltz.schema.tables.ApplicationGroup.APPLICATION_GROUP;
1718
import static com.khartec.waltz.schema.tables.ApplicationGroupMember.APPLICATION_GROUP_MEMBER;
1819

@@ -24,7 +25,7 @@ public class AppGroupDao {
2425
ApplicationGroupRecord record = r.into(APPLICATION_GROUP);
2526
return ImmutableAppGroup.builder()
2627
.name(record.getName())
27-
.description(record.getDescription())
28+
.description(mkSafe(record.getDescription()))
2829
.id(record.getId())
2930
.kind(AppGroupKind.valueOf(record.getKind()))
3031
.build();

waltz-data/src/main/java/com/khartec/waltz/data/capability/CapabilityDao.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.util.Optional;
3535

3636
import static com.khartec.waltz.common.Checks.checkNotNull;
37+
import static com.khartec.waltz.common.StringUtilities.mkSafe;
3738
import static com.khartec.waltz.model.utils.IdUtilities.ensureHasId;
3839
import static com.khartec.waltz.schema.tables.AppCapability.APP_CAPABILITY;
3940
import static com.khartec.waltz.schema.tables.Capability.CAPABILITY;
@@ -56,7 +57,7 @@ public class CapabilityDao {
5657
.level4(Optional.ofNullable(record.getLevel_4()))
5758
.level5(Optional.ofNullable(record.getLevel_5()))
5859
.parentId(Optional.ofNullable(record.getParentId()))
59-
.description(record.getDescription())
60+
.description(mkSafe(record.getDescription()))
6061
.name(record.getName())
6162
.build();
6263
};

waltz-data/src/main/java/com/khartec/waltz/data/capability_rating/CapabilityRatingDao.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,14 @@ public List<CapabilityRating> findByAppIds(Long[] appIds) {
204204
.and(PERSPECTIVE_RATING.PARENT_KIND.eq(EntityKind.APPLICATION.name()))
205205
.fetch(capabilityRatingMapper);
206206
}
207+
208+
public List<CapabilityRating> findByAppIdSelector(Select<Record1<Long>> appIdSelector) {
209+
Condition condition = PERSPECTIVE_RATING.PARENT_ID.in(appIdSelector)
210+
.and(PERSPECTIVE_RATING.PARENT_KIND.eq(EntityKind.APPLICATION.name()));
211+
212+
return prepareSelectPart()
213+
.where(dsl.renderInlined(condition))
214+
.fetch(capabilityRatingMapper);
215+
216+
}
207217
}

waltz-data/src/main/java/com/khartec/waltz/data/data_flow/DataFlowDao.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,28 +73,28 @@ public DataFlowDao(DSLContext dsl) {
7373

7474

7575
public List<DataFlow> findByEntityReference(EntityReference ref) {
76-
return baseOrgUnitQuery()
77-
.and(DATA_FLOW.SOURCE_ENTITY_ID.eq(ref.id()).and(DATA_FLOW.SOURCE_ENTITY_KIND.eq(ref.kind().name())))
78-
.or(DATA_FLOW.TARGET_ENTITY_ID.eq(ref.id()).and(DATA_FLOW.TARGET_ENTITY_KIND.eq(ref.kind().name())))
76+
return baseQuery()
77+
.and(DATA_FLOW.SOURCE_ENTITY_ID.eq(ref.id()))
78+
.or(DATA_FLOW.TARGET_ENTITY_ID.eq(ref.id()))
7979
.fetch(dataFlowMapper);
8080
}
8181

8282

8383
public List<DataFlow> findByApplicationIdSelector(Select<Record1<Long>> appIdSelector) {
84-
return baseOrgUnitQuery()
84+
return baseQuery()
8585
.and(DATA_FLOW.SOURCE_ENTITY_ID.in(appIdSelector))
8686
.or(DATA_FLOW.TARGET_ENTITY_ID.in(appIdSelector))
8787
.fetch(dataFlowMapper);
8888
}
8989

9090
public List<DataFlow> findByApplicationIds(Collection<Long> appIds) {
91-
return baseOrgUnitQuery()
91+
return baseQuery()
9292
.and(DATA_FLOW.SOURCE_ENTITY_ID.in(appIds))
9393
.or(DATA_FLOW.TARGET_ENTITY_ID.in(appIds))
9494
.fetch(dataFlowMapper);
9595
}
9696

97-
private SelectConditionStep<Record> baseOrgUnitQuery() {
97+
private SelectConditionStep<Record> baseQuery() {
9898

9999
Field[] fields = new ArrayBuilder<Field>()
100100
.add(DATA_FLOW.fields())

waltz-data/src/main/java/com/khartec/waltz/data/data_flow/DataFlowStatsDao.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,19 @@ public DataFlowMeasures countDistinctAppInvolvement(Select<Record1<Long>> appIdS
7373
df.TARGET_ENTITY_ID
7474
));
7575

76-
Select<Record1<Integer>> intraAppCounter = dsl
77-
.select(DSL.count())
78-
.from(APPLICATION)
79-
.where(APPLICATION.ID.in(appIdSelector));
76+
77+
Select<Record1<Integer>> intraAppCounter = FunctionUtilities.time("DFSD.intraAppCounter", ()
78+
-> dsl
79+
.select(DSL.count())
80+
.from(APPLICATION)
81+
.where(dsl.renderInlined(APPLICATION.ID.in(appIdSelector))));
8082

8183
Select<Record1<Integer>> query = inAppCounter
8284
.unionAll(outAppCounter)
8385
.unionAll(intraAppCounter);
8486

85-
List<Integer> results = query.fetch(0, Integer.class);
87+
List<Integer> results = FunctionUtilities.time("DFSD.executeUnionAppCounters", ()
88+
-> query.fetch(0, Integer.class));
8689

8790
return ImmutableDataFlowMeasures
8891
.builder()
@@ -93,7 +96,6 @@ public DataFlowMeasures countDistinctAppInvolvement(Select<Record1<Long>> appIdS
9396
}
9497

9598

96-
9799
public List<StringTally> tallyDataTypes(Select<Record1<Long>> appIdSelector) {
98100
checkNotNull(appIdSelector, "appIdSelector cannot be null");
99101

@@ -176,5 +178,4 @@ private SelectConditionStep<Record1<Integer>> countDistinctApps(Select<Record1<L
176178

177179
}
178180

179-
180181
}

waltz-data/src/main/java/com/khartec/waltz/data/data_type/DataTypeDao.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.List;
3030

3131
import static com.khartec.waltz.common.Checks.checkNotNull;
32+
import static com.khartec.waltz.common.StringUtilities.mkSafe;
3233
import static com.khartec.waltz.schema.tables.DataType.DATA_TYPE;
3334

3435

@@ -40,7 +41,7 @@ public class DataTypeDao {
4041
DataTypeRecord record = r.into(DataTypeRecord.class);
4142
return ImmutableDataType.builder()
4243
.code(record.getCode())
43-
.description(record.getDescription())
44+
.description(mkSafe(record.getDescription()))
4445
.name(record.getName())
4546
.build();
4647
};

waltz-data/src/main/java/com/khartec/waltz/data/end_user_app/EndUserAppDao.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import java.util.List;
3535

36+
import static com.khartec.waltz.common.StringUtilities.mkSafe;
3637
import static com.khartec.waltz.schema.tables.EndUserApplication.END_USER_APPLICATION;
3738

3839
@Repository
@@ -45,7 +46,7 @@ public class EndUserAppDao {
4546
EndUserApplicationRecord record = r.into(END_USER_APPLICATION);
4647
return ImmutableEndUserApplication.builder()
4748
.name(record.getName())
48-
.description(record.getDescription())
49+
.description(mkSafe(record.getDescription()))
4950
.kind(record.getKind())
5051
.id(record.getId())
5152
.organisationalUnitId(record.getOrganisationalUnitId())

0 commit comments

Comments
 (0)