Skip to content
Snippets Groups Projects
Commit 09b3fee9 authored by Stefan E. Funk's avatar Stefan E. Funk
Browse files

Add contributor to DARIAH record

parent 81edc96c
No related branches found
No related tags found
No related merge requests found
......@@ -56,7 +56,7 @@ import info.textgrid.middleware.oaipmh.Resource.Titles.Title;
/**
* @author Maximilian Brodhun, SUB Göttingen
* @author Stefan E. Funk, SUB Göttingen
* @version 2021-07-23
* @version 2021-09-03
* @since 2020-06-13
*/
@Component
......@@ -684,31 +684,46 @@ public class RecordDelivererDATACITE extends RecordDelivererAbstract {
Contributors contributors = new Contributors();
// FIXME fu: Please adapt to DARIAH!
for (String contributorField : this.oarContributorFields) {
Contributor contributorInOpenAireRecord = new Contributor();
if (contributorField.equals("project")) {
contributorInOpenAireRecord.setContributorName(
OAIPMHUtilities.fieldLoader(this.jsonObj, contributorField + ".value"));
contributorInOpenAireRecord.setContributorType(ContributorType.OTHER);
info.textgrid.middleware.oaipmh.Resource.Contributors.Contributor.NameIdentifier name =
new info.textgrid.middleware.oaipmh.Resource.Contributors.Contributor.NameIdentifier();
name.setNameIdentifierScheme("textgrid");
name.setValue(OAIPMHUtilities.fieldLoader(this.jsonObj, contributorField + ".id"));
name.setSchemeURI("https://textgridlab.org/schema/textgrid-metadata_2010.xsd");
contributorInOpenAireRecord.setNameIdentifier(name);
} else {
// **
// TextGrid
// **
if (this.textgrid) {
if (contributorField.equals("project")) {
contributorInOpenAireRecord.setContributorName(
OAIPMHUtilities.fieldLoader(this.jsonObj, contributorField + ".value"));
contributorInOpenAireRecord.setContributorType(ContributorType.OTHER);
info.textgrid.middleware.oaipmh.Resource.Contributors.Contributor.NameIdentifier name =
new info.textgrid.middleware.oaipmh.Resource.Contributors.Contributor.NameIdentifier();
name.setNameIdentifierScheme("textgrid");
name.setValue(OAIPMHUtilities.fieldLoader(this.jsonObj, contributorField + ".id"));
name.setSchemeURI("https://textgridlab.org/schema/textgrid-metadata_2010.xsd");
contributorInOpenAireRecord.setNameIdentifier(name);
} else {
contributorInOpenAireRecord
.setContributorName(OAIPMHUtilities.fieldLoader(this.jsonObj, contributorField));
contributorInOpenAireRecord.setContributorType(ContributorType.DATA_MANAGER);
/*
* info.textgrid.middleware.oaipmh.Resource.Contributors.Contributor.NameIdentifier name =
* new info.textgrid.middleware.oaipmh.Resource.Contributors.Contributor.NameIdentifier();
* name.setNameIdentifierScheme("textgrid"); name.setValue("");
* name.setSchemeURI("http://www.textgridlab.org/schema/textgrid-metadata_2010.xsd");
* contributorInOpenAireRecord.setNameIdentifier(name);
*/
}
}
// **
// DARIAH
// **
else if (this.dariah) {
contributorInOpenAireRecord
.setContributorName(OAIPMHUtilities.fieldLoader(this.jsonObj, contributorField));
contributorInOpenAireRecord.setContributorType(ContributorType.DATA_MANAGER);
/*
* info.textgrid.middleware.oaipmh.Resource.Contributors.Contributor.NameIdentifier name =
* new info.textgrid.middleware.oaipmh.Resource.Contributors.Contributor.NameIdentifier();
* name.setNameIdentifierScheme("textgrid"); name.setValue("");
* name.setSchemeURI("http://www.textgridlab.org/schema/textgrid-metadata_2010.xsd");
* contributorInOpenAireRecord.setNameIdentifier(name);
*/
}
contributors.getContributor().add(contributorInOpenAireRecord);
......
//package info.textgrid.middleware;
//
//import java.io.UnsupportedEncodingException;
//import java.net.URLDecoder;
//import java.util.Hashtable;
//import java.util.Iterator;
//import java.util.LinkedHashSet;
//import java.util.Map;
//import java.util.Set;
//import org.elasticsearch.action.get.GetRequestBuilder;
//import org.elasticsearch.action.get.GetResponse;
//import org.elasticsearch.action.search.SearchRequestBuilder;
//import org.elasticsearch.action.search.SearchResponse;
//import org.elasticsearch.index.query.QueryBuilder;
//import org.elasticsearch.index.query.QueryBuilders;
//import org.elasticsearch.search.SearchHit;
//import info.textgrid.middleware.oaipmh.ListSetsType;
//import info.textgrid.middleware.oaipmh.RequestType;
//import info.textgrid.middleware.oaipmh.SetType;
//import info.textgrid.namespaces.middleware.tgcrud.common.TextGridMimetypes;
//
///**
// *
// */
//public class SetDeliverer {
//
// private static Map<String, String> setSet = new Hashtable<String, String>();
//
// private Set<String> identifier = new LinkedHashSet<String>();
// private String formatField;
// private String formatToFilter;
// private String identifierField;
// private String repositoryObjectURIPrefix;
// private String specField;
// private String specFieldPrefix;
// private boolean textgrid;
// private boolean dariah;
//
// /**
// * @param oaiEsClient
// * @param textgrid
// * @param dariah
// */
// public SetDeliverer(boolean textgrid, boolean dariah) {
// this.textgrid = textgrid;
// this.dariah = dariah;
// }
//
// /**
// * @return
// */
// public ListSetsType setListBuilder() {
//
// ListSetsType setList = new ListSetsType();
// QueryBuilder aggQuery;
// if (this.textgrid) {
// aggQuery = QueryBuilders.matchPhraseQuery("format", TextGridMimetypes.EDITION);
// } else {
// aggQuery = QueryBuilders.matchPhraseQuery("descriptiveMetadata.dc:format",
// TextGridMimetypes.DARIAH_COLLECTION);
// }
//
// SearchRequestBuilder request = OAI_ESClient.getOaiESClient()
// .prepareSearch(OAI_ESClient.getEsIndex()).setTypes(OAI_ESClient.getEsType())
// .setQuery(aggQuery)
// .addField(this.formatField)
// .addField(this.identifierField)
// .addField("project.value")
// .addField("project.id")
// .setSize(100000);
//
// SearchResponse getRecordListItems = request.execute().actionGet();
//
// for (SearchHit hit : getRecordListItems.getHits().getHits()) {
// if (this.dariah == true && hit.getFields().get(this.identifierField).values().get(0)
// .toString().startsWith("hdl:")) {
// String pid = hit.getFields().get(this.identifierField).values().get(0).toString();
// this.identifier.add(pid);
//
// }
//
// if (this.textgrid == true) {
// String projectName = hit.getFields().get("project.value").values().get(0).toString();
// String projectID = hit.getFields().get("project.id").values().get(0).toString();
// String projectSetSpec = projectName.concat(":").concat(projectID);
// SetDeliverer.setSet.put(projectID, projectName);
// }
// }
//
// if (this.textgrid == true) {
// Iterator it = setSet.entrySet().iterator();
// while (it.hasNext()) {
// Map.Entry pair = (Map.Entry) it.next();
// SetType set = new SetType();
// set.setSetName(pair.getValue().toString());
// set.setSetSpec("project:" + pair.getKey().toString());
// setList.getSet().add(set);
// }
// }
//
// if (this.dariah == true) {
// for (String identifierSetSpec : this.identifier) {
// String id = identifierSetSpec;
// try {
// id = URLDecoder.decode(id, "UTF-8");
// } catch (UnsupportedEncodingException e) {
// e.printStackTrace();
// }
//
// id = identifierSetSpec.substring(this.repositoryObjectURIPrefix.length());
//
// GetRequestBuilder collectionNameById =
// OAI_ESClient.getOaiESClient().prepareGet().setIndex(OAI_ESClient.getEsIndex())
// .setType(OAI_ESClient.getEsType()).setFields(this.specField).setId(id);
//
// GetResponse setSpec = collectionNameById.execute().actionGet();
// String setName = "";
// if (setSpec != null && setSpec.isExists()) {
// if (setSpec.getField(this.specField) != null) {
// setName = setSpec.getField(this.specField).getValue().toString();
// }
// }
//
// SetType set = new SetType();
// set.setSetName(setName);
// set.setSetSpec(this.specFieldPrefix + id);
// setList.getSet().add(set);
// }
// }
//
// this.identifier.clear();
//
// return setList;
// }
//
// /**
// * <p>
// * Checking the request if all necessary values are set or not allowed values are not set.
// * </p>
// *
// * @param request the initially request from the OAIPMG client
// * @return a boolean indicating the correctness of the request
// */
// public boolean requestChecker(RequestType request) {
//
// boolean noArguments;
//
// if (request.getFrom() != null ||
// request.getIdentifier() != null ||
// request.getMetadataPrefix() != null) {
// noArguments = false;
// } else if (request.getResumptionToken() != null ||
// request.getSet() != null ||
// request.getUntil() != null) {
//
// noArguments = false;
// } else {
// noArguments = true;
// }
// return noArguments;
// }
//
// /**
// * @return
// */
// public String getFormatField() {
// return this.formatField;
// }
//
// /**
// * @param formatField
// */
// public void setFormatField(String formatField) {
// this.formatField = formatField;
// }
//
// public String getFormatToFilter() {
// return this.formatToFilter;
// }
//
// /**
// * @param formatToFilter
// */
// public void setFormatToFilter(String formatToFilter) {
// this.formatToFilter = formatToFilter;
// }
//
// /**
// * @return
// */
// public String getIdentifierField() {
// return this.identifierField;
// }
//
// /**
// * @param identifierField
// */
// public void setIdentifierField(String identifierField) {
// this.identifierField = identifierField;
// }
//
// /**
// * @return
// */
// public String getRepositoryObjectURIPrefix() {
// return this.repositoryObjectURIPrefix;
// }
//
// /**
// * @param repositoryObjectURIPrefix
// */
// public void setRepositoryObjectURIPrefix(String repositoryObjectURIPrefix) {
// this.repositoryObjectURIPrefix = repositoryObjectURIPrefix;
// }
//
// /**
// * @return
// */
// public String getSpecField() {
// return this.specField;
// }
//
// /**
// * @param titleField
// */
// public void setSpecField(String titleField) {
// this.specField = titleField;
// }
//
// /**
// * @return
// */
// public String getSpecFieldPrefix() {
// return this.specFieldPrefix;
// }
//
// /**
// * @param specFieldPrefix
// */
// public void setSpecFieldPrefix(String specFieldPrefix) {
// this.specFieldPrefix = specFieldPrefix;
// }
//
// /**
// * @return
// */
// public boolean isTextgrid() {
// return this.textgrid;
// }
//
// /**
// * @param textgrid
// */
// public void setTextgrid(boolean textgrid) {
// this.textgrid = textgrid;
// }
//
// /**
// * @return
// */
// public boolean isDariah() {
// return this.dariah;
// }
//
// /**
// * @param dariah
// */
// public void setDariah(boolean dariah) {
// this.dariah = dariah;
// }
//
//}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment