Skip to content

Commit

Permalink
improves collection profile handling
Browse files Browse the repository at this point in the history
* old collection profile data is now deleted before new one is stored
* list of objects from collection profile is now refreshed when entering step create executable plan, fixes #235
  • Loading branch information
kraxner committed Aug 26, 2014
1 parent 6551c05 commit 5cd64dd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Expand Up @@ -224,6 +224,8 @@ public void readProfile(InputStream stream, final String repositoryUser, final S
String name = id + "_" + key + ".xml";

log.info("Storing profile");
CollectionProfile collectionProfile = plan.getSampleRecordsDefinition().getCollectionProfile();

this.storeProfile(name, bsData);

log.info("processing sample objects information");
Expand All @@ -249,7 +251,8 @@ public void readProfile(InputStream stream, final String repositoryUser, final S
profile.setCollectionID(id + "?" + key);
profile.setNumberOfObjects(count);
profile.setTypeOfObjects(typeOfObjects);
this.plan.getSampleRecordsDefinition().setCollectionProfile(profile);
// TODO: confirm: why setting it when it was retrieved 4 lines above?
// this.plan.getSampleRecordsDefinition().setCollectionProfile(profile);
this.plan.getSampleRecordsDefinition().touch();
this.plan.touch();
} catch (Exception e) {
Expand Down Expand Up @@ -297,8 +300,14 @@ private void storeProfile(String name, ByteStream profile) throws PlanningExcept
object.setData(profile);

try {
CollectionProfile collectionProfile = plan.getSampleRecordsDefinition().getCollectionProfile();

// remove the old collection profile file if existent
if (collectionProfile.getProfile() != null) {
bytestreamsToRemove.add(collectionProfile.getProfile().getPid());
}
digitalObjectManager.moveDataToStorage(object);
plan.getSampleRecordsDefinition().getCollectionProfile().setProfile(object);
collectionProfile.setProfile(object);
addedBytestreams.add(object.getPid());
} catch (StorageException e) {
log.error("An error occurred while storing the profile: {}", e);
Expand Down
Expand Up @@ -34,6 +34,7 @@
import eu.scape_project.planning.manager.DigitalObjectManager;
import eu.scape_project.planning.manager.StorageException;
import eu.scape_project.planning.model.DigitalObject;
import eu.scape_project.planning.model.Plan;
import eu.scape_project.planning.model.PlanState;
import eu.scape_project.planning.plato.wf.AbstractWorkflowStep;
import eu.scape_project.planning.plato.wf.CreateExecutablePlan;
Expand Down Expand Up @@ -82,6 +83,12 @@ public CreateExecutablePlanView() {
protected AbstractWorkflowStep getWfStep() {
return createExecutablePlan;
}

@Override
public void init(Plan plan) {
super.init(plan);
collectionProfileElements = null;
}

/**
* Checks if a collection profile is defined for the plan.
Expand Down

0 comments on commit 5cd64dd

Please sign in to comment.