Skip to content

Commit

Permalink
Add validation log
Browse files Browse the repository at this point in the history
  • Loading branch information
afrold committed Apr 18, 2018
1 parent b333f69 commit 49fcddc
Show file tree
Hide file tree
Showing 9 changed files with 395 additions and 209 deletions.
Expand Up @@ -96,9 +96,10 @@ public void validateMessage(
try {
logger.info("Validating a message");
TestContext testContext = getTestContext(testContextId);
Long userId = SessionContext.getCurrentUserId(request.getSession(false));
command.setUserId(userId);
MessageValidationResult result = getMessageValidator().validate(testContext, command);
TestStepValidationReport report = saveReport(testContext, result,
SessionContext.getCurrentUserId(request.getSession(false)));
TestStepValidationReport report = saveReport(testContext, result, userId);
result.setHtml(null);
result.setXml(null);
result.setReportId(report.getId());
Expand Down
Expand Up @@ -12,33 +12,35 @@

package gov.nist.hit.core.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
* @author Harold Affo(NIST)
*
*/
@ApiModel(value="MessageValidationCommand", description="Data Model representing a request to validate a message")
@ApiModel(value = "MessageValidationCommand",
description = "Data Model representing a request to validate a message")
public class MessageValidationCommand extends TestCaseCommand {

@ApiModelProperty(required=true, value="content to parse")
@ApiModelProperty(required = true, value = "content to parse")
private String content;

private Map<String, String> nav;;
private Long userId;

private Map<String, String> nav;;

private String facilityId;

private String contextType;

private String facilityId;

private String contextType;

private String name;

@ApiModelProperty(required=false, value="data quality codes to validate")
private ArrayList<String> dqaCodes;
private String name;

@ApiModelProperty(required = false, value = "data quality codes to validate")
private ArrayList<String> dqaCodes;

public String getContent() {
return content;
Expand All @@ -48,7 +50,7 @@ public void setContent(String content) {
this.content = content;
}


public String getFacilityId() {
return facilityId;
}
Expand All @@ -73,7 +75,7 @@ public void setDqaCodes(ArrayList<String> dqaCodes) {
this.dqaCodes = dqaCodes;
}


public Map<String, String> getNav() {
return nav;
}
Expand All @@ -90,7 +92,14 @@ public void setName(String name) {
this.name = name;
}




public Long getUserId() {
return userId;
}

public void setUserId(Long userId) {
this.userId = userId;
}



}
Expand Up @@ -17,6 +17,7 @@
*
*/
public class TestCaseCommand {

protected Long testCaseId;

public Long getTestCaseId() {
Expand Down
@@ -0,0 +1,168 @@
package gov.nist.hit.core.domain.log;


import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.MapKeyColumn;
import javax.validation.constraints.NotNull;

/**
* This software was developed at the National Institute of Standards and Technology by employees of
* the Federal Government in the course of their official duties. Pursuant to title 17 Section 105
* of the United States Code this software is not subject to copyright protection and is in the
* public domain. This is an experimental system. NIST assumes no responsibility whatsoever for its
* use by other parties, and makes no guarantees, expressed or implied, about its quality,
* reliability, or any other characteristic. We would appreciate acknowledgement if the software is
* used. This software can be redistributed and/or modified freely provided that any derivative
* works bear some notice that they are derived from it, and any modified versions bear some notice
* that they have been modified.
*
* Created by mcl1 on 10/21/16.
*
* The ValidationLogReport is a minimalist version of the EnhancedReport that contains only the
* information we need to display the validation logs.
*
*/
@Entity
public class ValidationLog {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
protected Long id;


@NotNull
@Column(nullable = false)
private Long userId;

@NotNull
@Column(nullable = false)
private Long testStepId;
private String messageId;
private String format;
private String testingStage;
private int errorCount = 0;
private int warningCount = 0;

@NotNull
@Column(nullable = false)
private Date date;

@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "ErrorCountInSegment",
joinColumns = @JoinColumn(name = "validation_log_id"))
@MapKeyColumn(name = "segment_name")
@Column(name = "number_errors")
private Map<String, Integer> errorCountInSegment = new HashMap<String, Integer>();

private boolean validationResult = true;


public ValidationLog() {

}

public String getMessageId() {
return messageId;
}

public void setMessageId(String messageId) {
this.messageId = messageId;
}

public String getFormat() {
return format;
}

public void setFormat(String format) {
this.format = format;
}

public int getErrorCount() {
return errorCount;
}

public void setErrorCount(int errorCount) {
this.errorCount = errorCount;
}

public int getWarningCount() {
return warningCount;
}

public void setWarningCount(int warningCount) {
this.warningCount = warningCount;
}

public String getDate(String format) {
// Format the date as specified
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
if (this.date == null) {
this.date = new Date();
}
return simpleDateFormat.format(this.date);
}

public void setDate(Date date) {
this.date = date;
}

public Map<String, Integer> getErrorCountInSegment() {
return errorCountInSegment;
}

public void setErrorCountInSegment(Map<String, Integer> errorCountInSegment) {
this.errorCountInSegment = errorCountInSegment;
}

public boolean isValidationResult() {
return validationResult;
}

public void setValidationResult(boolean validationResult) {
this.validationResult = validationResult;
}

public String getTestingStage() {
return testingStage;
}

public void setTestingStage(String testingStage) {
this.testingStage = testingStage;
}

public Long getTestStepId() {
return testStepId;
}

public void setTestStepId(Long testStepId) {
this.testStepId = testStepId;
}

public Long getUserId() {
return userId;
}

public void setUserId(Long userId) {
this.userId = userId;
}

public Date getDate() {
return date;
}



}
@@ -0,0 +1,38 @@
/**
* This software was developed at the National Institute of Standards and Technology by employees of
* the Federal Government in the course of their official duties. Pursuant to title 17 Section 105
* of the United States Code this software is not subject to copyright protection and is in the
* public domain. This is an experimental system. NIST assumes no responsibility whatsoever for its
* use by other parties, and makes no guarantees, expressed or implied, about its quality,
* reliability, or any other characteristic. We would appreciate acknowledgement if the software is
* used. This software can be redistributed and/or modified freely provided that any derivative
* works bear some notice that they are derived from it, and any modified versions bear some notice
* that they have been modified.
*/

package gov.nist.hit.core.repo;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import gov.nist.hit.core.domain.TestArtifact;
import gov.nist.hit.core.domain.log.ValidationLog;

public interface ValidationLogRepository extends JpaRepository<ValidationLog, Long> {


@Query("select testStep.testStory from TestStep testStep where testStep.id = :id")
public TestArtifact testStory(@Param("id") Long id);


@Query("select log from ValidationLog log where log.userId = :userId")
public List<ValidationLog> findByUserId(@Param("userId") Long userId);

@Query("select log from ValidationLog log where log.testStepId = :testStepId")
public List<ValidationLog> findByTestStepId(@Param("testStepId") Long testStepId);


}
@@ -0,0 +1,22 @@
package gov.nist.hit.core.service;

import java.util.List;

import gov.nist.healthcare.unified.model.EnhancedReport;
import gov.nist.hit.core.domain.TestContext;
import gov.nist.hit.core.domain.log.ValidationLog;

public interface ValidationLogService {

public ValidationLog findOne(Long id);

public ValidationLog save(ValidationLog log);

public List<ValidationLog> findByUserId(Long userId);

public List<ValidationLog> findByTestStepId(Long testStepId);

public ValidationLog generateAndSave(Long userId, TestContext testContext, EnhancedReport report);


}

0 comments on commit 49fcddc

Please sign in to comment.