Commit 3c94863e authored by Matija Obreza's avatar Matija Obreza
Browse files

Data model

parent 5d075725
/**
* Copyright 2013 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package org.crophub.rest.common.model.impl;
import java.util.ArrayList;
import java.util.List;
public class ColumnGroups {
List<Integer> columns = null;
List<ColumnGroups> subs = null;
public List<Integer> getColumns() {
return columns;
}
public void setColumns(final List<Integer> columns) {
this.columns = columns;
}
public List<ColumnGroups> getSubs() {
return subs;
}
public void setSubs(final List<ColumnGroups> subs) {
this.subs = subs;
}
public synchronized void addColumn(final int column) {
if (columns == null) {
columns = new ArrayList<Integer>();
}
columns.add(column);
}
public synchronized void addSub(final ColumnGroups subGroup) {
if (subs == null) {
subs = new ArrayList<ColumnGroups>();
}
subs.add(subGroup);
}
}
/**
* Copyright 2013 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package org.crophub.rest.common.model.impl;
import java.util.Map;
public class DataMapping {
ColumnGroups grouping;
Map<Integer, Long> descriptorMap;
public ColumnGroups getGrouping() {
return grouping;
}
public void setGrouping(final ColumnGroups grouping) {
this.grouping = grouping;
}
public Map<Integer, Long> getDescriptorMap() {
return descriptorMap;
}
public void setDescriptorMap(final Map<Integer, Long> descriptorMap) {
this.descriptorMap = descriptorMap;
}
}
/**
* Copyright 2013 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package org.crophub.rest.common.model.impl;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "dataset")
public class DataSet implements Serializable {
private static final long serialVersionUID = 4562288873039057125L;
private Long id;
private License license;
private String name;
private String source;
private String headers;
private String mapping;
private Date uploadDate;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(final Long id) {
this.id = id;
}
@ManyToOne(cascade = {}, optional = true)
public License getLicense() {
return license;
}
public void setLicense(final License license) {
this.license = license;
}
@Column(nullable = false, length = 500)
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
public Date getUploadDate() {
return uploadDate;
}
public void setUploadDate(final Date uploadDate) {
this.uploadDate = uploadDate;
}
@Column(length = 500)
public String getSource() {
return source;
}
public void setSource(final String source) {
this.source = source;
}
/**
* Gets list of headers in source file
*
* @return
*/
@Lob
public String getHeaders() {
return headers;
}
public void setHeaders(final String headers) {
this.headers = headers;
}
/**
* Data mapping info
*
* @return
*/
@Lob
public String getMapping() {
return mapping;
}
public void setMapping(final String mapping) {
this.mapping = mapping;
}
@Override
public String toString() {
return MessageFormat.format(
"DataSet id={0,number,#} date={1,date,dd/MM/yyyy} name={2}",
id, uploadDate, name);
}
}
/**
* Copyright 2013 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package org.crophub.rest.common.model.impl;
import java.io.Serializable;
import java.text.MessageFormat;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
/**
* A Descriptor represents a dimension of a sparse vector.
*
* @author mobreza
*/
@Entity
@Table(name="descriptor")
public class Descriptor implements Serializable {
private static final long serialVersionUID = 3832200593904442940L;
private Long id;
private String name;
private String description;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(final Long id) {
this.id = id;
}
@Column(nullable = false, length = 500)
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
@Lob
public String getDescription() {
return description;
}
public void setDescription(final String description) {
this.description = description;
}
@Override
public String toString() {
return MessageFormat.format("Descriptor id={0,number,#} name={1}", id, name);
}
}
package org.crophub.rest.common.model.impl;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
/**
* A {@link License} entity represents one of the possible licenses in use by an
* {@link FaoInstitute}.
*
* @author mobreza
*/
@Entity
@Table(name = "license")
public class License implements Serializable {
private static final long serialVersionUID = -1240680237067019307L;
@Id
@GeneratedValue
private Long id;
@Column(length = 200, nullable = false)
private String name;
@Lob
@Column(nullable = false)
private String text;
private float openess;
public Long getId() {
return id;
}
public void setId(final Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
public String getText() {
return text;
}
public void setText(final String text) {
this.text = text;
}
public float getOpeness() {
return openess;
}
public void setOpeness(final float openess) {
this.openess = openess;
}
}
/**
* Copyright 2013 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package org.crophub.rest.common.model.impl;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OrderColumn;
import javax.persistence.Table;
import org.hibernate.annotations.Index;
/**
* Single Data entry representing a single dimension. Complete vector is
* obtained by looking up all {@link SparseData} relating to the same
* {@link SparseEntry}.
*/
@Entity
@Table(name = "sparsedata")
@org.hibernate.annotations.Table(appliesTo = "sparsedata", indexes = {
@Index(columnNames = { "descriptorId", "stringId" }, name = "descriptorstring_SPARSEDATA"),
@Index(columnNames = { "sparseEntryId" }, name = "entry_SPARSEDATA"),
@Index(columnNames = { "descriptorId" }, name = "descriptor_SPARSEDATA") })
public class SparseData implements Serializable {
private static final long serialVersionUID = -2142036544458439223L;
private Long id;
private long sparseEntryId;
private long descriptorId;
private String value;
private SparseString sparseString;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(final Long id) {
this.id = id;
}
@OrderColumn
public long getSparseEntryId() {
return sparseEntryId;
}
public void setSparseEntryId(final long sparseEntryId) {
this.sparseEntryId = sparseEntryId;
}
@OrderColumn
public long getDescriptorId() {
return descriptorId;
}
public void setDescriptorId(final long descriptorId) {
this.descriptorId = descriptorId;
}
@Column(nullable = false, length = 500)
public String getValue() {
return value;
}
public void setValue(final String value) {
this.value = value;
}
@ManyToOne(cascade = {}, optional = true)
@JoinColumn(name = "stringId")
public SparseString getSparseString() {
return sparseString;
}
public void setSparseString(final SparseString sparseString) {
this.sparseString = sparseString;
}
}
/**
* Copyright 2013 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package org.crophub.rest.common.model.impl;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
/**
* Represents a sparse data vector, part of a {@link DataSet} in the system.
*
* @author mobreza
*/
@Entity
@Table(name = "sparseentry")
public class SparseEntry implements Serializable {
private static final long serialVersionUID = 2430418022616359050L;
private Long id;
private DataSet dataSet;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(final Long id) {
this.id = id;
}
@ManyToOne(cascade = {}, optional = false)
@JoinColumn(name = "dataSetId", nullable = false)
public DataSet getDataSet() {
return dataSet;
}
public void setDataSet(final DataSet dataSet) {
this.dataSet = dataSet;
}
}
/**
* Copyright 2013 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package org.crophub.rest.common.model.impl;
import java.io.Serializable;
import java.text.MessageFormat;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* Strings used in sparse tables
*
* @author mobreza
*/
@Entity
@Table(name = "sparsestring")
public class SparseString implements Serializable {
private static final long serialVersionUID = 5896186555138979311L;
private Long id;
private String value;
public SparseString() {
}
public SparseString(final String value) {
this.value = value;
}
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(final Long id) {
this.id = id;
}
public int getHash() {
return this.value.hashCode();
}
public void setHash(final int hash) {
}
public int getLength() {
return this.value.length();
}
public void setLength(final int length) {
}