Skip to content
Snippets Groups Projects
Commit 16b0ee2b authored by Marc Burnie [AWS]'s avatar Marc Burnie [AWS]
Browse files

Merge branch 'feature/legaltag_extensionProperties' into 'master'

Feature/legaltag extension properties

See merge request !291
parents 59f15ea2 4fd2e502
No related branches found
No related tags found
1 merge request!291Feature/legaltag extension properties
Pipeline #138893 failed
Showing
with 114 additions and 10 deletions
......@@ -439,7 +439,7 @@ The following software have components provided under the terms of this license:
- Jackson datatype: Joda (from http://wiki.fasterxml.com/JacksonModuleJoda, https://github.com/FasterXML/jackson-datatype-joda)
- Jackson datatype: jdk8 (from https://repo1.maven.org/maven2/com/fasterxml/jackson/datatype/jackson-datatype-jdk8)
- Jackson module: Afterburner (from http://wiki.fasterxml.com/JacksonHome, https://github.com/FasterXML/jackson-modules-base)
- Jackson-annotations (from http://github.com/FasterXML/jackson, http://wiki.fasterxml.com/JacksonHome)
- Jackson-annotations (from http://github.com/FasterXML/jackson, http://wiki.fasterxml.com/JacksonHome, https://github.com/FasterXML/jackson)
- Jackson-core (from http://wiki.fasterxml.com/JacksonHome, https://github.com/FasterXML/jackson-core)
- Jackson-dataformat-XML (from http://wiki.fasterxml.com/JacksonExtensionXmlDataBinding, https://github.com/FasterXML/jackson-dataformat-xml)
- Jackson-dataformat-YAML (from https://github.com/FasterXML/jackson, https://github.com/FasterXML/jackson-dataformats-text)
......@@ -606,7 +606,7 @@ The following software have components provided under the terms of this license:
- io.grpc:grpc-protobuf-lite (from https://github.com/grpc/grpc-java)
- io.grpc:grpc-stub (from https://github.com/grpc/grpc-java)
- ion-java (from https://github.com/amzn/ion-java/, https://github.com/amznlabs/ion-java/)
- jackson-databind (from http://github.com/FasterXML/jackson, http://wiki.fasterxml.com/JacksonHome)
- jackson-databind (from http://github.com/FasterXML/jackson, http://wiki.fasterxml.com/JacksonHome, https://github.com/FasterXML/jackson)
- java-cloudant (from https://cloudant.com)
- javatuples (from http://www.javatuples.org)
- javax.annotation-api (from http://jcp.org/en/jsr/detail?id=250)
......@@ -1168,6 +1168,8 @@ The following software have components provided under the terms of this license:
========================================================================
unknown
========================================================================
The following software have components provided under the terms of this license:
- Bouncy Castle Provider (from http://www.bouncycastle.org/java.html, https://www.bouncycastle.org/java.html)
- Byte Buddy (without dependencies) (from https://repo1.maven.org/maven2/net/bytebuddy/byte-buddy)
- Checker Qual (from https://checkerframework.org)
......@@ -1181,7 +1183,10 @@ unknown
- JUnit Platform Engine API (from http://junit.org/junit5/, https://junit.org/junit5/)
- Jakarta Activation API (from https://github.com/eclipse-ee4j/jaf, https://repo1.maven.org/maven2/jakarta/activation/jakarta.activation-api)
- Jakarta XML Binding API (from https://repo1.maven.org/maven2/jakarta/xml/bind/jakarta.xml.bind-api, https://repo1.maven.org/maven2/org/jboss/spec/javax/xml/bind/jboss-jaxb-api_2.3_spec)
- xml-apis
- Java Native Access (from https://github.com/java-native-access/jna, https://github.com/twall/jna, https://repo1.maven.org/maven2/net/java/dev/jna/jna)
- Java Native Access Platform (from https://github.com/java-native-access/jna)
- System Rules (from http://stefanbirkner.github.com/system-rules/, http://stefanbirkner.github.io/system-rules/)
- xml-apis (from https://repo1.maven.org/maven2/xml-apis/xml-apis)
========================================================================
xpp
......
......@@ -478,6 +478,10 @@ definitions:
type: string
example: EAR99
description: The ECCN value of the data if one applies.
extensionProperties:
type: object
additionalProperties: true
description: The optional object field to attach any company specific attributes.
description: LegalTag properties
UpdateLegalTag:
type: object
......@@ -498,7 +502,11 @@ definitions:
expirationDate:
type: string
example: '2025-12-25'
description: The optional expiration date of the contract in the format YYYY-MM-DD
description: The optional expiration date of the contract in the format YYYY-MM-DD.
extensionProperties:
type: object
additionalProperties: true
description: The optional object field to attach any company specific attributes.
description: The model to update an existing LegalTag
VersionInfo:
type: "object"
......
......@@ -101,7 +101,10 @@ curl --request POST \
"originator":"OSDU",
"securityClassification":"Public",
"exportClassification":"EAR99",
"personalData":"No Personal Data"
"personalData":"No Personal Data",
"extensionProperties": {
"anyCompanySpecificAttributes": "anyJsonTypeOfvalue"
}
}
}'
```
......@@ -110,6 +113,8 @@ curl --request POST \
It is good practice for LegalTag names to be clear and descriptive of the properties it represents, so it would be easy to discover and to associate to the correct data with it. Also, the description field is a free form optional field to allow for you to add context to the LegalTag, making easier to understand and retrieve over time.
The "extensionProperties" field is an optional json object field and you may add any company specific attributes inside this field.
When creating LegalTags, the name is automatically prefixed with the data-partition-name that is assigned to the partition. So in the example above, if the given data-partition-name is **mypartition**, then the actual name of the LegalTag would be **mypartition-demo-legaltag**.
Valid values: The legalTag name needs to be between 3 and 100 characters and only alphanumeric characters and hyphens are allowed
......@@ -435,7 +440,7 @@ Ingestion services forward the request to the LegalTag API using the same _SAuth
## Updating a LegalTag<a name="Updating-a-LegalTag"></a>
One of the main cases where a LegalTag can become invalid is if a contract expiration date passes. This makes both the LegalTag invalid and *all* data associated with that LegalTag including derivatives.
In these situations we can update LegalTags to make them valid again and so make the associated data accessible. Currently we only allow the update of the *description*, *contract ID* and *expiration date* properties.
In these situations we can update LegalTags to make them valid again and so make the associated data accessible. Currently we only allow the update of the *description*, *contract ID*, *expiration date* and *extensionProperties* properties.
PUT /api/legal/v1/legaltags
......@@ -450,8 +455,11 @@ curl --request PUT \
--header 'data-partition-id: opendes' \
--data '{
"name": "opendes-demo-legaltag",
"contractId": "AE12345"
"expirationDate": "2099-12-21"
"contractId": "AE12345",
"expirationDate": "2099-12-21",
"extensionProperties": {
"anyCompanySpecificAttributes": "anyJsonTypeOfvalue"
}
}
}'
```
......
......@@ -18,6 +18,7 @@ public interface ILegalTagRepository {
String SECURITY_CLASSIFICATION = "securityClassification";
String EXPORT_CLASSIFICATION = "exportClassification";
String PERSONAL_DATA = "personalData";
String EXTENSION_PROPERTIES = "extensionProperties";
String DESCRIPTION = "description";
String NAME = "name";
......
......@@ -166,6 +166,7 @@ public class LegalTagService {
currentLegalTag.getProperties().setContractId(newLegalTag.getContractId());
currentLegalTag.getProperties().setExpirationDate(newLegalTag.getExpirationDate());
currentLegalTag.getProperties().setExtensionProperties(newLegalTag.getExtensionProperties());
currentLegalTag.setDescription(newLegalTag.getDescription());
validator.isValidThrows(currentLegalTag);
......
package org.opengroup.osdu.legal.tags.dto;
import java.sql.Date;
import java.util.Map;
import org.opengroup.osdu.core.common.model.legal.validation.ValidDescription;
import org.opengroup.osdu.core.common.model.legal.validation.ValidName;
import lombok.AllArgsConstructor;
......@@ -24,4 +26,6 @@ public class UpdateLegalTag {
private String description = "";
private Date expirationDate;
private Map<String, Object> extensionProperties;
}
......@@ -264,6 +264,7 @@ public class LegalTagServiceTests {
assertEquals(result.getName(), updateTag.getName());
assertEquals(result.getProperties().getContractId(), updateTag.getContractId());
assertEquals(result.getProperties().getExpirationDate(), updateTag.getExpirationDate());
assertEquals(result.getProperties().getExtensionProperties(), updateTag.getExtensionProperties());
assertEquals(result.getDescription(), updateTag.getDescription());
verify(validator, times(1)).isValidThrows(any());
}
......
......@@ -7,6 +7,9 @@ import org.opengroup.osdu.core.common.model.legal.LegalTag;
import org.opengroup.osdu.core.common.model.legal.Properties;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
public class LegalTestUtils {
public static LegalTag createValidLegalTag(String name){
......@@ -27,6 +30,16 @@ public class LegalTestUtils {
properties.setPersonalData("Sensitive Personal Information");
properties.setSecurityClassification("Confidential");
properties.setExportClassification("ECCN");
Map<String, Object> extensionProperties = new LinkedHashMap <String, Object>();
extensionProperties.put("EffectiveDate", "2022-06-01T00:00:00");
extensionProperties.put("AffiliateEnablementIndicator", true);
Map<String, Object> agreementParty = new LinkedHashMap <String, Object>();
agreementParty.put("AgreementPartyType", "EnabledAffiliate");
agreementParty.put("AgreementParty", "osdu:master-data--Organisation:TestCompany");
extensionProperties.put("AgreementParties", Arrays.asList(agreementParty));
properties.setExtensionProperties(extensionProperties);
return properties;
}
public static UpdateLegalTag createUpdateLegalTag(String name){
......@@ -35,6 +48,15 @@ public class LegalTestUtils {
legalTag.setContractId("abc123");
legalTag.setName(name);
legalTag.setDescription("myDescription");
Map<String, Object> extensionProperties = new LinkedHashMap <String, Object>();
extensionProperties.put("EffectiveDate", "2022-06-01T00:00:00");
extensionProperties.put("AffiliateEnablementIndicator", false);
Map<String, Object> agreementParty = new LinkedHashMap <String, Object>();
agreementParty.put("AgreementPartyType", "PurchaseOrganisation");
agreementParty.put("AgreementParty", "osdu:master-data--Organisation:TestCompany");
extensionProperties.put("AgreementParties", Arrays.asList(agreementParty));
return legalTag;
}
public static LegalTagDto createValidLegalTagDto(String name){
......
......@@ -109,6 +109,16 @@ public class LegalTagTests {
properties.setPersonalData("Personally Identifiable");
properties.setSecurityClassification("Confidential");
properties.setExportClassification("EAR99");
Map<String, Object> extensionProperties = new LinkedHashMap <String, Object>();
extensionProperties.put("EffectiveDate", "2022-06-01T00:00:00");
extensionProperties.put("AffiliateEnablementIndicator", true);
Map<String, Object> agreementParty = new LinkedHashMap <String, Object>();
agreementParty.put("AgreementPartyType", "EnabledAffiliate");
agreementParty.put("AgreementParty", "osdu:master-data--Organisation:TestCompany");
extensionProperties.put("AgreementParties", Arrays.asList(agreementParty));
properties.setExtensionProperties(extensionProperties);
LegalTag legalTag = new LegalTag();
legalTag.setProperties(properties);
legalTag.setId(1L);
......
......@@ -152,6 +152,15 @@ public class PropertiesTests {
sut.setSecurityClassification("Confidential");
sut.setExportClassification("EAR99");
sut.setExpirationDate(Properties.DEFAULT_EXPIRATIONDATE);
Map<String, Object> extensionProperties = new LinkedHashMap <String, Object>();
extensionProperties.put("EffectiveDate", "2022-06-01T00:00:00");
extensionProperties.put("AffiliateEnablementIndicator", true);
Map<String, Object> agreementParty = new LinkedHashMap <String, Object>();
agreementParty.put("AgreementPartyType", "EnabledAffiliate");
agreementParty.put("AgreementParty", "osdu:master-data--Organisation:TestCompany");
extensionProperties.put("AgreementParties", Arrays.asList(agreementParty));
sut.setExtensionProperties(extensionProperties);
return sut;
}
......
......@@ -14,6 +14,8 @@ import java.sql.Date;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertFalse;
......@@ -217,6 +219,16 @@ public class PropertiesValidatorTests {
properties.setOriginator(originator);
properties.setExpirationDate(ts);
properties.setCountryOfOrigin(new ArrayList<String>(){{add("FR");}});
Map<String, Object> extensionProperties = new LinkedHashMap <String, Object>();
extensionProperties.put("EffectiveDate", "2022-06-01T00:00:00");
extensionProperties.put("AffiliateEnablementIndicator", true);
Map<String, Object> agreementParty = new LinkedHashMap <String, Object>();
agreementParty.put("AgreementPartyType", "EnabledAffiliate");
agreementParty.put("AgreementParty", "osdu:master-data--Organisation:TestCompany");
extensionProperties.put("AgreementParties", Arrays.asList(agreementParty));
properties.setExtensionProperties(extensionProperties);
return properties;
}
}
......@@ -8,13 +8,14 @@
<maven.compiler.source>1.8</maven.compiler.source>
<docker.image.prefix>opendes</docker.image.prefix>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<os-core-common.version>0.16.0</os-core-common.version>
<os-core-common.version>0.17.0-rc4</os-core-common.version>
<snakeyaml.version>1.26</snakeyaml.version>
<resilience4jVersion>1.7.0</resilience4jVersion>
<springfox.version>3.0.0</springfox.version>
<log4j.version>2.17.1</log4j.version>
<json-smart.version>2.4.7</json-smart.version>
<jackson-databind.version>2.13.2.2</jackson-databind.version>
<jackson.version>2.13.2</jackson.version>
</properties>
<licenses>
......@@ -60,7 +61,19 @@
</distributionManagement>
<dependencyManagement>
<dependencies>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.4.12</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.4.12</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
......@@ -108,6 +121,16 @@
<artifactId>json-smart</artifactId>
<version>${json-smart.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment