Skip to content

Commit

Permalink
Merge pull request #6 from lubitchv/5513-database-variablemetadata
Browse files Browse the repository at this point in the history
5513 database variablemetadata
  • Loading branch information
lubitchv authored Feb 20, 2019
2 parents d0491b0 + 924d258 commit aad3a2b
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package edu.harvard.iq.dataverse.datavariable;

import javax.persistence.Index;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.GenerationType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.JoinColumn;

@Entity
@Table(indexes = {@Index(columnList="category_id"), @Index(columnList="variablemetadata_id")})
public class CategoryMetadata {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Long id;

@ManyToOne
@JoinColumn(nullable=false)
VariableCategory category;

@ManyToOne
@JoinColumn(nullable=false)
private VariableMetadata variableMetadata;

Double wfreq;

public CategoryMetadata() {}

public CategoryMetadata(VariableMetadata variableMetadata) {
this.variableMetadata = variableMetadata;
}

public Double getWfreq() {
return wfreq;
}

public void setWfreq(Double wfreq) {
this.wfreq = wfreq;
}

public VariableCategory getCategory() {
return category;
}

public void setCategory(VariableCategory category) {
this.category = category;
}

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public void setVariableMetadata(VariableMetadata variableMetadata) {
this.variableMetadata = variableMetadata;
}

public VariableMetadata getVariableMetadata() {
return variableMetadata;
}

@Override
public int hashCode() {
int hash = 0;
hash += (this.id != null ? this.id.hashCode() : 0);
return hash;
}

@Override
public boolean equals(Object object) {
if (!(object instanceof CategoryMetadata)) {
return false;
}

CategoryMetadata other = (CategoryMetadata) object;
if (this.id != other.id ) {
if (this.id == null || !this.id.equals(other.id)) {
return false;
}
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Column;
import javax.persistence.OneToMany;
import javax.persistence.CascadeType;

import java.util.Collection;
import java.util.Set;

import edu.harvard.iq.dataverse.FileMetadata;

Expand Down Expand Up @@ -79,9 +84,10 @@ public class VariableMetadata implements Serializable {
private boolean weighted = false;

/**
* wfreq: Weighted frequency for weigted variable
* categoriesMetadata: variable metadata for categories that includes weighted frequencies
*/
private Double wfreq;
@OneToMany (mappedBy="VariableMetadata", cascade={ CascadeType.REMOVE, CascadeType.MERGE,CascadeType.PERSIST})
private Collection<CategoryMetadata> categoriesMetadata;

/**
* dataVariable: DataVariable with which this variable is weighted.
Expand Down Expand Up @@ -180,12 +186,13 @@ public boolean isWeighted() {
return weighted;
}

public Double getWfreq() {
return wfreq;
public Collection<CategoryMetadata> getWfreq() {
return categoriesMetadata;
}

public void setWfreq(Double wfreq) {
this.wfreq = wfreq;
public void setWfreq(Set<CategoryMetadata> categoriesMetadata) {
this.categoriesMetadata = categoriesMetadata;

}

@Override
Expand Down

0 comments on commit aad3a2b

Please sign in to comment.