Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dataset extension #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public Dataset build(DatasetFacade facade) {
return toSubmit;
}

private List<CitationField> createFields(DatasetFacade facade, Citation citation) {
protected List<CitationField> createFields(DatasetFacade facade, Citation citation) {
List<CitationField> fields = new ArrayList<>();
//mandatory fields
addTitle(facade, fields);
Expand Down Expand Up @@ -117,62 +117,62 @@ private List<CitationField> createFields(DatasetFacade facade, Citation citation



private void addProductionDate(DatasetFacade facade, List<CitationField> fields) {
protected void addProductionDate(DatasetFacade facade, List<CitationField> fields) {
if( facade.getProductionDate() != null) {
CitationField prodDate = createPrimitiveSingleField("productionDate", isoDate(facade.getProductionDate()));
fields.add(prodDate);
}
}

private void addProductionPlace(DatasetFacade facade, List<CitationField> fields) {
protected void addProductionPlace(DatasetFacade facade, List<CitationField> fields) {
if(!isEmpty(facade.getProductionPlace())){
CitationField prodPlace = createPrimitiveSingleField("productionPlace", facade.getProductionPlace());
fields.add(prodPlace);
}
}


private void addLanguages(DatasetFacade facade, List<CitationField> fields) {
protected void addLanguages(DatasetFacade facade, List<CitationField> fields) {
if (!facade.getLanguages().isEmpty()) {
CitationField field = createControlledVocabField("language", true, facade.getLanguages());
fields.add(field);
}
}

private void addNotes(DatasetFacade facade, List<CitationField> fields) {
protected void addNotes(DatasetFacade facade, List<CitationField> fields) {
if(!isEmpty(facade.getNote())){
CitationField altUrl = createPrimitiveSingleField("notesText", facade.getNote());
fields.add(altUrl);
}
}

private void addAlternativeURL(DatasetFacade facade, List<CitationField> fields) {
protected void addAlternativeURL(DatasetFacade facade, List<CitationField> fields) {
if (facade.getAlternativeURL() != null) {
CitationField altUrl = createPrimitiveSingleField("alternativeURL", facade.getAlternativeURL().toString());
fields.add(altUrl);
}
}

private void addAlternativeTitle(DatasetFacade facade, List<CitationField> fields) {
protected void addAlternativeTitle(DatasetFacade facade, List<CitationField> fields) {
if (!isEmpty(facade.getAlternativeTitle())) {
CitationField title = createPrimitiveSingleField("alternativeTitle", facade.getAlternativeTitle());
fields.add(title);
}
}

private void addSubTitle(DatasetFacade facade, List<CitationField> fields) {
protected void addSubTitle(DatasetFacade facade, List<CitationField> fields) {
if (!isEmpty(facade.getSubtitle())) {
CitationField subtitle = createPrimitiveSingleField("subtitle", facade.getSubtitle());
fields.add(subtitle);
}
}

private void addSubject(DatasetFacade facade, List<CitationField> fields) {
protected void addSubject(DatasetFacade facade, List<CitationField> fields) {
CitationField subject = createControlledVocabField("subject", true, Arrays.asList(facade.getSubject()));
fields.add(subject);
}

private void addDescription(DatasetFacade facade, List<CitationField> fields) {
protected void addDescription(DatasetFacade facade, List<CitationField> fields) {
List<DatasetDescription> descs = facade.getDescriptions();
List<Map<String, Object>> descList = new ArrayList<>();
for (DatasetDescription desc: descs) {
Expand All @@ -190,7 +190,7 @@ private void addDescription(DatasetFacade facade, List<CitationField> fields) {
fields.add(desc);
}

private void addTopicClassifications(DatasetFacade facade, List<CitationField> fields) {
protected void addTopicClassifications(DatasetFacade facade, List<CitationField> fields) {
List<DatasetTopicClassification> topics = facade.getTopicClassifications();
List<Map<String, Object>> topicsList = new ArrayList<>();
for (DatasetTopicClassification topic: topics) {
Expand All @@ -204,7 +204,7 @@ private void addTopicClassifications(DatasetFacade facade, List<CitationField> f
fields.add(topicClassifn);
}

private void addProducers(DatasetFacade facade, List<CitationField> fields) {
protected void addProducers(DatasetFacade facade, List<CitationField> fields) {
List<DatasetProducer> topics = facade.getProducers();
List<Map<String, Object>> topicsList = new ArrayList<>();
for (DatasetProducer topic: topics) {
Expand All @@ -220,7 +220,7 @@ private void addProducers(DatasetFacade facade, List<CitationField> fields) {
fields.add(topicClassifn);
}

private void addContributor(DatasetFacade facade, List<CitationField> fields) {
protected void addContributor(DatasetFacade facade, List<CitationField> fields) {
List<DatasetContributor> contribs = facade.getContributors();
List<Map<String, Object>> contribList = new ArrayList<>();
for (DatasetContributor contrib: contribs) {
Expand All @@ -237,7 +237,7 @@ private void addContributor(DatasetFacade facade, List<CitationField> fields) {
fields.add(topicClassifn);
}

private void addPublications(DatasetFacade facade, List<CitationField> fields) {
protected void addPublications(DatasetFacade facade, List<CitationField> fields) {
List<DatasetPublication> publications = facade.getPublications();
List<Map<String, Object>> list = new ArrayList<>();
for (DatasetPublication publication: publications) {
Expand All @@ -256,7 +256,7 @@ private void addPublications(DatasetFacade facade, List<CitationField> fields) {
fields.add(publication);
}

private void addKeywords(DatasetFacade facade, List<CitationField> fields) {
protected void addKeywords(DatasetFacade facade, List<CitationField> fields) {
List<DatasetKeyword> keywords = facade.getKeywords();
List<Map<String, Object>> keysList = new ArrayList<>();
for (DatasetKeyword keyword: keywords) {
Expand All @@ -273,11 +273,11 @@ private void addKeywords(DatasetFacade facade, List<CitationField> fields) {

}

private String isoDate(Date date) {
protected String isoDate(Date date) {
return String.format("%tF", date);
}

private void addContacts (DatasetFacade facade, List<CitationField> fields) {
protected void addContacts (DatasetFacade facade, List<CitationField> fields) {
List<DatasetContact> contacts = facade.getContacts();
List<Map<String, Object>> contactsList = new ArrayList<>();
for (DatasetContact contact : contacts) {
Expand All @@ -292,7 +292,7 @@ private void addContacts (DatasetFacade facade, List<CitationField> fields) {
fields.add(contact);
}

private void addAuthors (DatasetFacade facade, List<CitationField> fields) {
protected void addAuthors (DatasetFacade facade, List<CitationField> fields) {
List<DatasetAuthor> authors = facade.getAuthors();
List<Map<String, Object>> authorsMap = new ArrayList<>();
for (DatasetAuthor author : authors) {
Expand All @@ -313,19 +313,19 @@ private void addAuthors (DatasetFacade facade, List<CitationField> fields) {
fields.add(toAdd);
}

private void addOptionalPrimitiveField(String value, Map<String, Object> map, String field) {
protected void addOptionalPrimitiveField(String value, Map<String, Object> map, String field) {
if (!isEmpty(value)) {
CitationField affil = createPrimitiveSingleField(field, value);
map.put(field, affil);
}
}

private void addTitle(DatasetFacade facade, List<CitationField> fields) {
protected void addTitle(DatasetFacade facade, List<CitationField> fields) {
CitationField title = createPrimitiveSingleField("title", facade.getTitle());
fields.add(title);
}

private void addDepositor(DatasetFacade facade, List<CitationField> fields) {
protected void addDepositor(DatasetFacade facade, List<CitationField> fields) {
CitationField deposit = createPrimitiveSingleField("depositor", facade.getDepositor());
fields.add(deposit);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void configure(DataverseConfig config) {
setServerURL(config.getServerURL().toString());
}

<T> void handleError(ResponseEntity<DataverseResponse<T>> resp) {
protected <T> void handleError(ResponseEntity<DataverseResponse<T>> resp) {
log.debug("{}", resp.getBody());
if (RestUtil.isError(resp.getStatusCode())) {
String msg = String.format("Error code returned %d with message [%s]", resp.getStatusCodeValue(),
Expand All @@ -83,7 +83,7 @@ RestTemplate createTemplate() {
return template;
}

String createV1Url(String ... pathComponents) {
protected String createV1Url(String ... pathComponents) {
String url = serverAPIv1URL + "/" + StringUtils.join(pathComponents, "/") ;
log.info("URL is {}", url);
return url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,18 +276,18 @@ public DvMessage deleteDataset(Identifier dsIdentifier) {
return resp.getBody().getData();
}

private HttpEntity<String> createHttpEntity(String body) {
protected HttpEntity<String> createHttpEntity(String body) {
HttpHeaders headers = addAPIKeyToHeader();
HttpEntity<String> entity = new HttpEntity<String>(body, headers);
return entity;
}

private String getJsonFromFacade(DatasetFacade facade) {
protected String getJsonFromFacade(DatasetFacade facade) {
Dataset dataset = new DatasetBuilder().build(facade);
return marshalDataset(dataset);
}

private String marshalDataset(Object object) {
protected String marshalDataset(Object object) {
ObjectMapper mapper = new ObjectMapper();
String json = "";
try {
Expand Down