Including `publication_date` bug fixing [#26166]
This commit is contained in:
parent
88975d12f4
commit
114c753ca4
|
@ -258,6 +258,8 @@ public class BasicInformationView extends Composite implements FormValidator {
|
|||
field_description.setValue(zenodoItem.getMetadata().getDescription());
|
||||
InfoTextAndLabels.addTooltipForFieldKey("description", cl_description);
|
||||
field_doi.setValue(zenodoItem.getDoi());
|
||||
|
||||
GWT.log("Filling form with: "+zenodoItem.getMetadata());
|
||||
|
||||
ZenodoMetadata zMeta = zenodoItem.getMetadata();
|
||||
if (zMeta != null) {
|
||||
|
|
|
@ -123,6 +123,9 @@ public class Ckan2ZenodoViewManager {
|
|||
meta.setDescription(basicForm.getField_description().getValue());
|
||||
meta.setKeywords(basicForm.getTags()); // these are the keywords
|
||||
|
||||
//Setting publication date fxing #26166
|
||||
meta.setPublication_date(basicForm.getField_publication_date().getValue());
|
||||
|
||||
List<ZenodoCreator> creators = basicForm.getListOfCreators();
|
||||
GWT.log("Read creators from FORM: "+creators);
|
||||
meta.setCreators(creators);
|
||||
|
|
|
@ -64,6 +64,8 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
|||
PortalUtils.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
PortalUtils.getCurrentToken(this.getThreadLocalRequest(), true);
|
||||
}
|
||||
|
||||
LOG.debug("publishOnZenodo called with metadata: "+zenodoItem.getMetadata());
|
||||
|
||||
Ckan2Zenodo client = new Ckan2ZenodoImpl();
|
||||
// Get the item representation
|
||||
|
|
|
@ -1,20 +1,102 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.ws.rs.client.Entity;
|
||||
|
||||
import org.gcube.data.publishing.ckan2zenodo.Fixer;
|
||||
import org.gcube.data.publishing.ckan2zenodo.model.faults.ZenodoException;
|
||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata;
|
||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.ZenodoDeposition;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
|
||||
public class Tester {
|
||||
|
||||
public static String expression = "^\\/dataset(\\?([a-zA-Z0-9_.-]*.+))*";
|
||||
public static String toMatch = "/dataset?systemtype=E39_Actor&groups=huma_num___nakala";
|
||||
|
||||
private static ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
static {
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false);
|
||||
mapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false);
|
||||
mapper.setSerializationInclusion(Include.NON_NULL);
|
||||
// mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// Pattern p = Pattern.compile(expression);
|
||||
// Matcher m = p.matcher(toMatch);
|
||||
// boolean b = m.matches();
|
||||
//
|
||||
// System.out.println(b);
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
Pattern p = Pattern.compile(expression);
|
||||
Matcher m = p.matcher(toMatch);
|
||||
boolean b = m.matches();
|
||||
|
||||
System.out.println(b);
|
||||
|
||||
//ObjectMapper mapper = new ObjectMapper();
|
||||
ZenodoDeposition zed = new ZenodoDeposition();
|
||||
DepositionMetadata metadata = new DepositionMetadata();
|
||||
metadata.setPublication_date(Date.from(Instant.now()));
|
||||
//zed.setMetadata(metadata);
|
||||
|
||||
String serialized;
|
||||
try {
|
||||
System.out.println("init json: "+mapper.writeValueAsString(metadata));
|
||||
|
||||
serialized = "{\"metadata\":"+Fixer.fixIncoming(mapper.writeValueAsString(metadata))+"}";
|
||||
System.out.println("serialized: "+serialized);
|
||||
|
||||
Entity<String> JSON = Entity.json(serialized);
|
||||
System.out.println("JSON: "+JSON);
|
||||
ZenodoDeposition object = mapper.readValue(Fixer.fixIncoming(serialized), ZenodoDeposition.class);
|
||||
System.out.println("ZenodoDeposition: "+object);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//System.out.println(metadata.getPublication_date());
|
||||
|
||||
// try {
|
||||
// updateMetadata(metadata);
|
||||
// } catch (ZenodoException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
private static ZenodoDeposition updateMetadata(DepositionMetadata meta) throws ZenodoException {
|
||||
try{
|
||||
String serialized="{\"metadata\":"+Fixer.fixIncoming(mapper.writeValueAsString(meta))+"}";
|
||||
System.out.println("serialized: "+serialized);
|
||||
try {
|
||||
// Response resp = getWebClient().target(credentials.getBaseUrl()).
|
||||
// path(DEPOSITION_BASE_URL).path(depositionId+"").
|
||||
// queryParam(ACCESS_TOKEN, credentials.getKey()).request(CONTENT_TYPE)
|
||||
// .put(Entity.json(serialized));
|
||||
// return check(resp,ZenodoDeposition.class);
|
||||
|
||||
Entity<String> JSON = Entity.json(serialized);
|
||||
System.out.println("JSON: "+JSON);
|
||||
return mapper.readValue(Fixer.fixIncoming(serialized), ZenodoDeposition.class);
|
||||
}catch(Throwable t) {
|
||||
System.out.println("Error while tryin to update "+serialized);
|
||||
return null;
|
||||
}
|
||||
}catch(JsonProcessingException e) {
|
||||
System.out.println("Error while parsing "+meta + " " +e);
|
||||
throw new ZenodoException("Internal error.",e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue