Project

General

Profile

« Previous | Next » 

Revision 46344

refactoring: let's reuse class MetadataReference

View differences:

modules/dnet-core-components/branches/saxonHE/src/main/java/eu/dnetlib/rmi/provision/MDFInfo.java
1 1
package eu.dnetlib.rmi.provision;
2 2

  
3
import eu.dnetlib.utils.MetadataReference;
4

  
3 5
public class MDFInfo {
4 6

  
5 7
	/**
......
13 15
	 * sourceFormat* are properties describing the metadata format to use as input to deliver records in the <prefix> format.
14 16
	 * sourceFormatName may be the same as prefix, for example in cases when we have a oai_dc store and we want to deliver oai_dc records.
15 17
	 */
16
	private String sourceFormatName;
17
	private String sourceFormatLayout;
18
	private String sourceFormatInterpretation;
18
	private MetadataReference sourceMetadataReference;
19 19

  
20 20
	/**
21 21
	 * query to filter out records to be delivered.
......
99 99
		this.prefix = prefix;
100 100
		this.schema = schema;
101 101
		this.namespace = namespace;
102
		this.sourceFormatName = sourceFormatName;
103
		this.sourceFormatLayout = sourceFormatLayout;
104
		this.sourceFormatInterpretation = sourceFormatInterpretation;
102
		this.sourceMetadataReference = new MetadataReference(sourceFormatName, sourceFormatLayout, sourceFormatInterpretation);
105 103
		this.baseQuery = baseQuery;
106 104
	}
107 105

  
108 106
	@Override
109 107
	public String toString() {
110
		return "MDFInfo [prefix=" + prefix + ", schema=" + schema + ", namespace=" + namespace + ", sourceFormatName=" + sourceFormatName
111
				+ ", sourceFormatLayout=" + sourceFormatLayout + ", sourceFormatInterpretation=" + sourceFormatInterpretation + ", baseQuery=" + baseQuery
112
				+ ", transformationRuleID=" + transformationRuleID + ", enabled=" + enabled + "]";
108
		return "MDFInfo{" +
109
				"prefix='" + prefix + '\'' +
110
				", schema='" + schema + '\'' +
111
				", namespace='" + namespace + '\'' +
112
				", sourceMetadataReference=" + sourceMetadataReference +
113
				", baseQuery='" + baseQuery + '\'' +
114
				", transformationRuleID='" + transformationRuleID + '\'' +
115
				", enabled=" + enabled +
116
				'}';
113 117
	}
114 118

  
115 119
	public String getPrefix() {
......
136 140
		this.namespace = namespace;
137 141
	}
138 142

  
139
	public String getSourceFormatName() {
140
		return sourceFormatName;
141
	}
142

  
143
	public void setSourceFormatName(final String sourceFormatName) {
144
		this.sourceFormatName = sourceFormatName;
145
	}
146

  
147
	public String getSourceFormatLayout() {
148
		return sourceFormatLayout;
149
	}
150

  
151
	public void setSourceFormatLayout(final String sourceFormatLayout) {
152
		this.sourceFormatLayout = sourceFormatLayout;
153
	}
154

  
155
	public String getSourceFormatInterpretation() {
156
		return sourceFormatInterpretation;
157
	}
158

  
159
	public void setSourceFormatInterpretation(final String sourceFormatInterpretation) {
160
		this.sourceFormatInterpretation = sourceFormatInterpretation;
161
	}
162

  
163 143
	public String getBaseQuery() {
164 144
		return baseQuery;
165 145
	}
......
184 164
		this.enabled = enabled;
185 165
	}
186 166

  
167
	public MetadataReference getSourceMetadataReference() {
168
		return sourceMetadataReference;
169
	}
170

  
171
	public void setSourceMetadataReference(final MetadataReference sourceMetadataReference) {
172
		this.sourceMetadataReference = sourceMetadataReference;
173
	}
174

  
175
	public String getSourceFormat(){
176
		return getSourceMetadataReference().getFormat();
177
	}
178

  
179
	public String getSourceLayout(){
180
		return getSourceMetadataReference().getLayout();
181
	}
182
	public String getSourceInterpretation(){
183
		return getSourceMetadataReference().getInterpretation();
184
	}
185

  
186

  
187 187
	@Override
188
	public int hashCode() {
189
		final int prime = 31;
190
		int result = 1;
191
		result = (prime * result) + ((baseQuery == null) ? 0 : baseQuery.hashCode());
192
		result = (prime * result) + (enabled ? 1231 : 1237);
193
		result = (prime * result) + ((namespace == null) ? 0 : namespace.hashCode());
194
		result = (prime * result) + ((prefix == null) ? 0 : prefix.hashCode());
195
		result = (prime * result) + ((schema == null) ? 0 : schema.hashCode());
196
		result = (prime * result) + ((sourceFormatInterpretation == null) ? 0 : sourceFormatInterpretation.hashCode());
197
		result = (prime * result) + ((sourceFormatLayout == null) ? 0 : sourceFormatLayout.hashCode());
198
		result = (prime * result) + ((sourceFormatName == null) ? 0 : sourceFormatName.hashCode());
199
		result = (prime * result) + ((transformationRuleID == null) ? 0 : transformationRuleID.hashCode());
200
		return result;
188
	public boolean equals(final Object o) {
189
		if (this == o) return true;
190
		if (o == null || getClass() != o.getClass()) return false;
191

  
192
		final MDFInfo mdfInfo = (MDFInfo) o;
193

  
194
		if (isEnabled() != mdfInfo.isEnabled()) return false;
195
		if (getPrefix() != null ? !getPrefix().equals(mdfInfo.getPrefix()) : mdfInfo.getPrefix() != null) return false;
196
		if (getSchema() != null ? !getSchema().equals(mdfInfo.getSchema()) : mdfInfo.getSchema() != null) return false;
197
		if (getNamespace() != null ? !getNamespace().equals(mdfInfo.getNamespace()) : mdfInfo.getNamespace() != null) return false;
198
		if (getSourceMetadataReference() != null ?
199
				!getSourceMetadataReference().equals(mdfInfo.getSourceMetadataReference()) :
200
				mdfInfo.getSourceMetadataReference() != null)
201
			return false;
202
		if (getBaseQuery() != null ? !getBaseQuery().equals(mdfInfo.getBaseQuery()) : mdfInfo.getBaseQuery() != null) return false;
203
		return getTransformationRuleID() != null ?
204
				getTransformationRuleID().equals(mdfInfo.getTransformationRuleID()) :
205
				mdfInfo.getTransformationRuleID() == null;
201 206
	}
202 207

  
203 208
	@Override
204
	public boolean equals(final Object obj) {
205
		if (this == obj) return true;
206
		if (obj == null) return false;
207
		if (!(obj instanceof MDFInfo)) return false;
208
		MDFInfo other = (MDFInfo) obj;
209
		if (baseQuery == null) {
210
			if (other.baseQuery != null) return false;
211
		} else if (!baseQuery.equals(other.baseQuery)) return false;
212
		if (enabled != other.enabled) return false;
213
		if (namespace == null) {
214
			if (other.namespace != null) return false;
215
		} else if (!namespace.equals(other.namespace)) return false;
216
		if (prefix == null) {
217
			if (other.prefix != null) return false;
218
		} else if (!prefix.equals(other.prefix)) return false;
219
		if (schema == null) {
220
			if (other.schema != null) return false;
221
		} else if (!schema.equals(other.schema)) return false;
222
		if (sourceFormatInterpretation == null) {
223
			if (other.sourceFormatInterpretation != null) return false;
224
		} else if (!sourceFormatInterpretation.equals(other.sourceFormatInterpretation)) return false;
225
		if (sourceFormatLayout == null) {
226
			if (other.sourceFormatLayout != null) return false;
227
		} else if (!sourceFormatLayout.equals(other.sourceFormatLayout)) return false;
228
		if (sourceFormatName == null) {
229
			if (other.sourceFormatName != null) return false;
230
		} else if (!sourceFormatName.equals(other.sourceFormatName)) return false;
231
		if (transformationRuleID == null) {
232
			if (other.transformationRuleID != null) return false;
233
		} else if (!transformationRuleID.equals(other.transformationRuleID)) return false;
234
		return true;
209
	public int hashCode() {
210
		int result = getPrefix() != null ? getPrefix().hashCode() : 0;
211
		result = 31 * result + (getSchema() != null ? getSchema().hashCode() : 0);
212
		result = 31 * result + (getNamespace() != null ? getNamespace().hashCode() : 0);
213
		result = 31 * result + (getSourceMetadataReference() != null ? getSourceMetadataReference().hashCode() : 0);
214
		result = 31 * result + (getBaseQuery() != null ? getBaseQuery().hashCode() : 0);
215
		result = 31 * result + (getTransformationRuleID() != null ? getTransformationRuleID().hashCode() : 0);
216
		result = 31 * result + (isEnabled() ? 1 : 0);
217
		return result;
235 218
	}
236 219

  
220

  
237 221
}

Also available in: Unified diff