Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DHFPROD-6693:Updates to step schema to support related entity mappings #5281

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.marklogic.hub.central.controllers.BaseController;
import com.marklogic.hub.central.schemas.StepSchema;
import com.marklogic.hub.central.schemas.MappingStepSchema;
import com.marklogic.hub.dataservices.ArtifactService;
import com.marklogic.hub.dataservices.MappingService;
import com.marklogic.hub.dataservices.StepService;
Expand Down Expand Up @@ -35,14 +35,14 @@ public ResponseEntity<JsonNode> getSteps() {
}

@RequestMapping(value = "/{stepName}", method = RequestMethod.GET)
@ApiOperation(value = "Get a step", response = StepSchema.class)
@ApiOperation(value = "Get a step", response = MappingStepSchema.class)
@Secured("ROLE_readMapping")
public ResponseEntity<JsonNode> getStep(@PathVariable String stepName) {
return ResponseEntity.ok(newService().getStep(STEP_DEFINITION_TYPE, stepName));
}

@RequestMapping(method = RequestMethod.POST)
@ApiImplicitParam(required = true, paramType = "body", dataType = "StepSchema")
@ApiImplicitParam(required = true, paramType = "body", dataType = "MappingStepSchema")
@Secured("ROLE_writeMapping")
public ResponseEntity<Void> createMappingStep(@RequestBody @ApiParam(hidden = true) ObjectNode propertiesToAssign) {
String stepName = propertiesToAssign.get("name").asText();
Expand All @@ -52,7 +52,7 @@ public ResponseEntity<Void> createMappingStep(@RequestBody @ApiParam(hidden = tr
}

@RequestMapping(value = "/{stepName}", method = RequestMethod.PUT)
@ApiImplicitParam(required = true, paramType = "body", dataType = "StepSchema")
@ApiImplicitParam(required = true, paramType = "body", dataType = "MappingStepSchema")
@Secured("ROLE_writeMapping")
public ResponseEntity<Void> updateMappingStep(@RequestBody @ApiParam(hidden = true) ObjectNode propertiesToAssign, @PathVariable String stepName) {
propertiesToAssign.put("name", stepName);
Expand Down Expand Up @@ -102,7 +102,7 @@ private StepService newService() {
return StepService.on(getHubClient().getStagingClient());
}

public static class MappingSteps extends ArrayList<StepSchema> {
public static class MappingSteps extends ArrayList<MappingStepSchema> {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

package com.marklogic.hub.central.schemas;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;


/**
* MappingProperties
* <p>
*
*
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({

})
public class MappingPropertiesSchema {


@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(MappingPropertiesSchema.class.getName()).append('@').append(Integer.toHexString(System.identityHashCode(this))).append('[');
if (sb.charAt((sb.length()- 1)) == ',') {
sb.setCharAt((sb.length()- 1), ']');
} else {
sb.append(']');
}
return sb.toString();
}

@Override
public int hashCode() {
int result = 1;
return result;
}

@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}
if ((other instanceof MappingPropertiesSchema) == false) {
return false;
}
MappingPropertiesSchema rhs = ((MappingPropertiesSchema) other);
return true;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@

package com.marklogic.hub.central.schemas;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;


/**
* MappingStep
* <p>
*
*
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"properties",
"relatedEntityMappings"
})
public class MappingStepSchema {

/**
* MappingProperties
* <p>
*
*
*/
@JsonProperty("properties")
private MappingPropertiesSchema properties;
/**
* additional collections provided by the user that get applied to the step output
*
*/
@JsonProperty("relatedEntityMappings")
@JsonPropertyDescription("additional collections provided by the user that get applied to the step output")
private List<RelatedEntityMapping> relatedEntityMappings = new ArrayList<RelatedEntityMapping>();
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();

/**
* MappingProperties
* <p>
*
*
*/
@JsonProperty("properties")
public MappingPropertiesSchema getProperties() {
return properties;
}

/**
* MappingProperties
* <p>
*
*
*/
@JsonProperty("properties")
public void setProperties(MappingPropertiesSchema properties) {
this.properties = properties;
}

/**
* additional collections provided by the user that get applied to the step output
*
*/
@JsonProperty("relatedEntityMappings")
public List<RelatedEntityMapping> getRelatedEntityMappings() {
return relatedEntityMappings;
}

/**
* additional collections provided by the user that get applied to the step output
*
*/
@JsonProperty("relatedEntityMappings")
public void setRelatedEntityMappings(List<RelatedEntityMapping> relatedEntityMappings) {
this.relatedEntityMappings = relatedEntityMappings;
}

@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}

@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(MappingStepSchema.class.getName()).append('@').append(Integer.toHexString(System.identityHashCode(this))).append('[');
sb.append("properties");
sb.append('=');
sb.append(((this.properties == null)?"<null>":this.properties));
sb.append(',');
sb.append("relatedEntityMappings");
sb.append('=');
sb.append(((this.relatedEntityMappings == null)?"<null>":this.relatedEntityMappings));
sb.append(',');
sb.append("additionalProperties");
sb.append('=');
sb.append(((this.additionalProperties == null)?"<null>":this.additionalProperties));
sb.append(',');
if (sb.charAt((sb.length()- 1)) == ',') {
sb.setCharAt((sb.length()- 1), ']');
} else {
sb.append(']');
}
return sb.toString();
}

@Override
public int hashCode() {
int result = 1;
result = ((result* 31)+((this.relatedEntityMappings == null)? 0 :this.relatedEntityMappings.hashCode()));
result = ((result* 31)+((this.additionalProperties == null)? 0 :this.additionalProperties.hashCode()));
result = ((result* 31)+((this.properties == null)? 0 :this.properties.hashCode()));
return result;
}

@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}
if ((other instanceof MappingStepSchema) == false) {
return false;
}
MappingStepSchema rhs = ((MappingStepSchema) other);
return ((((this.relatedEntityMappings == rhs.relatedEntityMappings)||((this.relatedEntityMappings!= null)&&this.relatedEntityMappings.equals(rhs.relatedEntityMappings)))&&((this.additionalProperties == rhs.additionalProperties)||((this.additionalProperties!= null)&&this.additionalProperties.equals(rhs.additionalProperties))))&&((this.properties == rhs.properties)||((this.properties!= null)&&this.properties.equals(rhs.properties))));
}

}
Loading