Skip to content

Commit 0a2de89

Browse files
Sync 2.14.0 to Dev (#268)
2.14.0 (2021-10-27) ------------------- **Added** * Added String representing product abbreviation to ProductCategory Enum (`#266 <https://github.com/qbicsoftware/data-model-lib/pull/266>`_) * ProductId now provides 'From' method to be created via String representation (`#264 <https://github.com/qbicsoftware/data-model-lib/pull/264>`_) **Fixed** **Dependencies** **Deprecated** * ``life.qbic.datamodel.dtos.business.services.ProductType.groovy``. The abbreviation is now accessible via the ``abbreviation`` property in ``life.qbic.datamodel.dtos.business.ProductCategory`` (`#266 <https://github.com/qbicsoftware/data-model-lib/pull/266>`_)
1 parent 39a00d1 commit 0a2de89

22 files changed

+172
-190
lines changed

.github/workflows/build_docs.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.qube.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ email: sven.fillinger@qbic.uni-tuebingen.de
44
project_name: data-model-lib
55
project_short_description: "Data models. A collection of QBiC's central data models\
66
\ and DTOs. "
7-
version: 2.14.0-SNAPSHOT
7+
version: 2.15.0-SNAPSHOT
88
domain: lib
99
language: groovy
1010
project_slug: data-model-lib

CHANGELOG.rst

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,33 @@ Changelog
44

55
This project adheres to `Semantic Versioning <https://semver.org/>`_.
66

7-
2.14.0-SNAPSHOT (2021-10-13)
7+
2.15.0-SNAPSHOT (2021-10-27)
88
----------------------------
99

1010
**Added**
1111

12-
* Added ProductTypeFactory ``life.qbic.datamodel.dtos.business.services.ProductTypeFactory``
13-
* ProductId now provides 'From' method to be created via String representation
12+
**Fixed**
13+
14+
**Dependencies**
15+
16+
**Deprecated**
17+
18+
19+
2.14.0 (2021-10-27)
20+
-------------------
21+
22+
**Added**
23+
24+
* Added String representing product abbreviation to ProductCategory Enum (`#266 <https://github.com/qbicsoftware/data-model-lib/pull/266>`_)
25+
* ProductId now provides 'From' method to be created via String representation (`#264 <https://github.com/qbicsoftware/data-model-lib/pull/264>`_)
1426

1527
**Fixed**
1628

1729
**Dependencies**
1830

1931
**Deprecated**
2032

33+
* ``life.qbic.datamodel.dtos.business.services.ProductType.groovy``. The abbreviation is now accessible via the ``abbreviation`` property in ``life.qbic.datamodel.dtos.business.ProductCategory`` (`#266 <https://github.com/qbicsoftware/data-model-lib/pull/266>`_)
2134

2235
2.13.0 (2021-10-13)
2336
-------------------
23.9 KB
Loading

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@
5555
# the built documents.
5656
#
5757
# The short X.Y version.
58-
version = '2.14.0-SNAPSHOT'
58+
version = '2.15.0-SNAPSHOT'
5959
# The full version, including alpha/beta/rc tags.
60-
release = '2.14.0-SNAPSHOT'
60+
release = '2.15.0-SNAPSHOT'
6161

6262
# The language for content autogenerated by Sphinx. Refer to documentation
6363
# for a list of supported languages.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<groupId>life.qbic</groupId>
99
<artifactId>data-model-lib</artifactId>
10-
<version>2.14.0-SNAPSHOT</version> <!-- <<QUBE_FORCE_BUMP>> -->
10+
<version>2.15.0-SNAPSHOT</version> <!-- <<QUBE_FORCE_BUMP>> -->
1111
<name>data-model-lib</name>
1212
<url>http://github.com/qbicsoftware/data-model-lib</url>
1313
<description>Data models. A collection of QBiC's central data models and DTOs. </description>

qube.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 2.14.0-SNAPSHOT
2+
current_version = 2.15.0-SNAPSHOT
33

44
[bumpversion_files_whitelisted]
55
dot_qube = .qube.yml

src/main/groovy/life/qbic/datamodel/dtos/business/ProductCategory.groovy

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,28 @@ package life.qbic.datamodel.dtos.business
99
*/
1010
enum ProductCategory {
1111

12-
SEQUENCING("Sequencing"),
13-
PROJECT_MANAGEMENT("Project Management"),
14-
PRIMARY_BIOINFO("Primary Bioinformatics"),
15-
SECONDARY_BIOINFO("Secondary Bioinformatics"),
16-
DATA_STORAGE("Data Storage"),
17-
PROTEOMIC("Proteomics"),
18-
METABOLOMIC("Metabolomics"),
19-
EXTERNAL_SERVICE("External Service")
12+
SEQUENCING("Sequencing", "SE"),
13+
PROJECT_MANAGEMENT("Project Management", "PM"),
14+
PRIMARY_BIOINFO("Primary Bioinformatics", "PB"),
15+
SECONDARY_BIOINFO("Secondary Bioinformatics", "SB"),
16+
DATA_STORAGE("Data Storage", "DS"),
17+
PROTEOMIC("Proteomics", "PR"),
18+
METABOLOMIC("Metabolomics", "ME"),
19+
EXTERNAL_SERVICE("External Service", "EXT")
2020

2121
/**
2222
* Value describing the enum type with a string
2323
*/
24-
private final String value
24+
private String value
2525

26-
ProductCategory(String value) {
26+
/**
27+
* Abbreviation for the enum type name
28+
*/
29+
private String abbreviation
30+
31+
ProductCategory(String value, String abbreviation) {
2732
this.value = value
33+
this.abbreviation = abbreviation
2834
}
2935

3036
/**
@@ -35,4 +41,14 @@ enum ProductCategory {
3541
String getValue() {
3642
return value
3743
}
44+
45+
/**
46+
* Returns the abbreviation associated to the given enum
47+
* This is <em>NOT</em> the same as {@link #toString}
48+
* @return a user-friendly string value
49+
*/
50+
String getAbbreviation() {
51+
return abbreviation
52+
}
53+
3854
}

src/main/groovy/life/qbic/datamodel/dtos/business/ProductCategoryFactory.groovy

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,20 @@ class ProductCategoryFactory extends EnumFactory<ProductCategory>{
2727
}
2828
return desiredKey
2929
}
30+
31+
/**
32+
* This method returns the enum with the provided String abbreviation.
33+
*
34+
* @throws IllegalArgumentException in case the String could not be mapped
35+
* @param abbreviation the String corresponding to the abbreviation stored in the enum
36+
* @return the enum key for the provided abbreviation
37+
*/
38+
ProductCategory getForAbbreviation(String abbreviation) {
39+
ProductCategory desiredKey
40+
desiredKey = ProductCategory.values().find {it.abbreviation.equals(abbreviation.trim())}
41+
if (!desiredKey) {
42+
throw new IllegalArgumentException("Unknown abbreviation'$abbreviation' for ${ProductCategory.getSimpleName()}")
43+
}
44+
return desiredKey
45+
}
3046
}

src/main/groovy/life/qbic/datamodel/dtos/business/ProductId.groovy

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package life.qbic.datamodel.dtos.business
22

33
import groovy.transform.EqualsAndHashCode
4-
import life.qbic.datamodel.dtos.business.services.ProductType
5-
import life.qbic.datamodel.dtos.business.services.ProductTypeFactory
64

75
/**
86
* A DTO describing Product Identifiers
@@ -29,6 +27,9 @@ class ProductId implements Comparable<ProductId>{
2927
/**
3028
* A builder for ProductId instances.
3129
*/
30+
31+
private static final ProductCategoryFactory productCategoryFactory = new ProductCategoryFactory()
32+
3233
static class Builder {
3334
private String productType
3435
private long uniqueId
@@ -119,34 +120,33 @@ class ProductId implements Comparable<ProductId>{
119120
* Returns a ProductId from a given String representation
120121
*
121122
* Expects a ProductIdString with the Format P_N
122-
* P being the one of the abbreviation values stored in {@link ProductType} enum
123+
* P being the one of the abbreviation values stored in {@link ProductCategory} enum
123124
* N being an Integer Number
124125
*
125126
* @param String representation of a productId
126-
* @return ProductId containing type and uniqueNumber of String representation
127+
* @return ProductId containing productCategory abbreviation and uniqueNumber of String representation
127128
*/
128129
static ProductId from(String productId) {
129130
if (!productId.contains("_")) {
130-
throw new IllegalArgumentException("Not a valid product identifier.")
131+
throw new IllegalArgumentException("${productId} is not a valid product identifier.")
131132
}
132133
def splitId = productId.split("_")
133-
String productTypeString
134-
String runningNumberString
134+
String productCategoryString = splitId[0].trim()
135+
String runningNumberString = splitId[1].trim()
135136
Long runningNumber
137+
ProductCategory productCategory
136138
try {
137-
ProductTypeFactory productTypeFactory = new ProductTypeFactory()
138-
productTypeString = splitId[0].trim()
139-
runningNumberString = splitId[1].trim()
140139
runningNumber = Long.parseUnsignedLong(runningNumberString)
141-
ProductType productType = productTypeFactory.getForString(productTypeString)
140+
productCategory = productCategoryFactory.getForAbbreviation(productCategoryString)
142141
}
143142
catch (NumberFormatException numberFormatException) {
144-
throw new NumberFormatException("Provided productId does not have a valid uniqueID")
143+
throw new NumberFormatException("Provided productId does not have a valid uniqueID. Provided unique id: ${runningNumberString}")
145144
}
146145
catch (IllegalArgumentException illegalArgumentException) {
147-
throw new IllegalArgumentException("ProductId does not have a valid ProductType")
146+
throw new IllegalArgumentException("ProductId does not have a valid ProductCategory abbreviation. Provided abbreviation: ${productCategoryString}")
147+
148148
}
149-
return new Builder(productTypeString, runningNumber).build()
149+
return new Builder(productCategory.getAbbreviation() , runningNumber).build()
150150
}
151151

152152
/**

0 commit comments

Comments
 (0)