Mercurial > hg > LGDataverses
comparison src/main/java/edu/harvard/iq/dataverse/ForeignMetadataFieldMapping.java @ 10:a50cf11e5178
Rewrite LGDataverse completely upgrading to dataverse4.0
| author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
|---|---|
| date | Tue, 08 Sep 2015 17:00:21 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 9:5926d6419569 | 10:a50cf11e5178 |
|---|---|
| 1 | |
| 2 | |
| 3 package edu.harvard.iq.dataverse; | |
| 4 | |
| 5 import java.io.Serializable; | |
| 6 import javax.persistence.*; | |
| 7 import java.util.Collection; | |
| 8 import java.util.LinkedList; | |
| 9 import java.util.List; | |
| 10 import java.util.Map; | |
| 11 import java.util.Set; | |
| 12 import java.util.TreeMap; | |
| 13 | |
| 14 /** | |
| 15 * | |
| 16 * @author Leonid Andreev | |
| 17 */ | |
| 18 @Table( | |
| 19 uniqueConstraints = @UniqueConstraint(columnNames={"foreignMetadataFormatMapping_id","foreignFieldXpath"}) ) | |
| 20 @NamedQueries({ | |
| 21 @NamedQuery( name="ForeignMetadataFieldMapping.findByPath", | |
| 22 query="SELECT fmfm FROM ForeignMetadataFieldMapping fmfm WHERE fmfm.foreignMetadataFormatMapping.name=:formatName AND fmfm.foreignFieldXPath=:xPath") | |
| 23 }) | |
| 24 @Entity | |
| 25 public class ForeignMetadataFieldMapping implements Serializable { | |
| 26 private static final long serialVersionUID = 1L; | |
| 27 @Id | |
| 28 @GeneratedValue(strategy = GenerationType.IDENTITY) | |
| 29 private Long id; | |
| 30 | |
| 31 public Long getId() { | |
| 32 return id; | |
| 33 } | |
| 34 | |
| 35 public void setId(Long id) { | |
| 36 this.id = id; | |
| 37 } | |
| 38 | |
| 39 @ManyToOne(cascade = CascadeType.MERGE) | |
| 40 private ForeignMetadataFormatMapping foreignMetadataFormatMapping; | |
| 41 | |
| 42 @Column(name = "foreignFieldXPath", columnDefinition = "TEXT") | |
| 43 private String foreignFieldXPath; | |
| 44 | |
| 45 @Column(name = "datasetfieldName", columnDefinition = "TEXT") | |
| 46 private String datasetfieldName; | |
| 47 | |
| 48 @OneToMany(mappedBy = "parentFieldMapping", cascade = {CascadeType.REMOVE, CascadeType.MERGE, CascadeType.PERSIST}) | |
| 49 private Collection<ForeignMetadataFieldMapping> childFieldMappings; | |
| 50 | |
| 51 @ManyToOne(cascade = CascadeType.MERGE) | |
| 52 private ForeignMetadataFieldMapping parentFieldMapping; | |
| 53 | |
| 54 private boolean isAttribute; | |
| 55 | |
| 56 /* getters/setters: */ | |
| 57 | |
| 58 public ForeignMetadataFormatMapping getForeignMetadataFormatMapping() { | |
| 59 return foreignMetadataFormatMapping; | |
| 60 } | |
| 61 | |
| 62 public void setForeignMetadataFormatMapping(ForeignMetadataFormatMapping foreignMetadataFormatMapping) { | |
| 63 this.foreignMetadataFormatMapping = foreignMetadataFormatMapping; | |
| 64 } | |
| 65 | |
| 66 public String getForeignFieldXPath() { | |
| 67 return foreignFieldXPath; | |
| 68 } | |
| 69 | |
| 70 public void setForeignFieldXPath(String foreignFieldXPath) { | |
| 71 this.foreignFieldXPath = foreignFieldXPath; | |
| 72 } | |
| 73 | |
| 74 public String getDatasetfieldName() { | |
| 75 return datasetfieldName; | |
| 76 } | |
| 77 | |
| 78 public void setDatasetfieldName(String datasetfieldName) { | |
| 79 this.datasetfieldName = datasetfieldName; | |
| 80 } | |
| 81 | |
| 82 | |
| 83 public Collection<ForeignMetadataFieldMapping> getChildFieldMappings() { | |
| 84 return this.childFieldMappings; | |
| 85 } | |
| 86 | |
| 87 public void setChildFieldMappings(Collection<ForeignMetadataFieldMapping> childFieldMappings) { | |
| 88 this.childFieldMappings = childFieldMappings; | |
| 89 } | |
| 90 | |
| 91 /* | |
| 92 public Collection<ForeignMetadataFieldMapping> getAttributeMappings() { | |
| 93 return this.attributeMappings; | |
| 94 } | |
| 95 | |
| 96 public void setAttributeMappings(Collection<ForeignMetadataFieldMapping> attributeMappings) { | |
| 97 this.attributeMappings = attributeMappings; | |
| 98 } | |
| 99 */ | |
| 100 | |
| 101 | |
| 102 public ForeignMetadataFieldMapping getParentFieldMapping() { | |
| 103 return parentFieldMapping; | |
| 104 } | |
| 105 | |
| 106 public void setParentFieldMapping(ForeignMetadataFieldMapping parentFieldMapping) { | |
| 107 this.parentFieldMapping = parentFieldMapping; | |
| 108 } | |
| 109 | |
| 110 public boolean isAttribute() { | |
| 111 return isAttribute; | |
| 112 } | |
| 113 | |
| 114 public void setIsAttribute(boolean isAttribute) { | |
| 115 this.isAttribute = isAttribute; | |
| 116 } | |
| 117 | |
| 118 /* logical: */ | |
| 119 | |
| 120 public boolean isChild() { | |
| 121 return this.parentFieldMapping != null; | |
| 122 } | |
| 123 | |
| 124 public boolean HasChildren() { | |
| 125 return !this.childFieldMappings.isEmpty(); | |
| 126 } | |
| 127 | |
| 128 /* | |
| 129 public boolean HasAttributes() { | |
| 130 return !this.attributeMappings.isEmpty(); | |
| 131 } | |
| 132 */ | |
| 133 | |
| 134 public boolean HasParent() { | |
| 135 return this.parentFieldMapping != null; | |
| 136 } | |
| 137 /* overrides: */ | |
| 138 | |
| 139 @Override | |
| 140 public int hashCode() { | |
| 141 int hash = 0; | |
| 142 hash += (id != null ? id.hashCode() : 0); | |
| 143 return hash; | |
| 144 } | |
| 145 | |
| 146 @Override | |
| 147 public boolean equals(Object object) { | |
| 148 if (!(object instanceof ForeignMetadataFieldMapping)) { | |
| 149 return false; | |
| 150 } | |
| 151 ForeignMetadataFieldMapping other = (ForeignMetadataFieldMapping) object; | |
| 152 return !((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))); | |
| 153 } | |
| 154 | |
| 155 @Override | |
| 156 public String toString() { | |
| 157 return "edu.harvard.iq.dataverse.ForeignMetadataFieldMapping[ id=" + id + " ]"; | |
| 158 } | |
| 159 | |
| 160 } |
