Skip to content
Snippets Groups Projects
Commit db143b7d authored by pkupczyk's avatar pkupczyk
Browse files

SSDM-1618 : CKAN - publication web app improvements:

- maintainer_email
- dc:date

SVN: 33688
parent 9569766b
No related branches found
No related tags found
No related merge requests found
Showing with 89 additions and 21 deletions
......@@ -19,6 +19,7 @@ package ch.systemsx.cisd.etlserver.registrator.api.v2.impl;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedBasicOpenBISService;
......@@ -89,8 +90,20 @@ public class DataSetImmutable extends AbstractDataSetImmutable
{
throw new UnsupportedOperationException(message);
}
@Override
public Date getModificationDate()
{
return null;
}
@Override
public Date getRegistrationDate()
{
return null;
}
}
protected final AbstractExternalData dataSet;
public DataSetImmutable(AbstractExternalData dataSet, IEncapsulatedBasicOpenBISService service)
......
......@@ -16,6 +16,8 @@
package ch.systemsx.cisd.etlserver.registrator.api.v2.impl;
import java.util.Date;
import ch.systemsx.cisd.common.exceptions.UserFailureException;
import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v2.IExperimentImmutable;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.id.IObjectId;
......@@ -97,6 +99,18 @@ public class ExperimentImmutable implements IExperimentImmutable
return experiment.getPermId();
}
@Override
public Date getRegistrationDate()
{
return experiment.getRegistrationDate();
}
@Override
public Date getModificationDate()
{
return experiment.getModificationDate();
}
@Override
public int hashCode()
{
......
......@@ -16,6 +16,8 @@
package ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v2;
import java.util.Date;
/**
* Read-only interface to an existing experiment.
*
......@@ -39,8 +41,7 @@ public interface IExperimentImmutable extends IMetaprojectContent
String getExperimentType();
/**
* Return the value of a property specified by a code. May return null of no such property with
* code <code>propertyCode</code> is found.
* Return the value of a property specified by a code. May return null of no such property with code <code>propertyCode</code> is found.
*/
String getPropertyValue(String propertyCode);
......@@ -48,4 +49,14 @@ public interface IExperimentImmutable extends IMetaprojectContent
* Returns the permId of this experiment.
*/
String getPermId();
/**
* Returns the registration date of this experiment.
*/
Date getRegistrationDate();
/**
* Returns the modification date of this experiment.
*/
Date getModificationDate();
}
......@@ -15,6 +15,7 @@ from ch.systemsx.cisd.openbis.generic.shared.api.v1.dto import SearchCriteria
from ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria import MatchClause, MatchClauseAttribute, MatchClauseTimeAttribute, CompareMode
DATE_FORMAT = SimpleDateFormat("yyyy-MM-dd")
DATE_FORMAT_WITH_TIME = SimpleDateFormat("yyyy-MM-dd HH:mm")
TIME_ZONE = "0"
PUBLICATION_EXPERIMENT_TYPE = "PUBLICATION"
......@@ -105,7 +106,7 @@ def createExperimentMetadata(experiment):
["dc:identifier" , "PUBLICATION_ID"],
["dc:title" , "PUBLICATION_TITLE"],
["dc:creator" , "PUBLICATION_AUTHOR"],
["creator_email" , "PUBLICATION_AUTHOR_EMAIL"],
["maintainer_email" , "PUBLICATION_AUTHOR_EMAIL"],
["dc:description" , "PUBLICATION_NOTES"],
["dc:rights" , "PUBLICATION_LICENSE"]
]
......@@ -121,8 +122,11 @@ def createExperimentMetadata(experiment):
subjectNode = ET.SubElement(oai, "dc:subject")
subjectNode.text = meshTerm.strip()
identifierNode = ET.SubElement(oai, "dc:source")
identifierNode.text = getServerUrl() + "/openbis/?viewMode=SIMPLE#entity=EXPERIMENT&permId=" + str(experiment.getPermId())
sourceNode = ET.SubElement(oai, "dc:source")
sourceNode.text = getServerUrl() + "/openbis/?viewMode=SIMPLE#entity=EXPERIMENT&permId=" + str(experiment.getPermId())
dateNode = ET.SubElement(oai, "dc:date")
dateNode.text = DATE_FORMAT_WITH_TIME.format(experiment.getRegistrationDate())
return Metadata(ET.tostring(oai))
......
......@@ -18,6 +18,7 @@ package ch.ethz.sis.openbis.oai_pmh.systemtests;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
......@@ -36,8 +37,12 @@ import org.testng.mustache.Mustache;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.experiment.Experiment;
import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.experiment.ExperimentCreation;
import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.experiment.ExperimentFetchOptions;
import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.entitytype.EntityTypePermId;
import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.experiment.ExperimentPermId;
import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.experiment.IExperimentId;
import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.project.ProjectIdentifier;
import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel;
import ch.systemsx.cisd.common.http.HttpTest;
......@@ -50,7 +55,11 @@ import ch.systemsx.cisd.openbis.generic.shared.util.TestInstanceHostUtils;
public class PublishServletTest extends OAIPMHSystemTest
{
private Map<String, Publication> publications = new LinkedHashMap<String, Publication>();
private static final SimpleDateFormat DATE_WITH_TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm");
private Map<String, Publication> publicationsMap = new LinkedHashMap<String, Publication>();
private Map<String, Experiment> experimentsMap = new LinkedHashMap<String, Experiment>();
private TestResources resources = new TestResources(getClass());
......@@ -81,11 +90,19 @@ public class PublishServletTest extends OAIPMHSystemTest
Object[] resultAndError = publish(adminUserSessionToken, publication);
String permId = (String) resultAndError[0];
String error = (String) resultAndError[1];
waitUntilIndexUpdaterIsIdle();
publications.put((String) resultAndError[0], publication);
Map<IExperimentId, Experiment> experiments =
getApplicationServerApi().mapExperiments(adminUserSessionToken, Arrays.asList(new ExperimentPermId(permId)),
new ExperimentFetchOptions());
publicationsMap.put(permId, publication);
experimentsMap.put(permId, experiments.values().iterator().next());
Assert.assertNull(resultAndError[1]);
Assert.assertNull(error);
}
@Test
......@@ -102,9 +119,12 @@ public class PublishServletTest extends OAIPMHSystemTest
List<Record> records = new ArrayList<Record>();
int i = 0;
for (String permId : publications.keySet())
for (String permId : publicationsMap.keySet())
{
records.add(new Record(permId, datestamps.get(i)));
Record record = new Record();
record.IDENTIFIER = permId;
record.DATESTAMP = datestamps.get(i);
records.add(record);
i++;
}
templateValues.put("RECORDS", records);
......@@ -128,9 +148,14 @@ public class PublishServletTest extends OAIPMHSystemTest
List<Record> records = new ArrayList<Record>();
int i = 0;
for (String permId : publications.keySet())
for (String permId : publicationsMap.keySet())
{
records.add(new Record(permId, datestamps.get(i)));
Experiment experiment = experimentsMap.get(permId);
Record record = new Record();
record.IDENTIFIER = permId;
record.DATESTAMP = datestamps.get(i);
record.REGISTRATION_DATE = DATE_WITH_TIME_FORMAT.format(experiment.getRegistrationDate());
records.add(record);
i++;
}
templateValues.put("RECORDS", records);
......@@ -142,7 +167,7 @@ public class PublishServletTest extends OAIPMHSystemTest
@Test
public void testGetRecord() throws IOException, SAXException
{
String identifier = publications.keySet().iterator().next();
String identifier = publicationsMap.keySet().iterator().next();
GetMethod response =
callServlet(REVIEWER_USER_ID, REVIEWER_USER_PASSWORD, "verb=GetRecord&metadataPrefix=oai_dc&identifier=" + identifier);
......@@ -151,10 +176,13 @@ public class PublishServletTest extends OAIPMHSystemTest
String responseDate = HttpTest.evaluateToString(document, "/OAI-PMH/responseDate");
String datestamp = HttpTest.evaluateToString(document, "/OAI-PMH/GetRecord/record/header/datestamp");
Experiment experiment = experimentsMap.get(identifier);
Map<String, Object> templateValues = new HashMap<String, Object>();
templateValues.put("RESPONSE_DATE", responseDate);
templateValues.put("IDENTIFIER", identifier);
templateValues.put("DATESTAMP", datestamp);
templateValues.put("REGISTRATION_DATE", DATE_WITH_TIME_FORMAT.format(experiment.getRegistrationDate()));
String expectedResponse = getFilledTemplate("testGetRecord.xml", templateValues);
assertResponse(response.getResponseBodyAsString(), expectedResponse);
......@@ -193,11 +221,7 @@ public class PublishServletTest extends OAIPMHSystemTest
public String DATESTAMP;
public Record(String IDENTIFIER, String DATESTAMP)
{
this.IDENTIFIER = IDENTIFIER;
this.DATESTAMP = DATESTAMP;
}
public String REGISTRATION_DATE;
}
......
......@@ -16,13 +16,14 @@
<dc:identifier>Some publication Id</dc:identifier>
<dc:title>Some publication Title</dc:title>
<dc:creator>Some author</dc:creator>
<creator_email>some@authoremail.com</creator_email>
<maintainer_email>some@authoremail.com</maintainer_email>
<dc:description>Some notes</dc:description>
<dc:rights>NONE</dc:rights>
<dc:subject>Viruses;B04</dc:subject>
<dc:source>
{{SERVER_URL}}/openbis/?viewMode=SIMPLE#entity=EXPERIMENT&amp;permId={{IDENTIFIER}}
</dc:source>
<dc:date>{{REGISTRATION_DATE}}</dc:date>
</oai_dc:dc>
</metadata>
</record>
......
......@@ -16,13 +16,14 @@
<dc:identifier>Some publication Id</dc:identifier>
<dc:title>Some publication Title</dc:title>
<dc:creator>Some author</dc:creator>
<creator_email>some@authoremail.com</creator_email>
<maintainer_email>some@authoremail.com</maintainer_email>
<dc:description>Some notes</dc:description>
<dc:rights>NONE</dc:rights>
<dc:subject>Viruses;B04</dc:subject>
<dc:source>
{{SERVER_URL}}/openbis/?viewMode=SIMPLE#entity=EXPERIMENT&amp;permId={{IDENTIFIER}}
</dc:source>
<dc:date>{{REGISTRATION_DATE}}</dc:date>
</oai_dc:dc>
</metadata>
</record>
......
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