Skip to content

Commit

Permalink
Updated metadata title (sippreview.getname() )
Browse files Browse the repository at this point in the history
  • Loading branch information
sleroux-keep committed Dec 11, 2015
1 parent 093459b commit d3eac25
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/main/java/org/roda/rodain/creation/BagitSipCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import org.roda.rodain.rules.TreeNode;
import org.roda.rodain.rules.sip.SipPreview;
import org.roda.rodain.utils.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -69,7 +70,11 @@ private void createBagit(String schemaId, SipPreview sip) {
b.getBagInfoTxt().put("level", "item");

currentAction = actionCopyingMetadata;
Map<String, String> metadata = getMetadata(sip.getMetadataContent());
String content = sip.getMetadataContent();
content = Utils.replaceTag(content,"#title#",sip.getName());
content = Utils.replaceTag(content,"#date#",new SimpleDateFormat("yyyy-MM-dd").format(new Date()));

Map<String, String> metadata = getMetadata(content);
for (String key : metadata.keySet()) {
if (key.endsWith("title")) {
b.getBagInfoTxt().put("title", metadata.get(key));
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/org/roda/rodain/creation/EarkSipCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.Set;

import org.apache.commons.io.FileUtils;
import org.roda.rodain.rules.TreeNode;
import org.roda.rodain.rules.sip.SipPreview;
import org.roda.rodain.rules.sip.TemplateType;
import org.roda.rodain.utils.Utils;
import org.roda_project.commons_ip.model.SIP;
import org.roda_project.commons_ip.model.SIPDescriptiveMetadata;
import org.roda_project.commons_ip.model.SIPRepresentation;
Expand Down Expand Up @@ -68,7 +71,12 @@ private void createEarkSip(String schemaId, SipPreview sip) {
metadataType = METSEnums.MetadataType.EAD;
}
}
FileUtils.writeStringToFile(new File(home + metadataName), sip.getMetadataContent());

String content = sip.getMetadataContent();
content = Utils.replaceTag(content,"#title#",sip.getName());
content = Utils.replaceTag(content,"#date#",new SimpleDateFormat("yyyy-MM-dd").format(new Date()));

FileUtils.writeStringToFile(new File(home + metadataName), content);
SIPDescriptiveMetadata metadata = new SIPDescriptiveMetadata(Paths.get(home + metadataName), null, metadataType);
earkSip.addDescriptiveMetadata(metadata);

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/roda/rodain/rules/sip/SipMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ private void loadMetadata() {
InputStream contentStream = ClassLoader.getSystemResource(fileName).openStream();
content = Utils.convertStreamToString(contentStream);
//TODO configurable tags maybe...
content = Utils.replaceTag(content,"#title#",fileName);
content = Utils.replaceTag(content,"#date#",new SimpleDateFormat("yyyy-MM-dd").format(new Date()));

contentStream.close();
loaded = true;
}
Expand Down

0 comments on commit d3eac25

Please sign in to comment.