Skip to content

Commit

Permalink
Release/2.14.0 (#266)
Browse files Browse the repository at this point in the history
2.14.0 (2021-10-27)
-------------------

**Added**

* Added String representing product abbreviation to ProductCategory Enum (`#266)
* ProductId now provides 'From' method to be created via String representation (`#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)
  • Loading branch information
Steffengreiner authored Oct 27, 2021
1 parent a561ac0 commit 94e2815
Show file tree
Hide file tree
Showing 20 changed files with 270 additions and 101 deletions.
34 changes: 0 additions & 34 deletions .github/workflows/build_docs.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .qube.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ email: [email protected]
project_name: data-model-lib
project_short_description: "Data models. A collection of QBiC's central data models\
\ and DTOs. "
version: 2.13.0
version: 2.14.0
domain: lib
language: groovy
project_slug: data-model-lib
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ Changelog

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

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>`_)

2.13.0 (2021-10-13)
-------------------

Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
# the built documents.
#
# The short X.Y version.
version = '2.13.0'
version = '2.14.0'
# The full version, including alpha/beta/rc tags.
release = '2.13.0'
release = '2.14.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>life.qbic</groupId>
<artifactId>data-model-lib</artifactId>
<version>2.13.0</version> <!-- <<QUBE_FORCE_BUMP>> -->
<version>2.14.0</version> <!-- <<QUBE_FORCE_BUMP>> -->
<name>data-model-lib</name>
<url>http://github.com/qbicsoftware/data-model-lib</url>
<description>Data models. A collection of QBiC's central data models and DTOs. </description>
Expand Down
2 changes: 1 addition & 1 deletion qube.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.13.0
current_version = 2.14.0

[bumpversion_files_whitelisted]
dot_qube = .qube.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,28 @@ package life.qbic.datamodel.dtos.business
*/
enum ProductCategory {

SEQUENCING("Sequencing"),
PROJECT_MANAGEMENT("Project Management"),
PRIMARY_BIOINFO("Primary Bioinformatics"),
SECONDARY_BIOINFO("Secondary Bioinformatics"),
DATA_STORAGE("Data Storage"),
PROTEOMIC("Proteomics"),
METABOLOMIC("Metabolomics"),
EXTERNAL_SERVICE("External Service")
SEQUENCING("Sequencing", "SE"),
PROJECT_MANAGEMENT("Project Management", "PM"),
PRIMARY_BIOINFO("Primary Bioinformatics", "PB"),
SECONDARY_BIOINFO("Secondary Bioinformatics", "SB"),
DATA_STORAGE("Data Storage", "DS"),
PROTEOMIC("Proteomics", "PR"),
METABOLOMIC("Metabolomics", "ME"),
EXTERNAL_SERVICE("External Service", "EXT")

/**
* Value describing the enum type with a string
*/
private final String value
private String value

ProductCategory(String value) {
/**
* Abbreviation for the enum type name
*/
private String abbreviation

ProductCategory(String value, String abbreviation) {
this.value = value
this.abbreviation = abbreviation
}

/**
Expand All @@ -35,4 +41,14 @@ enum ProductCategory {
String getValue() {
return value
}

/**
* Returns the abbreviation associated to the given enum
* This is <em>NOT</em> the same as {@link #toString}
* @return a user-friendly string value
*/
String getAbbreviation() {
return abbreviation
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,20 @@ class ProductCategoryFactory extends EnumFactory<ProductCategory>{
}
return desiredKey
}

/**
* This method returns the enum with the provided String abbreviation.
*
* @throws IllegalArgumentException in case the String could not be mapped
* @param abbreviation the String corresponding to the abbreviation stored in the enum
* @return the enum key for the provided abbreviation
*/
ProductCategory getForAbbreviation(String abbreviation) {
ProductCategory desiredKey
desiredKey = ProductCategory.values().find {it.abbreviation.equals(abbreviation.trim())}
if (!desiredKey) {
throw new IllegalArgumentException("Unknown abbreviation'$abbreviation' for ${ProductCategory.getSimpleName()}")
}
return desiredKey
}
}
36 changes: 36 additions & 0 deletions src/main/groovy/life/qbic/datamodel/dtos/business/ProductId.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class ProductId implements Comparable<ProductId>{
/**
* A builder for ProductId instances.
*/

private static final ProductCategoryFactory productCategoryFactory = new ProductCategoryFactory()

static class Builder {
private String productType
private long uniqueId
Expand Down Expand Up @@ -113,6 +116,39 @@ class ProductId implements Comparable<ProductId>{
return type
}

/**
* Returns a ProductId from a given String representation
*
* Expects a ProductIdString with the Format P_N
* P being the one of the abbreviation values stored in {@link ProductCategory} enum
* N being an Integer Number
*
* @param String representation of a productId
* @return ProductId containing productCategory abbreviation and uniqueNumber of String representation
*/
static ProductId from(String productId) {
if (!productId.contains("_")) {
throw new IllegalArgumentException("${productId} is not a valid product identifier.")
}
def splitId = productId.split("_")
String productCategoryString = splitId[0].trim()
String runningNumberString = splitId[1].trim()
Long runningNumber
ProductCategory productCategory
try {
runningNumber = Long.parseUnsignedLong(runningNumberString)
productCategory = productCategoryFactory.getForAbbreviation(productCategoryString)
}
catch (NumberFormatException numberFormatException) {
throw new NumberFormatException("Provided productId does not have a valid uniqueID. Provided unique id: ${runningNumberString}")
}
catch (IllegalArgumentException illegalArgumentException) {
throw new IllegalArgumentException("ProductId does not have a valid ProductCategory abbreviation. Provided abbreviation: ${productCategoryString}")

}
return new Builder(productCategory.getAbbreviation() , runningNumber).build()
}

/**
* Returns a String representation in the format:
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package life.qbic.datamodel.dtos.business.services

import groovy.transform.EqualsAndHashCode
import life.qbic.datamodel.dtos.business.ProductCategory
import life.qbic.datamodel.dtos.business.ProductId
import life.qbic.datamodel.dtos.business.facilities.Facility

Expand All @@ -20,12 +21,12 @@ class DataStorage extends PartialProduct {
* @param description The description of what the product is about.
* @param unitPrice The price in € per unit
* @param unit The product unit
* @param runningNumber Number used in conjunction with ProductType{@link life.qbic.datamodel.dtos.business.services.ProductType} to identify product
* @param runningNumber Number used in conjunction with {@link ProductCategory} to identify product
* @deprecated since 2.5.0
*/
@Deprecated
DataStorage(String name, String description, double unitPrice, ProductUnit unit, String runningNumber) {
super(name, description, unitPrice, unit, new ProductId(ProductType.DATA_STORAGE.toString(), runningNumber))
super(name, description, unitPrice, unit, new ProductId(ProductCategory.DATA_STORAGE.getAbbreviation(), runningNumber))
}

/**
Expand All @@ -37,13 +38,13 @@ class DataStorage extends PartialProduct {
* @param description The description of what the product is about.
* @param unitPrice The price in € per unit
* @param unit The product unit
* @param runningNumber Number used in conjunction with ProductType{@link life.qbic.datamodel.dtos.business.services.ProductType} to identify product
* @param runningNumber Number used in conjunction with {@link ProductCategory} to identify product
*
* @deprecated 2.11.0
*/
@Deprecated
DataStorage(String name, String description, double unitPrice, ProductUnit unit, long runningNumber) {
super(name, description, unitPrice, unit, new ProductId.Builder(ProductType.DATA_STORAGE.toString(), runningNumber).build())
super(name, description, unitPrice, unit, new ProductId.Builder(ProductCategory.DATA_STORAGE.getAbbreviation(), runningNumber).build())
}

/**
Expand All @@ -56,11 +57,11 @@ class DataStorage extends PartialProduct {
* @param internalUnitPrice The price in € per unit for internal customers
* @param externalUnitPrice The price in € per unit for external customers
* @param unit The product unit
* @param runningNumber Number used in conjunction with ProductType{@link life.qbic.datamodel.dtos.business.services.ProductType} to identify product
* @param runningNumber Number used in conjunction with {@link ProductCategory} to identify product
*
* @since 2.11.0
*/
DataStorage(String name, String description, double internalUnitPrice, double externalUnitPrice, ProductUnit unit, long runningNumber, Facility serviceProvider) {
super(name, description, internalUnitPrice, externalUnitPrice, unit, new ProductId.Builder(ProductType.DATA_STORAGE.toString(), runningNumber).build(), serviceProvider)
super(name, description, internalUnitPrice, externalUnitPrice, unit, new ProductId.Builder(ProductCategory.DATA_STORAGE.getAbbreviation(), runningNumber).build(), serviceProvider)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package life.qbic.datamodel.dtos.business.services

import groovy.transform.EqualsAndHashCode
import life.qbic.datamodel.dtos.business.ProductCategory
import life.qbic.datamodel.dtos.business.ProductId
import life.qbic.datamodel.dtos.business.facilities.Facility

Expand All @@ -24,6 +25,7 @@ class ExternalServiceProduct extends PartialProduct {
* @param serviceProvider The service provider
*/
ExternalServiceProduct(String name, String description, double internalUnitPrice, double externalUnitPrice, ProductUnit unit, long runningNumber, Facility serviceProvider) {
super(name, description, internalUnitPrice, externalUnitPrice, unit, new ProductId.Builder(ProductType.EXTERNAL_SERVICE.toString(), runningNumber).build(), serviceProvider)
super(name, description, internalUnitPrice, externalUnitPrice, unit, new ProductId.Builder(
ProductCategory.EXTERNAL_SERVICE.getAbbreviation(), runningNumber).build(), serviceProvider)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package life.qbic.datamodel.dtos.business.services

import groovy.transform.EqualsAndHashCode
import life.qbic.datamodel.dtos.business.ProductCategory
import life.qbic.datamodel.dtos.business.ProductId
import life.qbic.datamodel.dtos.business.facilities.Facility

Expand All @@ -20,12 +21,12 @@ class MetabolomicAnalysis extends AtomicProduct {
* @param description The description of what the product is about.
* @param unitPrice The price in € per unit
* @param unit The product unit
* @param runningNumber Number used in conjunction with ProductType{@link life.qbic.datamodel.dtos.business.services.ProductType} to identify product
* @param runningNumber Number used in conjunction with {@link ProductCategory} to identify product
* @deprecated since 2.5.0
*/
@Deprecated
MetabolomicAnalysis(String name, String description, double unitPrice, ProductUnit unit, String runningNumber) {
super(name, description, unitPrice, unit, new ProductId(ProductType.METABOLOMIC.toString(), runningNumber))
super(name, description, unitPrice, unit, new ProductId(ProductCategory.METABOLOMIC.getAbbreviation(), runningNumber))
}

/**
Expand All @@ -37,13 +38,13 @@ class MetabolomicAnalysis extends AtomicProduct {
* @param description The description of what the product is about.
* @param unitPrice The price in € per unit
* @param unit The product unit
* @param runningNumber Number used in conjunction with ProductType{@link life.qbic.datamodel.dtos.business.services.ProductType} to identify product
* @param runningNumber Number used in conjunction with {@link ProductCategory} to identify product
*
* @deprecated 2.11.0
*/
@Deprecated
MetabolomicAnalysis(String name, String description, double unitPrice, ProductUnit unit, long runningNumber) {
super(name, description, unitPrice, unit, new ProductId.Builder(ProductType.METABOLOMIC.toString(), runningNumber).build())
super(name, description, unitPrice, unit, new ProductId.Builder(ProductCategory.METABOLOMIC.getAbbreviation(), runningNumber).build())
}

/**
Expand All @@ -56,13 +57,13 @@ class MetabolomicAnalysis extends AtomicProduct {
* @param internalUnitPrice The price in € per unit for internal customers
* @param externalUnitPrice The price in € per unit for external customers
* @param unit The product unit
* @param runningNumber Number used in conjunction with ProductType{@link life.qbic.datamodel.dtos.business.services.ProductType} to identify product
* @param runningNumber Number used in conjunction with {@link ProductCategory} to identify product
* @param serviceProvider The facility providing the service product
*
* @since 2.11.0
*/
MetabolomicAnalysis(String name, String description, double internalUnitPrice, double externalUnitPrice, ProductUnit unit, long runningNumber, Facility serviceProvider) {
super(name, description, internalUnitPrice, externalUnitPrice, unit, new ProductId.Builder(ProductType.METABOLOMIC.toString(), runningNumber).build(), serviceProvider)
super(name, description, internalUnitPrice, externalUnitPrice, unit, new ProductId.Builder(ProductCategory.METABOLOMIC.getAbbreviation(), runningNumber).build(), serviceProvider)
}
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package life.qbic.datamodel.dtos.business.services

import groovy.transform.EqualsAndHashCode
import life.qbic.datamodel.dtos.business.ProductCategory
import life.qbic.datamodel.dtos.business.ProductId
import life.qbic.datamodel.dtos.business.facilities.Facility

Expand All @@ -20,12 +21,12 @@ class PrimaryAnalysis extends AtomicProduct {
* @param description The description of what the product is about.
* @param unitPrice The price in € per unit
* @param unit The product unit
* @param runningNumber Number used in conjunction with ProductType{@link life.qbic.datamodel.dtos.business.services.ProductType} to identify product
* @param runningNumber Number used in conjunction with {@link ProductCategory} to identify product
* @deprecated since 2.5.0
*/
@Deprecated
PrimaryAnalysis(String name, String description, double unitPrice, ProductUnit unit, String runningNumber) {
super(name, description, unitPrice, unit, new ProductId(ProductType.PRIMARY_BIOINFO.toString(), runningNumber))
super(name, description, unitPrice, unit, new ProductId(ProductCategory.PRIMARY_BIOINFO.getAbbreviation(), runningNumber))
}

/**
Expand All @@ -37,13 +38,13 @@ class PrimaryAnalysis extends AtomicProduct {
* @param description The description of what the product is about.
* @param unitPrice The price in € per unit
* @param unit The product unit
* @param runningNumber Number used in conjunction with ProductType{@link life.qbic.datamodel.dtos.business.services.ProductType} to identify product
* @param runningNumber Number used in conjunction with {@link ProductCategory} to identify product
*
* @deprecated 2.11.0
*/
@Deprecated
PrimaryAnalysis(String name, String description, double unitPrice, ProductUnit unit, long runningNumber) {
super(name, description, unitPrice, unit, new ProductId.Builder(ProductType.PRIMARY_BIOINFO.toString(), runningNumber).build())
super(name, description, unitPrice, unit, new ProductId.Builder(ProductCategory.PRIMARY_BIOINFO.getAbbreviation(), runningNumber).build())
}

/**
Expand All @@ -56,12 +57,12 @@ class PrimaryAnalysis extends AtomicProduct {
* @param internalUnitPrice The price in € per unit for internal customers
* @param externalUnitPrice The price in € per unit for external customers
* @param unit The product unit
* @param runningNumber Number used in conjunction with ProductType{@link life.qbic.datamodel.dtos.business.services.ProductType} to identify product
* @param runningNumber Number used in conjunction with {@link ProductCategory} to identify product
* @param serviceProvider The facility providing the service product
*
* @since 2.11.0
*/
PrimaryAnalysis(String name, String description, double internalUnitPrice, double externalUnitPrice, ProductUnit unit, long runningNumber, Facility serviceProvider) {
super(name, description, internalUnitPrice, externalUnitPrice, unit, new ProductId.Builder(ProductType.PRIMARY_BIOINFO.toString(), runningNumber).build(), serviceProvider)
super(name, description, internalUnitPrice, externalUnitPrice, unit, new ProductId.Builder(ProductCategory.PRIMARY_BIOINFO.getAbbreviation(), runningNumber).build(), serviceProvider)
}
}
Loading

0 comments on commit 94e2815

Please sign in to comment.