WIP: model simplification
This commit is contained in:
parent
4d70508ad9
commit
3b5b4c565b
|
@ -6,8 +6,6 @@ import java.util.List;
|
|||
|
||||
public class Dataset extends Result implements Serializable {
|
||||
|
||||
private static final String DATASET_RESULTTYPE = "dataset";
|
||||
|
||||
private String storagedate;
|
||||
|
||||
// candidate for removal
|
||||
|
@ -24,7 +22,7 @@ public class Dataset extends Result implements Serializable {
|
|||
private List<GeoLocation> geolocation;
|
||||
|
||||
public Dataset() {
|
||||
setResulttype(DATASET_RESULTTYPE);
|
||||
setResulttype(RESULTTYPE.dataset);
|
||||
}
|
||||
|
||||
public String getStoragedate() {
|
||||
|
|
|
@ -6,8 +6,6 @@ import java.util.List;
|
|||
|
||||
public class OtherResearchProduct extends Result implements Serializable {
|
||||
|
||||
private static final String ORP_RESULTTYPE = "otherresearchproduct";
|
||||
|
||||
private List<String> contactperson;
|
||||
|
||||
private List<String> contactgroup;
|
||||
|
@ -15,7 +13,7 @@ public class OtherResearchProduct extends Result implements Serializable {
|
|||
private List<String> tool;
|
||||
|
||||
public OtherResearchProduct() {
|
||||
setResulttype(ORP_RESULTTYPE);
|
||||
setResulttype(RESULTTYPE.otherresearchproduct);
|
||||
}
|
||||
|
||||
public List<String> getContactperson() {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package eu.dnetlib.dhp.schema.oaf;
|
||||
|
||||
public class Provenance {
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Provenance implements Serializable {
|
||||
|
||||
private KeyValue collectedfrom;
|
||||
|
||||
|
|
|
@ -5,10 +5,8 @@ import java.io.Serializable;
|
|||
|
||||
public class Publication extends Result implements Serializable {
|
||||
|
||||
private static final String PUBLICATION_RESULTTYPE = "publication";
|
||||
|
||||
public Publication() {
|
||||
setResulttype(PUBLICATION_RESULTTYPE);
|
||||
setResulttype(RESULTTYPE.publication);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
package eu.dnetlib.dhp.schema.oaf;
|
||||
|
||||
import java.beans.Transient;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -14,139 +15,335 @@ import java.util.Objects;
|
|||
*/
|
||||
public class Relation extends Oaf implements Serializable {
|
||||
|
||||
/**
|
||||
* Main relationship classifier, values include 'resultResult', 'resultProject', 'resultOrganization', etc.
|
||||
*/
|
||||
private String relType;
|
||||
public enum RELTYPE {
|
||||
resultResult,
|
||||
resultProject,
|
||||
resultOrganization,
|
||||
projectOrganization,
|
||||
datasourceOrganization
|
||||
}
|
||||
|
||||
/**
|
||||
* Further classifies a relationship, values include 'affiliation', 'similarity', 'supplement', etc.
|
||||
*/
|
||||
private String subRelType;
|
||||
public enum SUBRELTYPE {
|
||||
affiliation,
|
||||
citation,
|
||||
dedup,
|
||||
outcome,
|
||||
part,
|
||||
participation,
|
||||
provision,
|
||||
relationship,
|
||||
review,
|
||||
similarity,
|
||||
supplement,
|
||||
version;
|
||||
|
||||
/**
|
||||
* Indicates the direction of the relationship, values include 'isSupplementTo', 'isSupplementedBy', 'merges,
|
||||
* 'isMergedIn'.
|
||||
*/
|
||||
private String relClass;
|
||||
public boolean exists(String subreltype) {
|
||||
try {
|
||||
SUBRELTYPE.valueOf(subreltype);
|
||||
return true;
|
||||
} catch (IllegalArgumentException | NullPointerException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The source entity id.
|
||||
*/
|
||||
private String source;
|
||||
public enum RELCLASS {
|
||||
IsVersionOf,
|
||||
IsSourceOf,
|
||||
isMergedIn,
|
||||
IsIdenticalTo,
|
||||
Documents,
|
||||
IsAmongTopNSimilarDocuments,
|
||||
IsSupplementedBy,
|
||||
IsObsoletedBy,
|
||||
Continues,
|
||||
IsParentOf,
|
||||
IsReferencedBy,
|
||||
IsCitedBy,
|
||||
Compiles,
|
||||
IsPreviousVersionOf,
|
||||
HasPart,
|
||||
IsDocumentedBy,
|
||||
HasAmongTopNSimilarDocuments,
|
||||
isParticipant,
|
||||
hasAuthorInstitution,
|
||||
IsRelatedTo,
|
||||
Requires,
|
||||
Describes,
|
||||
IsReviewedBy,
|
||||
IsContinuedBy,
|
||||
provides,
|
||||
IsChildOf,
|
||||
IsDescribedBy,
|
||||
IsNewVersionOf,
|
||||
IsPartOf,
|
||||
HasVersion,
|
||||
hasParticipant,
|
||||
isAuthorInstitutionOf,
|
||||
IsVariantFormOf,
|
||||
isProducedBy,
|
||||
IsMetadataFor,
|
||||
Cites,
|
||||
IsRequiredBy,
|
||||
IsOriginalFormOf,
|
||||
IsSupplementTo,
|
||||
IsMetadataOf,
|
||||
References,
|
||||
IsCompiledBy,
|
||||
isProvidedBy,
|
||||
merges,
|
||||
IsDerivedFrom,
|
||||
Obsoletes,
|
||||
Reviews,
|
||||
produces;
|
||||
|
||||
/**
|
||||
* The target entity id.
|
||||
*/
|
||||
private String target;
|
||||
public static boolean exists(String relclass) {
|
||||
try {
|
||||
RELCLASS.valueOf(relclass);
|
||||
return true;
|
||||
} catch (IllegalArgumentException | NullPointerException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Was this relationship authoritatively validated?
|
||||
*/
|
||||
private Boolean validated;
|
||||
@Transient
|
||||
public RELCLASS getInverse() {
|
||||
switch (this) {
|
||||
case IsVersionOf:
|
||||
return HasVersion;
|
||||
case IsSourceOf:
|
||||
return IsDerivedFrom;
|
||||
case isMergedIn:
|
||||
return merges;
|
||||
case IsIdenticalTo:
|
||||
return IsIdenticalTo;
|
||||
case Documents:
|
||||
return IsDocumentedBy;
|
||||
case IsAmongTopNSimilarDocuments:
|
||||
return HasAmongTopNSimilarDocuments;
|
||||
case IsSupplementedBy:
|
||||
return IsSupplementTo;
|
||||
case IsObsoletedBy:
|
||||
return Obsoletes;
|
||||
case Continues:
|
||||
return IsContinuedBy;
|
||||
case IsParentOf:
|
||||
return IsChildOf;
|
||||
case IsReferencedBy:
|
||||
return References;
|
||||
case IsCitedBy:
|
||||
return Cites;
|
||||
case Compiles:
|
||||
return IsCompiledBy;
|
||||
case IsPreviousVersionOf:
|
||||
return IsNewVersionOf;
|
||||
case HasPart:
|
||||
return IsPartOf;
|
||||
case IsDocumentedBy:
|
||||
return Documents;
|
||||
case HasAmongTopNSimilarDocuments:
|
||||
return IsAmongTopNSimilarDocuments;
|
||||
case isParticipant:
|
||||
return hasParticipant;
|
||||
case hasAuthorInstitution:
|
||||
return isAuthorInstitutionOf;
|
||||
case IsRelatedTo:
|
||||
return IsRelatedTo;
|
||||
case Requires:
|
||||
return IsRequiredBy;
|
||||
case Describes:
|
||||
return IsDescribedBy;
|
||||
case IsReviewedBy:
|
||||
return Reviews;
|
||||
case IsContinuedBy:
|
||||
return Continues;
|
||||
case provides:
|
||||
return isProvidedBy;
|
||||
case IsChildOf:
|
||||
return IsParentOf;
|
||||
case IsDescribedBy:
|
||||
return Describes;
|
||||
case IsNewVersionOf:
|
||||
return IsPreviousVersionOf;
|
||||
case IsPartOf:
|
||||
return HasPart;
|
||||
case HasVersion:
|
||||
return IsVersionOf;
|
||||
case hasParticipant:
|
||||
return isParticipant;
|
||||
case isAuthorInstitutionOf:
|
||||
return hasAuthorInstitution;
|
||||
case IsVariantFormOf:
|
||||
return IsOriginalFormOf;
|
||||
case isProducedBy:
|
||||
return produces;
|
||||
case IsMetadataFor:
|
||||
return IsMetadataOf;
|
||||
case Cites:
|
||||
return IsCitedBy;
|
||||
case IsRequiredBy:
|
||||
return Requires;
|
||||
case IsOriginalFormOf:
|
||||
return IsVariantFormOf;
|
||||
case IsSupplementTo:
|
||||
return IsSupplementedBy;
|
||||
case IsMetadataOf:
|
||||
return IsMetadataFor;
|
||||
case References:
|
||||
return IsReferencedBy;
|
||||
case IsCompiledBy:
|
||||
return Compiles;
|
||||
case isProvidedBy:
|
||||
return provides;
|
||||
case merges:
|
||||
return isMergedIn;
|
||||
case IsDerivedFrom:
|
||||
return IsSourceOf;
|
||||
case Obsoletes:
|
||||
return IsObsoletedBy;
|
||||
case Reviews:
|
||||
return IsReviewedBy;
|
||||
case produces:
|
||||
return isProducedBy;
|
||||
}
|
||||
// makes the compiler happy
|
||||
throw new IllegalArgumentException("missing inverse mapping for" + this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When was this relationship authoritatively validated.
|
||||
*/
|
||||
private String validationDate;
|
||||
/**
|
||||
* Main relationship classifier, values include 'resultResult', 'resultProject', 'resultOrganization', etc.
|
||||
*/
|
||||
private RELTYPE relType;
|
||||
|
||||
private List<Provenance> provenance;
|
||||
/**
|
||||
* Further classifies a relationship, values include 'affiliation', 'similarity', 'supplement', etc.
|
||||
*/
|
||||
private SUBRELTYPE subRelType;
|
||||
|
||||
/**
|
||||
* List of relation specific properties. Values include 'similarityLevel', indicating the similarity score between a
|
||||
* pair of publications.
|
||||
*/
|
||||
private List<KeyValue> properties = new ArrayList<>();
|
||||
/**
|
||||
* Indicates the direction of the relationship, values include 'isSupplementTo', 'isSupplementedBy', 'merges,
|
||||
* 'isMergedIn'.
|
||||
*/
|
||||
private RELCLASS relClass;
|
||||
|
||||
public String getRelType() {
|
||||
return relType;
|
||||
}
|
||||
/**
|
||||
* The source entity id.
|
||||
*/
|
||||
private String source;
|
||||
|
||||
public void setRelType(final String relType) {
|
||||
this.relType = relType;
|
||||
}
|
||||
/**
|
||||
* The target entity id.
|
||||
*/
|
||||
private String target;
|
||||
|
||||
public String getSubRelType() {
|
||||
return subRelType;
|
||||
}
|
||||
/**
|
||||
* Was this relationship authoritatively validated?
|
||||
*/
|
||||
private Boolean validated;
|
||||
|
||||
public void setSubRelType(final String subRelType) {
|
||||
this.subRelType = subRelType;
|
||||
}
|
||||
/**
|
||||
* When was this relationship authoritatively validated.
|
||||
*/
|
||||
private String validationDate;
|
||||
|
||||
public String getRelClass() {
|
||||
return relClass;
|
||||
}
|
||||
private List<Provenance> provenance;
|
||||
|
||||
public void setRelClass(final String relClass) {
|
||||
this.relClass = relClass;
|
||||
}
|
||||
/**
|
||||
* List of relation specific properties. Values include 'similarityLevel', indicating the similarity score between a
|
||||
* pair of publications.
|
||||
*/
|
||||
private List<KeyValue> properties = new ArrayList<>();
|
||||
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
public RELTYPE getRelType() {
|
||||
return relType;
|
||||
}
|
||||
|
||||
public void setSource(final String source) {
|
||||
this.source = source;
|
||||
}
|
||||
public void setRelType(final RELTYPE relType) {
|
||||
this.relType = relType;
|
||||
}
|
||||
|
||||
public String getTarget() {
|
||||
return target;
|
||||
}
|
||||
public SUBRELTYPE getSubRelType() {
|
||||
return subRelType;
|
||||
}
|
||||
|
||||
public void setTarget(final String target) {
|
||||
this.target = target;
|
||||
}
|
||||
public void setSubRelType(final SUBRELTYPE subRelType) {
|
||||
this.subRelType = subRelType;
|
||||
}
|
||||
|
||||
public List<KeyValue> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
public RELCLASS getRelClass() {
|
||||
return relClass;
|
||||
}
|
||||
|
||||
public void setProperties(List<KeyValue> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
public void setRelClass(final RELCLASS relClass) {
|
||||
this.relClass = relClass;
|
||||
}
|
||||
|
||||
public Boolean getValidated() {
|
||||
return Objects.nonNull(validated) && validated;
|
||||
}
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public void setValidated(Boolean validated) {
|
||||
this.validated = validated;
|
||||
}
|
||||
public void setSource(final String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public String getValidationDate() {
|
||||
return validationDate;
|
||||
}
|
||||
public String getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setValidationDate(String validationDate) {
|
||||
this.validationDate = validationDate;
|
||||
}
|
||||
public void setTarget(final String target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public List<Provenance> getProvenance() {
|
||||
return provenance;
|
||||
}
|
||||
public List<KeyValue> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProvenance(List<Provenance> provenance) {
|
||||
this.provenance = provenance;
|
||||
}
|
||||
public void setProperties(List<KeyValue> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
Relation relation = (Relation) o;
|
||||
return relType.equals(relation.relType)
|
||||
&& subRelType.equals(relation.subRelType)
|
||||
&& relClass.equals(relation.relClass)
|
||||
&& source.equals(relation.source)
|
||||
&& target.equals(relation.target);
|
||||
}
|
||||
public Boolean getValidated() {
|
||||
return Objects.nonNull(validated) && validated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(relType, subRelType, relClass, source, target, provenance);
|
||||
}
|
||||
public void setValidated(Boolean validated) {
|
||||
this.validated = validated;
|
||||
}
|
||||
|
||||
public String getValidationDate() {
|
||||
return validationDate;
|
||||
}
|
||||
|
||||
public void setValidationDate(String validationDate) {
|
||||
this.validationDate = validationDate;
|
||||
}
|
||||
|
||||
public List<Provenance> getProvenance() {
|
||||
return provenance;
|
||||
}
|
||||
|
||||
public void setProvenance(List<Provenance> provenance) {
|
||||
this.provenance = provenance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
Relation relation = (Relation) o;
|
||||
return relType.equals(relation.relType)
|
||||
&& subRelType.equals(relation.subRelType)
|
||||
&& relClass.equals(relation.relClass)
|
||||
&& source.equals(relation.source)
|
||||
&& target.equals(relation.target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(relType, subRelType, relClass, source, target, provenance);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,13 @@ import java.util.List;
|
|||
*/
|
||||
public class Result extends Entity implements Serializable {
|
||||
|
||||
public enum RESULTTYPE {
|
||||
publication,
|
||||
dataset,
|
||||
software,
|
||||
otherresearchproduct
|
||||
}
|
||||
|
||||
/**
|
||||
* ( article | book ) processing charges.
|
||||
*/
|
||||
|
@ -27,7 +34,7 @@ public class Result extends Entity implements Serializable {
|
|||
/**
|
||||
* The Resulttype. It allows subclassing results into publications | datasets | software | orp
|
||||
*/
|
||||
private String resulttype;
|
||||
private RESULTTYPE resulttype;
|
||||
|
||||
/**
|
||||
* The Language.
|
||||
|
@ -172,7 +179,7 @@ public class Result extends Entity implements Serializable {
|
|||
*
|
||||
* @return the resulttype
|
||||
*/
|
||||
public String getResulttype() {
|
||||
public RESULTTYPE getResulttype() {
|
||||
return resulttype;
|
||||
}
|
||||
|
||||
|
@ -181,7 +188,7 @@ public class Result extends Entity implements Serializable {
|
|||
*
|
||||
* @param resulttype the resulttype
|
||||
*/
|
||||
public void setResulttype(String resulttype) {
|
||||
public void setResulttype(RESULTTYPE resulttype) {
|
||||
this.resulttype = resulttype;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,6 @@ import java.util.List;
|
|||
|
||||
public class Software extends Result implements Serializable {
|
||||
|
||||
private static final String SOFTWARE_RESULTTYPE = "software";
|
||||
|
||||
private List<String> documentationUrl;
|
||||
|
||||
// candidate for removal
|
||||
|
@ -16,7 +14,7 @@ public class Software extends Result implements Serializable {
|
|||
private Qualifier programmingLanguage;
|
||||
|
||||
public Software() {
|
||||
setResulttype(SOFTWARE_RESULTTYPE);
|
||||
setResulttype(RESULTTYPE.software);
|
||||
}
|
||||
|
||||
public List<String> getDocumentationUrl() {
|
||||
|
|
|
@ -22,9 +22,9 @@ class AtomicActionTest {
|
|||
Relation rel = new Relation();
|
||||
rel.setSource("1");
|
||||
rel.setTarget("2");
|
||||
rel.setRelType("resultResult");
|
||||
rel.setSubRelType("dedup");
|
||||
rel.setRelClass("merges");
|
||||
rel.setRelType(Relation.RELTYPE.resultResult);
|
||||
rel.setSubRelType(Relation.SUBRELTYPE.dedup);
|
||||
rel.setRelClass(Relation.RELCLASS.merges);
|
||||
|
||||
AtomicAction aa1 = new AtomicAction(Relation.class, rel);
|
||||
|
||||
|
|
Loading…
Reference in New Issue