/** * ============================================================================= * * ORCID (R) Open Source * http://orcid.org * * Copyright (c) 2012-2014 ORCID, Inc. * Licensed under an MIT-Style License (MIT) * http://orcid.org/open-source-license * * This copyright and license information (including a link to the full license) * shall be included in its entirety in all copies or substantial portion of * the software. * * ============================================================================= */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. // Generated on: 2012.08.13 at 04:58:08 PM BST // package org.orcid.core.adapter.impl.jsonidentifiers; import java.io.Serializable; import org.orcid.core.utils.JsonUtils; import org.orcid.jaxb.model.message.FundingExternalIdentifierType; import org.orcid.jaxb.model.record_v2.ExternalID; import org.orcid.jaxb.model.record_v2.Relationship; import org.orcid.pojo.ajaxForm.PojoUtil; import com.fasterxml.jackson.annotation.JsonIgnore; public class FundingExternalIdentifier implements Serializable, JSONIdentifierAdapter<org.orcid.jaxb.model.message.FundingExternalIdentifier, ExternalID> { private static final long serialVersionUID = -7384268121070514399L; protected String type; protected String value; protected Url url; protected String relationship; @JsonIgnore private ExternalIdentifierTypeConverter conv = new ExternalIdentifierTypeConverter(); protected FundingExternalIdentifier() { } public FundingExternalIdentifier(org.orcid.jaxb.model.message.FundingExternalIdentifier messagePojo) { if (messagePojo.getType() != null) { this.setType(messagePojo.getType().value()); } if (messagePojo.getUrl() != null) { this.setUrl(new Url(messagePojo.getUrl().getValue())); } if (!PojoUtil.isEmpty(messagePojo.getValue())) { this.setValue(messagePojo.getValue()); } } public FundingExternalIdentifier(org.orcid.jaxb.model.record_v2.ExternalID recordPojo) { if (recordPojo.getType() != null) { this.setType(recordPojo.getType()); } if (recordPojo.getUrl() != null) { this.setUrl(new Url(recordPojo.getUrl().getValue())); } if (!PojoUtil.isEmpty(recordPojo.getValue())) { this.setValue(recordPojo.getValue()); } if (recordPojo.getRelationship() != null) { this.setRelationship(recordPojo.getRelationship().value()); } } public FundingExternalIdentifier(FundingExternalIdentifierType type, String url2, String value) { this.setType(type.value()); this.setUrl(new Url(url2)); this.setValue(value); } public String toDBJSONString() { return JsonUtils.convertToJsonString(this); } public static FundingExternalIdentifier fromDBJSONString(String dbJSON) { return JsonUtils.readObjectFromJsonString(dbJSON, FundingExternalIdentifier.class); } public String getType() { return type; } public void setType(String type) { if (type != null) this.type = conv.convertTo(type, null); } public String getValue() { return value; } public void setValue(String value) { this.value = value; } public Url getUrl() { return url; } public void setUrl(Url url) { this.url = url; } public String getRelationship() { return relationship; } public void setRelationship(String relationship) { if (relationship != null) this.relationship = conv.convertTo(relationship, null); } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((type == null) ? 0 : type.hashCode()); result = prime * result + ((url == null) ? 0 : url.hashCode()); result = prime * result + ((value == null) ? 0 : value.hashCode()); result = prime * result + ((relationship == null) ? 0 : relationship.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; FundingExternalIdentifier other = (FundingExternalIdentifier) obj; if (type == null) { if (other.type != null) return false; } else if (!type.equals(other.type)) return false; if (url == null) { if (other.url != null) return false; } else if (!url.equals(other.url)) return false; if (value == null) { if (other.value != null) return false; } else if (!value.equals(other.value)) return false; if (relationship == null) { if (other.relationship != null) return false; } else if (!relationship.equals(other.relationship)) return false; return true; } public org.orcid.jaxb.model.message.FundingExternalIdentifier toMessagePojo() { org.orcid.jaxb.model.message.FundingExternalIdentifier messagePojo = new org.orcid.jaxb.model.message.FundingExternalIdentifier(); try { // note that funding identifiers use "_" in the api e.g. // grant_number wheras works use "-". Isn't that fun? if (this.getType() != null) messagePojo.setType(FundingExternalIdentifierType.fromValue(this.getType().toLowerCase())); else messagePojo.setType(FundingExternalIdentifierType.GRANT_NUMBER); } catch (IllegalArgumentException e) { messagePojo.setType(FundingExternalIdentifierType.GRANT_NUMBER); } if (this.getUrl() != null) { org.orcid.jaxb.model.message.Url messageUrl = new org.orcid.jaxb.model.message.Url(); messageUrl.setValue(this.getUrl().value); messagePojo.setUrl(messageUrl); } messagePojo.setValue(this.getValue()); return messagePojo; } public ExternalID toRecordPojo() { ExternalID recordPojo = new ExternalID(); // note that funding identifiers use "_" in the api e.g. grant_number // wheras works use "-". Isn't that fun? if (this.getType() == null) recordPojo.setType(FundingExternalIdentifierType.GRANT_NUMBER.value()); else recordPojo.setType(this.getType().toLowerCase()); if (this.getUrl() != null && !PojoUtil.isEmpty(this.getUrl().value)) { org.orcid.jaxb.model.common_v2.Url url = new org.orcid.jaxb.model.common_v2.Url(this.getUrl().value); recordPojo.setUrl(url); } if (!PojoUtil.isEmpty(this.getValue())) { recordPojo.setValue(this.getValue()); } if (this.getRelationship() != null) recordPojo.setRelationship(Relationship.fromValue(conv.convertFrom(this.getRelationship(), null))); return recordPojo; } }