diff --git a/api/pom.xml b/api/pom.xml index 9172630..a8f471c 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -4,11 +4,11 @@ gov.nsa.datawave.microservice datawave-microservice-parent - 3.0.4 + 4.0.0-SNAPSHOT ../../../microservice-parent/pom.xml dictionary-api - 3.0.1-SNAPSHOT + 4.0.0-SNAPSHOT https://code.nsa.gov/datawave-dictionary-service scm:git:https://github.com/NationalSecurityAgency/datawave-dictionary-service.git @@ -18,9 +18,9 @@ http://webservice.datawave.nsa/v1 - 3.0.0 + 4.0.0-SNAPSHOT 31.1-jre - 3.0.0 + 4.0.0-SNAPSHOT diff --git a/api/src/main/java/datawave/webservice/model/Model.java b/api/src/main/java/datawave/webservice/model/Model.java index 48cbfda..ced294a 100644 --- a/api/src/main/java/datawave/webservice/model/Model.java +++ b/api/src/main/java/datawave/webservice/model/Model.java @@ -11,12 +11,17 @@ import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; + import datawave.query.model.FieldMapping; import datawave.webservice.HtmlProvider; import datawave.webservice.result.BaseResponse; -import lombok.Data; -@Data @XmlRootElement(name = "Model") @XmlAccessorType(XmlAccessType.NONE) public class Model extends BaseResponse implements Serializable, HtmlProvider { @@ -40,15 +45,53 @@ public Model(String jqueryUri, String datatablesUri) { public Model() {}; @XmlAttribute(name = "name", required = true) - private String name; + private String name = null; @XmlElementWrapper(name = "Mappings") @XmlElement(name = "Mapping") private TreeSet fields = new TreeSet(); + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public TreeSet getFields() { + return fields; + } + + public void setFields(TreeSet fields) { + this.fields = fields; + } + + @Override + public int hashCode() { + return new HashCodeBuilder(17, 37).append(name).append(fields).toHashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) + return false; + if (obj == this) + return true; + if (obj.getClass() != this.getClass()) + return false; + Model other = (Model) obj; + return new EqualsBuilder().append(name, other.name).append(fields, other.fields).isEquals(); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("name", name).append("fields", fields).toString(); + } + /* * (non-Javadoc) - * + * * @see datawave.webservice.HtmlProvider#getTitle() */ @Override @@ -58,7 +101,7 @@ public String getTitle() { /* * (non-Javadoc) - * + * * @see datawave.webservice.HtmlProvider#getPageHeader() */ @Override @@ -68,7 +111,7 @@ public String getPageHeader() { /* * (non-Javadoc) - * + * * @see datawave.webservice.HtmlProvider#getHeadContent() */ @Override @@ -78,7 +121,7 @@ public String getHeadContent() { /* * (non-Javadoc) - * + * * @see datawave.webservice.HtmlProvider#getMainContent() */ @Override @@ -89,16 +132,32 @@ public String getMainContent() { builder.append("
\n"); builder.append("\n"); - builder.append(""); + builder.append(""); builder.append(""); + // first gather the model fields that are deemed "lenient" (i.e. where the model field name has a lenient attribute) + Multimap modelFieldAttributes = HashMultimap.create(); + for (FieldMapping field : this.getFields()) { + if (!field.isFieldMapping()) { + modelFieldAttributes.putAll(field.getModelFieldName(), field.getAttributes()); + } + } + for (FieldMapping f : this.getFields()) { - builder.append(""); - builder.append(""); - builder.append(""); - builder.append(""); - builder.append(""); - builder.append(""); + // don't include model field attributes + if (f.isFieldMapping()) { + builder.append(""); + builder.append(""); + builder.append(""); + builder.append(""); + builder.append(""); + TreeSet attributes = new TreeSet<>(f.getAttributes()); + if (modelFieldAttributes.containsKey(f.getModelFieldName())) { + attributes.addAll(modelFieldAttributes.get(f.getModelFieldName())); + } + builder.append(""); + builder.append(""); + } } builder.append(""); diff --git a/pom.xml b/pom.xml index 7815333..c5f9d8d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,11 +4,11 @@ gov.nsa.datawave.microservice datawave-microservice-parent - 3.0.4 + 4.0.0-SNAPSHOT ../../microservice-parent/pom.xml dictionary-service-parent - 3.0.1-SNAPSHOT + 4.0.0-SNAPSHOTpomhttps://code.nsa.gov/datawave-dictionary-service diff --git a/service/pom.xml b/service/pom.xml index 96ebf2f..ad87f6d 100644 --- a/service/pom.xml +++ b/service/pom.xml @@ -4,11 +4,11 @@ gov.nsa.datawave.microservice datawave-microservice-service-parent - 4.0.4 + 5.0.0-SNAPSHOT ../../../microservice-service-parent/pom.xml dictionary-service - 3.0.1-SNAPSHOT + 4.0.0-SNAPSHOT DATAWAVE Dictionary Service https://code.nsa.gov/datawave-dictionary-service @@ -21,10 +21,10 @@ datawave.microservice.dictionary.DictionaryService 2.1.1 5.2.0 - 3.0.1 - 3.0.0 - 3.0.0 - 2.0.0 + 4.0.0-SNAPSHOT + 4.0.0-SNAPSHOT + 4.0.0-SNAPSHOT + 3.0.0-SNAPSHOT 1.11.4 3.6.0 0.50 diff --git a/service/src/main/java/datawave/microservice/model/ModelController.java b/service/src/main/java/datawave/microservice/model/ModelController.java index 5396dc8..1884ab2 100644 --- a/service/src/main/java/datawave/microservice/model/ModelController.java +++ b/service/src/main/java/datawave/microservice/model/ModelController.java @@ -48,7 +48,7 @@ url = "https://github.com/NationalSecurityAgency/datawave-dictionary-service")) @Slf4j @RestController -@RequestMapping(path = "/model", +@RequestMapping(path = "/model/v1", produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE, MediaType.TEXT_XML_VALUE, ProtostuffHttpMessageConverter.PROTOSTUFF_VALUE, MediaType.TEXT_HTML_VALUE, "text/x-yaml", "application/x-yaml"}) @Secured({"AuthorizedUser", "AuthorizedQueryServer", "InternalUser", "Administrator", "JBossAdministrator"}) diff --git a/service/src/test/java/datawave/microservice/model/ModelControllerTest.java b/service/src/test/java/datawave/microservice/model/ModelControllerTest.java index ab1533c..d52e631 100644 --- a/service/src/test/java/datawave/microservice/model/ModelControllerTest.java +++ b/service/src/test/java/datawave/microservice/model/ModelControllerTest.java @@ -114,7 +114,7 @@ public void testList() { // @formatter:off UriComponents uri = UriComponentsBuilder.newInstance() .scheme("https").host("localhost").port(webServicePort) - .path("/dictionary/model/list") + .path("/dictionary/model/v1/list") .build(); // @formatter:on @@ -130,7 +130,7 @@ public void testImportAKAInsert() { // @formatter:off UriComponents uri = UriComponentsBuilder.newInstance() .scheme("https").host("localhost").port(webServicePort) - .path("/dictionary/model/list") + .path("/dictionary/model/v1/list") .build(); // @formatter:on @@ -142,7 +142,7 @@ public void testImportAKAInsert() { // @formatter:off uri = UriComponentsBuilder.newInstance() .scheme("https").host("localhost").port(webServicePort) - .path("/dictionary/model/import") + .path("/dictionary/model/v1/import") .build(); // @formatter:on @@ -157,7 +157,7 @@ public void testImportAKAInsert() { // @formatter:off uri = UriComponentsBuilder.newInstance() .scheme("https").host("localhost").port(webServicePort) - .path("/dictionary/model/list") + .path("/dictionary/model/v1/list") .build(); // @formatter:on @@ -172,7 +172,7 @@ public void testClone() { // @formatter:off UriComponents uri = UriComponentsBuilder.newInstance() .scheme("https").host("localhost").port(webServicePort) - .path("/dictionary/model/list") + .path("/dictionary/model/v1/list") .build(); // @formatter:on @@ -185,7 +185,7 @@ public void testClone() { // @formatter:off uri = UriComponentsBuilder.newInstance() .scheme("https").host("localhost").port(webServicePort) - .path("/dictionary/model/clone") + .path("/dictionary/model/v1/clone") .queryParam("name", MODEL_ONE.getName()) .queryParam("newName", newName) .build(); @@ -199,7 +199,7 @@ public void testClone() { assertEquals(HttpStatus.OK, imprtResponse.getStatusCode()); // There should now be 2 models.... - uri = UriComponentsBuilder.newInstance().scheme("https").host("localhost").port(webServicePort).path("/dictionary/model/list").build(); + uri = UriComponentsBuilder.newInstance().scheme("https").host("localhost").port(webServicePort).path("/dictionary/model/v1/list").build(); // @formatter:on ResponseEntity modelListResponse2 = jwtRestTemplate.exchange(adminUser, HttpMethod.GET, uri, ModelList.class); @@ -216,7 +216,7 @@ public void testGet() { // @formatter:off UriComponents uri = UriComponentsBuilder.newInstance() .scheme("https").host("localhost").port(webServicePort) - .path("/dictionary/model/list") + .path("/dictionary/model/v1/list") .build(); // @formatter:on @@ -228,7 +228,7 @@ public void testGet() { // @formatter:off uri = UriComponentsBuilder.newInstance() .scheme("https").host("localhost").port(webServicePort) - .path("/dictionary/model/{name}") + .path("/dictionary/model/v1/{name}") .queryParam("name", MODEL_ONE.getName()) .build(); // @formatter:on @@ -243,7 +243,7 @@ public void testDelete() { // @formatter:off UriComponents uri = UriComponentsBuilder.newInstance() .scheme("https").host("localhost").port(webServicePort) - .path("/dictionary/model/list") + .path("/dictionary/model/v1/list") .build(); // @formatter:on @@ -255,7 +255,7 @@ public void testDelete() { // @formatter:off uri = UriComponentsBuilder.newInstance() .scheme("https").host("localhost").port(webServicePort) - .path("/dictionary/model/delete") + .path("/dictionary/model/v1/delete") .build(); // @formatter:on HttpHeaders additionalHeaders = new HttpHeaders(); @@ -265,7 +265,7 @@ public void testDelete() { assertEquals(HttpStatus.OK, imprtResponse.getStatusCode()); // Verify that it was deleted - uri = UriComponentsBuilder.newInstance().scheme("https").host("localhost").port(webServicePort).path("/dictionary/model/list").build(); + uri = UriComponentsBuilder.newInstance().scheme("https").host("localhost").port(webServicePort).path("/dictionary/model/v1/list").build(); // @formatter:on ResponseEntity modelListResponse2 = jwtRestTemplate.exchange(adminUser, HttpMethod.GET, uri, ModelList.class);
VisibilityFieldNameDataTypeModelFieldNameDirection
VisibilityFieldNameDataTypeModelFieldNameDirectionAttributes
").append(f.getColumnVisibility()).append("").append(f.getFieldName()).append("").append(f.getDatatype()).append("").append(f.getModelFieldName()).append("").append(f.getDirection()).append("
").append(f.getColumnVisibility()).append("").append(f.getFieldName()).append("").append(f.getDatatype()).append("").append(f.getModelFieldName()).append("").append(f.getDirection()).append("").append(attributes).append("