Export author and affiliation

This commit is contained in:
Georgy Litvinov 2020-11-23 17:13:52 +01:00
parent 8741ed024f
commit a2a14c0c12

View file

@ -31,6 +31,8 @@ public class DocumentStructure {
private static final String TOC_LEVEL = "TOCLevel";
private static final String TABLE_OF_CONTENTS = "TOC";
private static final String PARTICIPANT = "publicationParticipant";
private static final String ORGANIZATION = "organization";
private static final String PUBLICATION = "publication";
private static final String BOOK = "book";
private static final String JOURNAL = "journal";
@ -49,6 +51,9 @@ public class DocumentStructure {
private OntClass itemClass;
private OntClass documentClass;
private OntClass tocClass;
private OntClass organizationClass;
private OntClass participantClass;
private HashMap<String, Resource> tocLevels;
private HashMap<String, DocumentPart> inputParts;
@ -62,6 +67,8 @@ public class DocumentStructure {
this.textOntology = ModelFactory.createOntologyModel();
this.tocLevelClass = textOntology.createClass(TS + TOC_LEVEL);
this.tocClass = textOntology.createClass(TS + TABLE_OF_CONTENTS);
this.organizationClass = textOntology.createClass(TS + ORGANIZATION);
this.participantClass = textOntology.createClass(TS + PARTICIPANT);
this.itemClass = textOntology.createClass(TS + TOCITEM);
this.docID = fileName;
String publicationType = config.getRDFType();
@ -182,7 +189,7 @@ public class DocumentStructure {
mainResource.addProperty(hasTOC, toc);
addMetadataProperties(mainResource, docPart);
addAuthor(mainResource, docPart);
//addAuthor(mainResource, docPart);
tocLevels.put(docPart.getPath(), toc);
attachExcerpt(docPart, toc);
}
@ -199,10 +206,66 @@ public class DocumentStructure {
}
private void attachAuthor(Resource resource, Map<String, String> map, String order) {
//String tocURI = TS + PARTICIPANT + "/" + PARSERNAME + "_" + docID ;
//Resource toc = m.createResource(tocURI, tocClass);
String participantURI = TS + PARTICIPANT + "/" + PARSERNAME + "_" + docID + order ;
Resource participant = m.createResource(participantURI, participantClass);
Property hasAuthor = m.createProperty(TS + "hasAuthor");
resource.addProperty(hasAuthor, participant);
createParticipant(map, order, participant);
}
private void createParticipant(Map<String, String> map, String order, Resource participant) {
String givenName = map.get("author given name");
if (givenName != null) {
Property givenNameProperty = m.createProperty(TS + "participantGivenName");
participant.addProperty( givenNameProperty, givenName.trim());
}
String family = map.get("author family");
if (family != null) {
Property familyProperty = m.createProperty(TS + "participantFamily");
participant.addProperty( familyProperty, family.trim());
}
String email = map.get("author email");
if (email != null) {
Property emailProperty = m.createProperty(TS + "participantEmail");
participant.addProperty( emailProperty, email.trim());
}
String authorInitials = map.get("author initials");
if (email != null) {
Property initialsProperty = m.createProperty(TS + "participantInitials");
participant.addProperty( initialsProperty, authorInitials.trim());
}
attachOrganization(participant, map, order);
}
private void attachOrganization(Resource participant, Map<String, String> map, String order) {
String orgName = map.get("affiliated organization name");
System.out.println(orgName);
if (orgName == null) {
return;
}
String organizationUri = TS + ORGANIZATION + "/" + PARSERNAME + "_" + docID + order;
Resource organization = m.createResource(organizationUri, organizationClass);
Property affiliatedWith = m.createProperty(TS + "affiliatedWith");
participant.addProperty(affiliatedWith, participant);
organization.addProperty(RDFS.label, orgName);
String officialName = map.get("affiliated organization official name");
if (officialName != null) {
Property officialNameProperty = m.createProperty(TS + "officialOrganizationName");
organization.addProperty(officialNameProperty, officialName);
}
String orgAddress = map.get("affiliated organization address");
if (orgAddress != null) {
Property orgAddressProperty = m.createProperty(TS + "organizationAddress");
organization.addProperty(orgAddressProperty, orgAddress);
}
String postalCode = map.get("affiliated organization postal code");
if (postalCode != null) {
Property postalCodeProperty = m.createProperty(TS + "organizationPostalCode");
organization.addProperty(postalCodeProperty, postalCode);
}
}
private void addMetadataProperties(Resource resource, DocumentPart docPart) {