Skip to content

Commit

Permalink
fix broken javadoc and add missing license header
Browse files Browse the repository at this point in the history
  • Loading branch information
arendd committed Mar 24, 2020
1 parent 2097676 commit 60f686a
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 57 deletions.
126 changes: 69 additions & 57 deletions src/main/java/de/ipk_gatersleben/bit/bi/isa4j/components/Process.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,35 @@
import de.ipk_gatersleben.bit.bi.isa4j.exceptions.RedundantItemException;

public class Process extends StudyOrAssayTableObject implements Commentable {

private CommentCollection comments = new CommentCollection();

private LocalDate date;

private LocalDateTime dateTime;

private StudyOrAssayTableObject input;

private List<ParameterValue> parameterValues = new ArrayList<ParameterValue>();

private Protocol protocol;

public Process(Protocol protocol) {
this.setProtocol(protocol);
}

public void addParameterValue(ParameterValue parameterValue) {
if(this.parameterValues.stream().map(ParameterValue::getCategory).anyMatch(parameterValue.getCategory()::equals))
throw new RedundantItemException("Multiple ParameterValues for Parameter: " + parameterValue.getCategory().getName());
if (this.parameterValues.stream().map(ParameterValue::getCategory)
.anyMatch(parameterValue.getCategory()::equals))
throw new RedundantItemException(
"Multiple ParameterValues for Parameter: " + parameterValue.getCategory().getName());
this.parameterValues.add(parameterValue);
}

public CommentCollection comments() {
return this.comments;
}

/**
* @return the date
*/
Expand All @@ -60,40 +62,43 @@ public LocalDate getDate() {
public LocalDateTime getDateTime() {
return dateTime;
}

Map<String, String[]> getFields() {
HashMap<String, String[]> fields = new HashMap<String, String[]>();

fields.put(StudyAssayAttribute.PROTOCOL.toString(), new String[]{this.protocol.getName()});
fields.putAll(this.getFieldsForValues(StudyAssayAttribute.PARAMETER_VALUE, this.parameterValues, pv -> pv.getCategory().getName().getTerm()));
if(this.dateTime != null)
fields.put(StudyAssayAttribute.PROTOCOL_DATE.toString(), new String[]{this.dateTime.toString()});
else if(this.date != null)
fields.put(StudyAssayAttribute.PROTOCOL_DATE.toString(), new String[]{this.date.toString()});

fields.put(StudyAssayAttribute.PROTOCOL.toString(), new String[] { this.protocol.getName() });
fields.putAll(this.getFieldsForValues(StudyAssayAttribute.PARAMETER_VALUE, this.parameterValues,
pv -> pv.getCategory().getName().getTerm()));
if (this.dateTime != null)
fields.put(StudyAssayAttribute.PROTOCOL_DATE.toString(), new String[] { this.dateTime.toString() });
else if (this.date != null)
fields.put(StudyAssayAttribute.PROTOCOL_DATE.toString(), new String[] { this.date.toString() });
fields.putAll(this.getFieldsForComments(this.comments));

return fields;
}

LinkedHashMap<String, String[]> getHeaders() {
LinkedHashMap<String, String[]> headers = new LinkedHashMap<String, String[]>();

headers.put(StudyAssayAttribute.PROTOCOL.toString(), new String[]{StudyAssayAttribute.PROTOCOL.toString()});
headers.putAll(this.getHeadersForValues(StudyAssayAttribute.PARAMETER_VALUE, this.parameterValues, pv -> pv.getCategory().getName().getTerm()));
if(this.dateTime != null || this.date != null)
headers.put(StudyAssayAttribute.PROTOCOL_DATE.toString(), new String[]{StudyAssayAttribute.PROTOCOL_DATE.toString()});

headers.put(StudyAssayAttribute.PROTOCOL.toString(), new String[] { StudyAssayAttribute.PROTOCOL.toString() });
headers.putAll(this.getHeadersForValues(StudyAssayAttribute.PARAMETER_VALUE, this.parameterValues,
pv -> pv.getCategory().getName().getTerm()));
if (this.dateTime != null || this.date != null)
headers.put(StudyAssayAttribute.PROTOCOL_DATE.toString(),
new String[] { StudyAssayAttribute.PROTOCOL_DATE.toString() });
headers.putAll(this.getHeadersForComments(this.comments));

return headers;
}

public StudyOrAssayTableObject getInput() {
return this.input;
}
return this.input;
}

public StudyOrAssayTableObject getOutput() {
return this.getNextStudyOrAssayTableObject();
}
return this.getNextStudyOrAssayTableObject();
}

/**
* @return the factorValues
Expand All @@ -110,60 +115,67 @@ public Protocol getProtocol() {
}

/**
* Sets a Date for this Process (without time of day). Overwrites any Date or DateTime set before.
* Sets a Date for this Process (without time of day). Overwrites any Date or
* DateTime set before.
*
* @param date the date to set
*/
public void setDate(LocalDate date) {
this.date = date;
this.dateTime = null;
}

/**
* Sets a DateTime for this Process. Overwrites any Date or DateTime set before.
*
* @param dateTime the dateTime to set
*/
public void setDateTime(LocalDateTime dateTime) {
this.dateTime = dateTime;
this.date = null;
}


/**
* Declares the input to this Process. This information is used to link
* different entities together in the output Study and Assay Files through
* Processes, e.g. Source-&gt;Process-&gt;Sample.
*
* @param input to set
*/
public void setInput(StudyOrAssayTableObject input) {
// Remove myself from previously defined input
if (this.input != null)
this.input.setNextStudyOrAssayTableObject(null);
input.setNextStudyOrAssayTableObject(this);
this.input = input;
}

/**
* Declares the input to this Process. This information is used to link different entities
* together in the output Study and Assay Files through Processes, e.g. Source->Process->Sample.
* @param input
* Declares the output of this Process. This information is used to link
* different entities together in the output Study and Assay Files through
* Processes, e.g. Source-&gt;Process-&gt;Sample.
*
* @param output to set
*/
public void setInput(StudyOrAssayTableObject input) {
// Remove myself from previously defined input
if(this.input != null)
this.input.setNextStudyOrAssayTableObject(null);
input.setNextStudyOrAssayTableObject(this);
this.input = input;
}

/**
* Declares the output of this Process. This information is used to link different entities
* together in the output Study and Assay Files through Processes, e.g. Source->Process->Sample.
* @param output
*/
public void setOutput(StudyOrAssayTableObject output) {
this.setNextStudyOrAssayTableObject(output);
}

/**
public void setOutput(StudyOrAssayTableObject output) {
this.setNextStudyOrAssayTableObject(output);
}

/**
* @param parameterValues the factorValues to set
*/
public void setParameterValues(List<ParameterValue> parameterValues) {
parameterValues.stream().forEach(Objects::requireNonNull);
this.parameterValues = parameterValues;
}
/**

/**
* @param protocol the protocol to set
*/
public void setProtocol(Protocol protocol) {
this.protocol = Objects.requireNonNull(protocol, "Protocol cannot be null");
}

@Override
public String toString() {
return "<Process> '" + this.protocol.getName() + "' on input " + this.input.toString();
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/isa4J/SimpleWorkingExample.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Copyright (c) 2020 Leibniz Institute of Plant Genetics and Crop Plant Research (IPK), Gatersleben, Germany.
* All rights reserved. This program and the accompanying materials are made available under the terms of the GNU GPLv3 license (https://www.gnu.org/licenses/gpl-3.0.en.html)
*
* Contributors:
* Leibniz Institute of Plant Genetics and Crop Plant Research (IPK), Gatersleben, Germany
*/
package isa4J;

import java.io.IOException;
Expand Down

0 comments on commit 60f686a

Please sign in to comment.