Commit f673366f authored by Matija Obreza's avatar Matija Obreza
Browse files

Method#parameter not required

parent 8cf2df78
......@@ -18,70 +18,52 @@ package org.genesys2.server.model.genesys;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.genesys2.server.model.BusinessModel;
@Entity
@Table(name = "methods")
public class Method implements java.io.Serializable {
public class Method extends BusinessModel {
/**
*
*/
private static final long serialVersionUID = -1084675112110837714L;
private Long id;
// private Language language;
private Parameter parameter;
// private Language language;
@Column(nullable = false)
@Lob
private String method;
@Column(length = 32)
private String unit;
private String options;
private String fieldName;
private int fieldType;
private String fieldSize;
private String range;
public Method() {
}
@Lob
private String options;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="Method_Id")
public Long getId() {
return this.id;
}
@Column(nullable = false, length = 32)
private String fieldName;
public void setId(final Long methodId) {
this.id = methodId;
}
@Column(nullable = false)
private int fieldType;
// @ManyToOne(cascade = {}, optional = false)
// @JoinColumn(name = "languageId", nullable = false)
// public Language getLanguage() {
// return this.language;
// }
//
// public void setLanguage(final Language language) {
// this.language = language;
// }
@Column(nullable = false, length = 10)
private String fieldSize;
@ManyToOne(cascade = {}, optional = false)
@JoinColumn(name = "Par_Id", nullable = false)
public Parameter getParameter() {
return this.parameter;
}
@Column(name = "\"range\"", length = 32)
private String range;
@ManyToOne(cascade = {}, optional = true)
@JoinColumn(name = "parameterId", nullable = true)
private Parameter parameter;
public void setParameter(final Parameter parameter) {
this.parameter = parameter;
}
@Column(nullable = false)
@Lob
public String getMethod() {
return this.method;
}
......@@ -90,7 +72,6 @@ public class Method implements java.io.Serializable {
this.method = method;
}
@Column(length = 32)
public String getUnit() {
return this.unit;
}
......@@ -99,7 +80,6 @@ public class Method implements java.io.Serializable {
this.unit = unit;
}
@Lob
public String getOptions() {
return this.options;
}
......@@ -108,7 +88,6 @@ public class Method implements java.io.Serializable {
this.options = options;
}
@Column(nullable = false, length = 32)
public String getFieldName() {
return this.fieldName;
}
......@@ -117,7 +96,6 @@ public class Method implements java.io.Serializable {
this.fieldName = fieldName;
}
@Column(nullable = false)
public int getFieldType() {
return this.fieldType;
}
......@@ -126,7 +104,6 @@ public class Method implements java.io.Serializable {
this.fieldType = fieldType;
}
@Column(nullable = false, length = 10)
public String getFieldSize() {
return this.fieldSize;
}
......@@ -148,8 +125,7 @@ public class Method implements java.io.Serializable {
// Long
return Long.class;
default:
throw new RuntimeException("Unknown data type " + fieldType
+ " for " + this);
throw new RuntimeException("Unknown data type " + fieldType + " for " + this);
}
}
......@@ -157,43 +133,42 @@ public class Method implements java.io.Serializable {
public boolean isCoded() {
return this.fieldType == 0;
}
// FIXME String?
public Object decode(Object value) {
return isCoded() && value!=null ? TraitCode.decode(this.options, value.toString()) : value;
return isCoded() && value != null ? TraitCode.decode(this.options, value.toString()) : value;
}
/**
* Get list of codes for a coded descriptor.
*
*
* @return <code>null</code> if not coded, list of {@link TraitCode} for
* coded traits
*/
// @Transient
// public List<TraitCode> getCodes() {
// if (!isCoded()) {
// return null;
// }
//
// return TraitCode.parseOptions(this.options);
// }
// @Transient
// public List<TraitCode> getCodes() {
// if (!isCoded()) {
// return null;
// }
//
// return TraitCode.parseOptions(this.options);
// }
/**
* Get map of codes for a coded descriptor.
*
*
* @return <code>null</code> if not coded, list of {@link TraitCode} for
* coded traits
*/
// @Transient
// public Map<String, TraitCode> getCodeMap() {
// if (!isCoded()) {
// return null;
// }
//
// return TraitCode.parseOptionsMap(this.options);
// }
@Column(name = "\"Range\"", length = 32)
// @Transient
// public Map<String, TraitCode> getCodeMap() {
// if (!isCoded()) {
// return null;
// }
//
// return TraitCode.parseOptionsMap(this.options);
// }
public String getRange() {
return this.range;
}
......@@ -202,12 +177,22 @@ public class Method implements java.io.Serializable {
this.range = range;
}
// @Override
// public String toString() {
// return MessageFormat.format(
// "Method id={0,number,#} lang={1} param={2} fieldName={3}[{4}]",
// id, language.getId(), parameter.getTitle(), fieldName,
// fieldSize);
// }
// @Override
// public String toString() {
// return MessageFormat.format(
// "Method id={0,number,#} lang={1} param={2} fieldName={3}[{4}]",
// id, language.getId(), parameter.getTitle(), fieldName,
// fieldSize);
// }
public Method() {
}
public Parameter getParameter() {
return this.parameter;
}
public void setParameter(final Parameter parameter) {
this.parameter = parameter;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment