Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

tool work flow refactored up to and including capture to METS structu…

…re map.

decorators in the arrangement are working again
addressed project scope preference persistence issues w/using the settings folder
  • Loading branch information...
commit 3816411c7711006275015d2b4716461898c4c60c 1 parent a933f64
Gregory Jansen gregjan authored
Showing with 408 additions and 610 deletions.
  1. +2 −2 mets.model/src/gov/loc/mets/util/METSUtils.java
  2. +15 −83 workbench_plugin/plugin.xml
  3. +7 −11 workbench_plugin/src/main/java/unc/lib/cdr/workbench/SelectionPropertyTester.java
  4. +4 −3 workbench_plugin/src/main/java/unc/lib/cdr/workbench/arrange/ArrangementCommonDropAdapterAssistant.java
  5. +8 −7 workbench_plugin/src/main/java/unc/lib/cdr/workbench/arrange/ArrangementDropListener.java
  6. +4 −38 workbench_plugin/src/main/java/unc/lib/cdr/workbench/arrange/DivAdapterFactory.java
  7. +2 −65 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/CaptureHandler.java
  8. +64 −92 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/CaptureJob.java
  9. +4 −4 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalsContentProvider.java
  10. +126 −133 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalsDecorator.java
  11. +4 −4 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalsLabelProvider.java
  12. +5 −18 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalsLinkJob.java
  13. +9 −3 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalsPropertyTester.java
  14. +2 −2 workbench_plugin/src/main/java/unc/lib/cdr/workbench/commands/OpenSystemEditorTempCopyHandler.java
  15. +27 −22 ...in/src/main/java/unc/lib/cdr/workbench/originals/{OriginalsWrapperStore.java → OriginalFileStore.java}
  16. +5 −5 workbench_plugin/src/main/java/unc/lib/cdr/workbench/originals/{Original.java → OriginalStub.java}
  17. +6 −7 ...main/java/unc/lib/cdr/workbench/originals/{OriginalsWrapperFileSystem.java → OriginalsFileSystem.java}
  18. +63 −61 workbench_plugin/src/main/java/unc/lib/cdr/workbench/project/MetsProjectNature.java
  19. +12 −17 workbench_plugin/src/main/java/unc/lib/cdr/workbench/project/ProjectEMFSession.java
  20. +5 −5 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/HasOriginalFilter.java
  21. +8 −8 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/HasStagedFileFilter.java
  22. +2 −2 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/LabelImageFactory.java
  23. +3 −3 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/OriginalFingerprintSection.java
  24. +7 −7 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/OriginalResourcePropertySheetSection.java
  25. +14 −8 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/OriginalVolumeSection.java
4 mets.model/src/gov/loc/mets/util/METSUtils.java
View
@@ -202,9 +202,9 @@ public static DivType findBagDiv(MetsType m) {
* the original IFile
* @return the file element
*/
- public static FileType addFile(MetsType mets, URI originalData, long size, String md5) {
+ public static FileType addFile(MetsType mets, URI originalData, String xmlid, long size, String md5) {
FileType f = MetsFactory.eINSTANCE.createFileType();
- f.setID(makeXMLUUID());
+ f.setID(xmlid);
if (md5 != null) {
f.setCHECKSUMTYPE(CHECKSUMTYPEType.MD5);
98 workbench_plugin/plugin.xml
View
@@ -7,8 +7,8 @@
class="unc.lib.cdr.workbench.capture.OriginalsPropertyTester"
id="cdr-workbench.propertyTesterOriginals"
namespace="cdr-workbench"
- properties="staged,captured"
- type="org.eclipse.core.resources.IResource">
+ properties="staged,captured,isFile"
+ type="unc.lib.cdr.workbench.originals.OriginalFileStore">
</propertyTester>
<propertyTester
class="unc.lib.cdr.workbench.xwalk.MetadataSourcePropertyTester"
@@ -42,7 +42,7 @@
class="unc.lib.cdr.workbench.SelectionPropertyTester"
id="workbench_plugin.selectionTester"
namespace="workbench_plugin.selection"
- properties="hasDivLinkPotential,siblingIResources"
+ properties="hasDivLinkPotential,siblingOriginals"
type="org.eclipse.jface.viewers.ISelection">
</propertyTester>
</extension>
@@ -247,14 +247,6 @@
</activeWhen>
<class
class="org.eclipse.ui.internal.views.markers.DeleteHandler"></class>
- <enabledWhen>
- <not>
- <test
- property="workbench_plugin.testTopFolderName.folderName"
- value=".originals">
- </test>
- </not>
- </enabledWhen>
</handler>
</extension>
<extension
@@ -353,13 +345,13 @@
<iterate
ifEmpty="false">
<and>
- <test
- property="workbench_plugin.testTopFolderName.folderName"
- value="&apos;.originals&apos;">
- </test>
<instanceof
- value="org.eclipse.core.resources.IFile">
+ value="unc.lib.cdr.workbench.originals.OriginalFileStore">
</instanceof>
+ <test
+ property="cdr-workbench.isFile"
+ value="true">
+ </test>
</and>
</iterate>
</with>
@@ -376,9 +368,6 @@
<iterate
ifEmpty="false">
<or>
- <instanceof
- value="unc.lib.cdr.workbench.capture.OriginalFoldersProjectElement">
- </instanceof>
<and>
<instanceof
value="org.eclipse.core.resources.IResource">
@@ -411,21 +400,14 @@
variable="activeMenuSelection">
<and>
<test
- property="workbench_plugin.selection.siblingIResources">
+ property="workbench_plugin.selection.siblingOriginals">
</test>
<iterate
ifEmpty="false">
<and>
- <test
- property="workbench_plugin.testTopFolderName.folderName"
- value=".originals">
- </test>
<or>
<instanceof
- value="org.eclipse.core.resources.IFolder">
- </instanceof>
- <instanceof
- value="org.eclipse.core.resources.IFile">
+ value="unc.lib.cdr.workbench.originals.OriginalFileStore">
</instanceof>
</or>
</and>
@@ -695,9 +677,6 @@
<iterate
ifEmpty="false">
<or>
- <instanceof
- value="unc.lib.cdr.workbench.capture.OriginalFoldersProjectElement">
- </instanceof>
<and>
<instanceof
value="org.eclipse.core.resources.IProject">
@@ -888,7 +867,7 @@
adaptableType="gov.loc.mets.DivType"
class="unc.lib.cdr.workbench.arrange.DivAdapterFactory">
<adapter
- type="org.eclipse.core.resources.IResource">
+ type="unc.lib.cdr.workbench.originals.OriginalFileStore">
</adapter>
</factory>
</extension>
@@ -1040,20 +1019,6 @@
</objectContribution>
</extension>
<extension
- id="unc.lib.cdr.workbench.markers.OriginalFileSet"
- name="Original File Set"
- point="org.eclipse.core.resources.markers">
- <persistent
- value="true">
- </persistent>
- <attribute
- name="type">
- </attribute>
- <attribute
- name="prestagedBase">
- </attribute>
- </extension>
- <extension
point="org.eclipse.ui.navigator.viewer">
<viewer
viewerId="cdr-workbench.projectview">
@@ -1185,7 +1150,7 @@
value="org.eclipse.core.resources.IResource">
</instanceof>
<instanceof
- value="unc.lib.cdr.workbench.originals.Original">
+ value="unc.lib.cdr.workbench.originals.OriginalStub">
</instanceof>
</or>
</possibleChildren>
@@ -1328,39 +1293,6 @@
</commonFilter>
</extension>
<extension
- id="unc.lib.cdr.workbench.markers.Captured"
- name="captured"
- point="org.eclipse.core.resources.markers">
- <attribute
- name="mets.Div.ID">
- </attribute>
- <persistent
- value="true">
- </persistent>
- </extension>
- <extension
- id="unc.lib.cdr.workbench.markers.Staged"
- name="staged"
- point="org.eclipse.core.resources.markers">
- <persistent
- value="true">
- </persistent>
- <attribute
- name="stage.uri">
- </attribute>
- </extension>
- <extension
- id="unc.lib.cdr.workbench.markers.Filed"
- name="filed"
- point="org.eclipse.core.resources.markers">
- <persistent
- value="true">
- </persistent>
- <attribute
- name="mets.File.ID">
- </attribute>
- </extension>
- <extension
point="org.eclipse.ui.decorators">
<decorator
class="unc.lib.cdr.workbench.capture.OriginalsDecorator"
@@ -1372,7 +1304,7 @@
<enablement>
<or>
<objectClass
- name="org.eclipse.core.resources.IResource">
+ name="unc.lib.cdr.workbench.originals.OriginalFileStore">
</objectClass>
<objectClass
name="gov.loc.mets.DivType">
@@ -1704,7 +1636,7 @@
<filesystem
scheme="ro+file">
<run
- class="unc.lib.cdr.workbench.originals.OriginalsWrapperFileSystem">
+ class="unc.lib.cdr.workbench.originals.OriginalsFileSystem">
</run>
</filesystem>
</extension>
@@ -1713,7 +1645,7 @@
<filesystem
scheme="ro+irods">
<run
- class="unc.lib.cdr.workbench.originals.OriginalsWrapperFileSystem">
+ class="unc.lib.cdr.workbench.originals.OriginalsFileSystem">
</run>
</filesystem>
</extension>
18 workbench_plugin/src/main/java/unc/lib/cdr/workbench/SelectionPropertyTester.java
View
@@ -7,23 +7,19 @@
import java.util.Collection;
import org.eclipse.core.expressions.PropertyTester;
-import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import unc.lib.cdr.workbench.originals.OriginalFileStore;
import unc.lib.cdr.workbench.project.MetsProjectNature;
-import unc.lib.cdr.workbench.rcp.Activator;
public class SelectionPropertyTester extends PropertyTester {
public static final String IS_DIV_LINK_PAIR = "isDivLinkPair";
public static final String HAS_DIV_LINK_POTENTIAL = "hasDivLinkPotential";
- public static final String SIBLING_IRESOURCES = "siblingIResources";
+ public static final String SIBLING_ORIGINALS = "siblingOriginals";
public SelectionPropertyTester() {
- // TODO Auto-generated constructor stub
}
@Override
@@ -94,20 +90,20 @@ public boolean test(Object receiver, String property, Object[] args, Object expe
}
}
}
- } else if(SIBLING_IRESOURCES.equals(property)) {
+ } else if(SIBLING_ORIGINALS.equals(property)) {
//System.out.println("checking siblings");
if (receiver instanceof ISelection) {
ISelection s = (ISelection) receiver;
if (s instanceof IStructuredSelection) {
IStructuredSelection struct = (IStructuredSelection) s;
if(struct.size() > 0) {
- if(struct.getFirstElement() instanceof IResource) {
- IContainer c = ((IResource)struct.getFirstElement()).getParent();
+ if(struct.getFirstElement() instanceof OriginalFileStore) {
+ OriginalFileStore c = (OriginalFileStore)((OriginalFileStore)struct.getFirstElement()).getParent();
for(Object r : struct.toArray()) {
- if(!(r instanceof IResource)) {
+ if(!(r instanceof OriginalFileStore)) {
return false;
}
- if(!(c.equals(((IResource)r).getParent()))) {
+ if(!(c.equals((OriginalFileStore)((OriginalFileStore)r).getParent()))) {
System.out.println("not the same parent");
return false;
}
7 workbench_plugin/src/main/java/unc/lib/cdr/workbench/arrange/ArrangementCommonDropAdapterAssistant.java
View
@@ -45,6 +45,7 @@
import org.slf4j.LoggerFactory;
import unc.lib.cdr.workbench.capture.CaptureJob;
+import unc.lib.cdr.workbench.originals.OriginalFileStore;
import unc.lib.cdr.workbench.project.MetsProjectNature;
public class ArrangementCommonDropAdapterAssistant extends CommonDropAdapterAssistant {
@@ -118,8 +119,8 @@ public IStatus handleDrop(CommonDropAdapter aDropAdapter, DropTargetEvent event,
//LOG.debug("selection: " + select);
List items = select.toList();
if (items.size() > 0) {
- if (items.get(0) instanceof IResource) {
- return dropResources(items);
+ if (items.get(0) instanceof OriginalFileStore) {
+ return dropOriginals(items);
} else if (items.get(0) instanceof DivType) {
return dropDivs(items);
} else if (items.get(0) instanceof MdSecType) {
@@ -272,7 +273,7 @@ private void insertOrMoveAll(List<DivType> items, DivType dest, int index) {
}
}
- private IStatus dropResources(List<IResource> items) {
+ private IStatus dropOriginals(List<OriginalFileStore> items) {
//LOG.debug("dropping Resources");
CaptureJob job = null;
Object target = getCommonDropAdapter().getCurrentTarget();
15 workbench_plugin/src/main/java/unc/lib/cdr/workbench/arrange/ArrangementDropListener.java
View
@@ -46,6 +46,7 @@
import org.slf4j.LoggerFactory;
import unc.lib.cdr.workbench.capture.CaptureJob;
+import unc.lib.cdr.workbench.originals.OriginalFileStore;
import unc.lib.cdr.workbench.project.MetsProjectNature;
/**
@@ -107,13 +108,13 @@ public boolean performDrop(Object data) {
boolean result2 = dropMdSecs(mdSecs);
result = result || result2;
}
- } else if (data instanceof IResource[]) {
- IResource[] res = (IResource[]) data;
- List<IResource> items = new ArrayList<IResource>(res.length);
- for (IResource r : res) {
+ } else if (data instanceof OriginalFileStore[]) {
+ OriginalFileStore[] res = (OriginalFileStore[]) data;
+ List<OriginalFileStore> items = new ArrayList<OriginalFileStore>(res.length);
+ for (OriginalFileStore r : res) {
items.add(r);
}
- result = dropResources(items);
+ result = dropOriginals(items);
}
refresh();
return result;
@@ -255,8 +256,8 @@ public void drop(DropTargetEvent event) {
super.drop(event);
}
- private boolean dropResources(List<IResource> items) {
- LOG.debug("dropping Resources");
+ private boolean dropOriginals(List<OriginalFileStore> items) {
+ LOG.debug("dropping originals");
CaptureJob job = null;
if (this.getCurrentTarget() instanceof IProject) {
IProject p = (IProject) this.getCurrentTarget();
42 workbench_plugin/src/main/java/unc/lib/cdr/workbench/arrange/DivAdapterFactory.java
View
@@ -16,58 +16,24 @@
package unc.lib.cdr.workbench.arrange;
import gov.loc.mets.DivType;
-import gov.loc.mets.util.METSConstants;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IAdapterFactory;
+import unc.lib.cdr.workbench.originals.OriginalFileStore;
import unc.lib.cdr.workbench.project.MetsProjectNature;
public class DivAdapterFactory implements IAdapterFactory {
@SuppressWarnings("rawtypes")
- Class[] adapterTypes = new Class[] { IResource.class };
+ Class[] adapterTypes = new Class[] { OriginalFileStore.class };
@SuppressWarnings("rawtypes")
@Override
public Object getAdapter(Object adaptableObject, Class adapterType) {
Object result = null;
- if (IResource.class.equals(adapterType)) {
+ if (OriginalFileStore.class.equals(adapterType)) {
if (adaptableObject instanceof DivType) {
- // make a DivType into a IResource.
DivType d = (DivType) adaptableObject;
- IProject project = MetsProjectNature.getProjectForMetsEObject(d);
- if(project == null) return result;
- if (d.getCONTENTIDS() != null && d.getCONTENTIDS().size() > 0) {
- URI loc;
- try {
- loc = new URI(d.getCONTENTIDS().get(0));
- if (METSConstants.Div_File.equals(d.getTYPE())) {
- IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(loc);
- for(IFile f : files) {
- if(project.equals(f.getProject())) {
- result = f;
- }
- }
- } else {
- IContainer[] cs = ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(loc);
- for(IContainer f : cs) {
- if(project.equals(f.getProject())) {
- result = f;
- }
- }
- }
- } catch (URISyntaxException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
+ return MetsProjectNature.getOriginal(d);
}
}
return result;
67 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/CaptureHandler.java
View
@@ -16,18 +16,11 @@
package unc.lib.cdr.workbench.capture;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
@@ -37,7 +30,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import unc.lib.cdr.workbench.IResourceConstants;
+import unc.lib.cdr.workbench.originals.OriginalFileStore;
public class CaptureHandler extends AbstractHandler {
@@ -51,7 +44,7 @@
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- List<IResource> toCapture = new ArrayList<IResource>();
+ List<OriginalFileStore> toCapture = new ArrayList<OriginalFileStore>();
ISelectionProvider sp = HandlerUtil.getActiveSite(event).getSelectionProvider();
IStructuredSelection s = (IStructuredSelection) sp.getSelection();
toCapture.addAll(s.toList());
@@ -70,60 +63,4 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
return null;
}
- /**
- * @param toCapture
- * @throws CoreException
- */
- private void addFolderContents(List<IResource> toCapture) throws CoreException {
- Set<IResource> additions = new HashSet<IResource>();
- // for each Folder, if no contents are selected individually, add all contents
- foldercheck: for (IResource r : toCapture) {
- if (r instanceof IFolder) {
- IFolder f = (IFolder) r;
- IPath p = f.getFullPath();
- for (IResource check : toCapture) {
- if (!f.equals(check) && p.isPrefixOf(check.getFullPath())) {
- LOG.debug(f.getName() + " found selected children, breaking here..");
- break foldercheck;
- }
- }
- // no children were selected, so add them all
- addMembersRecursive(additions, f);
- }
- }
- toCapture.addAll(additions);
- }
-
- /**
- * @param additions
- * the set to add members to
- * @param f
- * the folder
- */
- private void addMembersRecursive(Set<IResource> additions, IFolder f) throws CoreException {
- for (IResource r : f.members()) {
- additions.add(r);
- if (r instanceof IFolder) {
- IFolder cf = (IFolder) r;
- addMembersRecursive(additions, cf);
- }
- }
- }
-
- /**
- * @param toCapture
- * @return
- */
- private Set<IResource> findPreviouslyCaptured(List<IResource> toCapture) throws CoreException {
- Set<IResource> result = new HashSet<IResource>();
- for (Object o : toCapture) {
- IResource r = (IResource) o;
- IMarker[] ms = r.findMarkers(IResourceConstants.MARKER_CAPTURED, false, IResource.DEPTH_ZERO);
- if (ms.length > 0) {
- result.add(r);
- }
- }
- return result;
- }
-
}
156 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/CaptureJob.java
View
@@ -27,6 +27,7 @@
import java.text.Collator;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
@@ -34,16 +35,10 @@
import java.util.Map;
import java.util.UUID;
-import javax.swing.ProgressMonitor;
-
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileInfo;
import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -55,7 +50,7 @@
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.edit.command.AddCommand;
-import unc.lib.cdr.workbench.IResourceConstants;
+import unc.lib.cdr.workbench.originals.OriginalFileStore;
import unc.lib.cdr.workbench.project.MetsProjectNature;
/**
@@ -64,7 +59,7 @@
*/
public class CaptureJob extends Job {
private IProject project = null;
- private List<IResource> items;
+ private List<OriginalFileStore> items;
private DivType topDestination = null;
private DivType insertBefore = null;
private MetsProjectNature mpn = null;
@@ -72,11 +67,11 @@
private DivType bag = null;
private IProgressMonitor monitor = null;
private CompoundCommand command = null;
- private Map<IResource, DivType> localParentDivs = new HashMap<IResource, DivType>();
+ private Map<OriginalFileStore, DivType> localParentDivs = new HashMap<OriginalFileStore, DivType>();
- private static Comparator<IResource> resourceComparator = new Comparator<IResource>() {
+ private static Comparator<OriginalFileStore> comparator = new Comparator<OriginalFileStore>() {
@Override
- public int compare(IResource arg0, IResource arg1) {
+ public int compare(OriginalFileStore arg0, OriginalFileStore arg1) {
return Collator.getInstance().compare(arg0.getName(), arg1.getName());
}
};
@@ -91,7 +86,7 @@ public int compare(IResource arg0, IResource arg1) {
* @param insertBefore
* If not null, captured resources will be inserted before this div
*/
- public CaptureJob(String jobName, List<IResource> items, DivType destination, DivType insertBefore) {
+ public CaptureJob(String jobName, List<OriginalFileStore> items, DivType destination, DivType insertBefore) {
super(jobName);
this.items = items;
@@ -108,22 +103,21 @@ public CaptureJob(String jobName, List<IResource> items, DivType destination, Di
* @param items
* the items to capture or verify
*/
- public CaptureJob(String jobName, List<IResource> items) {
+ public CaptureJob(String jobName, List<OriginalFileStore> items) {
this(jobName, items, null, null);
}
- public class CounterVisitor implements IResourceVisitor {
+ public class CounterVisitor {
+ IProgressMonitor monitor = new NullProgressMonitor();
public int count = 0;
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.resources.IResourceVisitor#visit(org.eclipse.core.resources.IResource)
- */
- @Override
- public boolean visit(IResource resource) throws CoreException {
+ public void visit(IFileStore resource) throws CoreException {
count++;
- return true;
+ if (resource.fetchInfo().isDirectory()) {
+ for (IFileStore f : resource.childStores(EFS.NONE, monitor)) {
+ visit(f);
+ }
+ }
}
}
@@ -145,30 +139,30 @@ protected IStatus run(IProgressMonitor monitor) {
}
// recursively count the items
CounterVisitor v = new CounterVisitor();
- for (IResource r : items) {
- r.accept(v);
+ for (OriginalFileStore r : items) {
+ v.visit(r);
}
String commandLabel = "Capturing " + v.count + " resources..";
monitor.beginTask(commandLabel, v.count);
command = new CompoundCommand(commandLabel);
// get METS object
- mpn = (MetsProjectNature) project.getNature(MetsProjectNature.NATURE_ID);
+ mpn = MetsProjectNature.get(project);
m = mpn.getMets();
bag = METSUtils.findBagDiv(m);
- Map<IResource, DivType> map = captureSiblingList(items);
-
+ Map<OriginalFileStore, DivType> map = captureSiblingList(items);
+
if (topDestination == null) {
// create and add relevant parents (EMF Command for top node)
- for(IResource r: items) {
- if(map.containsKey(r)) {
+ for (OriginalFileStore r : items) {
+ if (map.containsKey(r)) {
makeOrLinkParent(r, map.get(r));
}
}
} else {
- for(IResource r : items) {
- if(map.containsKey(r)) {
+ for (OriginalFileStore r : items) {
+ if (map.containsKey(r)) {
// use EMF command to add item to topDestination
emfAdd(topDestination, map.get(r));
}
@@ -177,7 +171,7 @@ protected IStatus run(IProgressMonitor monitor) {
mpn.getCommandStack().execute(command);
project.getWorkspace().save(true, monitor);
-
+
if (mpn.getAutomaticStaging(project)) {
System.out.println("triggering build b/c auto staging says " + mpn.getAutomaticStaging(project));
Job buildJob = new Job("Staging") {
@@ -189,7 +183,8 @@ protected IStatus run(IProgressMonitor monitor) {
project.build(IncrementalProjectBuilder.FULL_BUILD, MetsProjectNature.STAGING_BUILDER_ID, params,
monitor);
} catch (CoreException e) {
- return new Status(Status.ERROR, Activator.PLUGIN_ID, "There was a problem running the staging process.", e);
+ return new Status(Status.ERROR, Activator.PLUGIN_ID,
+ "There was a problem running the staging process.", e);
}
return Status.OK_STATUS;
}
@@ -200,7 +195,7 @@ protected IStatus run(IProgressMonitor monitor) {
} else {
System.out.println("skipping build b/c auto staging says " + mpn.getAutomaticStaging(project));
}
-
+
monitor.done();
return Status.OK_STATUS;
} catch (CoreException e) {
@@ -210,25 +205,25 @@ protected IStatus run(IProgressMonitor monitor) {
}
/**
- * Recursives captures a list of resources, returning a map of the top resource nodes to their DivTypes. Resources
+ * Recursives captures a list of originals, returning a map of the top nodes to their DivTypes. Originals
* already captured are left in place, but their children are captured under them.
*
* @param list
- * the resources to capture
+ * the original stores to capture
* @param dest
* the parent to add these DivTypes to
- * @return a map of captured resources (at this level) to DivTypes
+ * @return a map of captured original stores (at this level) to DivTypes
* @throws CoreException
*/
- private Map<IResource, DivType> captureSiblingList(List<IResource> list) throws CoreException {
+ private Map<OriginalFileStore, DivType> captureSiblingList(List<OriginalFileStore> list) throws CoreException {
if (list.size() == 0)
return Collections.EMPTY_MAP;
- Map<IResource, DivType> result = new HashMap<IResource, DivType>();
-
- Collections.sort(list, resourceComparator);
- for (IResource r : list) {
+ Map<OriginalFileStore, DivType> result = new HashMap<OriginalFileStore, DivType>();
+
+ Collections.sort(list, comparator);
+ for (OriginalFileStore r : list) {
// first find or create this Div
- DivType d = findDiv(r);
+ DivType d = r.getMetsDivType();
boolean newDiv = false;
if (d == null) {
newDiv = true;
@@ -238,13 +233,12 @@ protected IStatus run(IProgressMonitor monitor) {
} else {
System.out.println("previously captured: " + d);
}
- if (r instanceof IContainer) {
+ IProgressMonitor mon = new NullProgressMonitor();
+ if (r.fetchInfo().isDirectory()) {
// get children, and capture them
- List<IResource> children = new ArrayList<IResource>();
- IContainer c = (IContainer) r;
- Collections.addAll(children, c.members());
- Map<IResource, DivType> map = captureSiblingList(children);
- for (IResource childRes : children) {
+ List<OriginalFileStore> children = Arrays.asList((OriginalFileStore[])r.childStores(EFS.NONE, mon));
+ Map<OriginalFileStore, DivType> map = captureSiblingList(children);
+ for (OriginalFileStore childRes : children) {
if (map.containsKey(childRes)) { // if we created a new Div
if (!newDiv) {
emfAdd(d, map.get(childRes));
@@ -263,89 +257,67 @@ private void emfAdd(DivType d, DivType child) {
command.append(add);
}
- private DivType findDiv(IResource r) throws CoreException {
- DivType result = null;
- String divID = IResourceConstants.getDivID(r);
- if (divID != null) {
- result = (DivType) m.eResource().getEObject(divID);
- }
- return result;
- }
-
- private FileType findFile(IResource r) throws CoreException {
- FileType result = null;
- String fileID = IResourceConstants.getFileID(r);
- if (fileID != null) {
- result = (FileType) m.eResource().getEObject(fileID);
- }
- return result;
- }
-
/**
- * Finds and links to existing parent of resource or builds a parent and recurses.
+ * Finds and links to existing parent of resource or builds a parent and recurses.
*
- * @param iResource
+ * @param original
* @return
* @throws CoreException
*/
- private void makeOrLinkParent(IResource resource, DivType div) throws CoreException {
+ private void makeOrLinkParent(OriginalFileStore original, DivType div) throws CoreException {
DivType parent = null;
- if (resource.getParent() == null) {
+ if (original.getOriginalStub().getStore().equals(original)) {
parent = this.bag;
} else {
- parent = findDiv(resource.getParent());
+ parent = ((OriginalFileStore)original.getParent()).getMetsDivType();
}
if (parent != null) {
// attach resource div to found parent
emfAdd(parent, div);
} else { // parent is not in METS doc
- if(localParentDivs.containsKey(resource.getParent())) {
+ if (localParentDivs.containsKey((OriginalFileStore)original.getParent())) {
// parents were already made
- localParentDivs.get(resource.getParent()).getDiv().add(div);
+ localParentDivs.get((OriginalFileStore)original.getParent()).getDiv().add(div);
} else {
// make a parent, attach the child and keep going
- parent = makeDiv(resource.getParent());
- localParentDivs.put(resource.getParent(), parent);
+ parent = makeDiv((OriginalFileStore)original.getParent());
+ localParentDivs.put((OriginalFileStore)original.getParent(), parent);
parent.getDiv().add(div);
- makeOrLinkParent(resource.getParent(), parent);
+ makeOrLinkParent((OriginalFileStore)original.getParent(), parent);
}
}
}
/**
- * @param folderDiv
- * @param c
+ * @param original
*/
- private DivType makeDiv(IResource c) throws CoreException {
+ private DivType makeDiv(OriginalFileStore original) throws CoreException {
DivType result = MetsFactory.eINSTANCE.createDivType();
UUID uuid = UUID.randomUUID();
List<String> contentIds = new ArrayList<String>();
- contentIds.add(c.getLocationURI().toASCIIString());
- contentIds.add("info:fedora/uuid:"+uuid.toString());
+ contentIds.add(original.getWrapped().toURI().toASCIIString());
+ contentIds.add("info:fedora/uuid:" + uuid.toString());
result.setCONTENTIDS(contentIds);
- result.setID(METSUtils.makeXMLUUID(uuid));
- result.setLABEL1(c.getName());
- if (c instanceof IContainer) {
+ result.setID(original.getDivID());
+ result.setLABEL1(original.getWrapped().getName());
+ if (original.fetchInfo().isDirectory()) {
result.setTYPE(METSConstants.Div_Folder);
- } else if (c instanceof IFile) {
+ } else {
result.setTYPE(METSConstants.Div_File);
// calc size and checksum.
- IFileStore sourceFileStore = EFS.getStore(c.getLocationURI());
- IFileInfo sourceFileInfo = sourceFileStore.fetchInfo();
+ IFileInfo sourceFileInfo = original.fetchInfo();
long size = sourceFileInfo.getLength();
// find File section (for previously captured) or make one
- FileType ft = findFile(c);
+ FileType ft = original.getMetsFileType();
if (ft == null) {
- ft = METSUtils.addFile(m, c.getLocationURI(), size, null);
- IResourceConstants.setFileID(c, ft.getID());
+ ft = METSUtils.addFile(m, original.getWrapped().toURI(), original.getFileID(), size, null);
}
FptrType fptr = MetsFactory.eINSTANCE.createFptrType();
fptr.setFILEID(ft.getID());
result.getFptr().add(fptr);
}
- IResourceConstants.setDivID(c, result.getID());
return result;
}
8 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalsContentProvider.java
View
@@ -35,7 +35,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import unc.lib.cdr.workbench.originals.Original;
+import unc.lib.cdr.workbench.originals.OriginalStub;
import unc.lib.cdr.workbench.project.MetsProjectNature;
/**
@@ -68,8 +68,8 @@ public OriginalsContentProvider() {
MetsProjectNature n = (MetsProjectNature) p.getNature(MetsProjectNature.NATURE_ID);
results.addAll(n.getOriginals());
}
- } else if(parent instanceof Original) {
- Original original = (Original)parent;
+ } else if(parent instanceof OriginalStub) {
+ OriginalStub original = (OriginalStub)parent;
results.add(original.getStore());
} else if (parent instanceof IFileStore) {
IFileStore f = (IFileStore) parent;
@@ -105,7 +105,7 @@ public Object getParent(Object element) {
*/
@Override
public boolean hasChildren(Object element) {
- if(element instanceof Original) {
+ if(element instanceof OriginalStub) {
return true;
} else if(element instanceof IFileStore) {
IFileStore fs = (IFileStore)element;
259 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalsDecorator.java
View
@@ -23,15 +23,11 @@
import gov.loc.mets.util.METSUtils;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IMarkerDelta;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -46,14 +42,15 @@
import org.slf4j.LoggerFactory;
import unc.lib.cdr.workbench.IResourceConstants;
+import unc.lib.cdr.workbench.originals.OriginalFileStore;
import unc.lib.cdr.workbench.project.MetsProjectNature;
import unc.lib.cdr.workbench.views.LabelImageFactory.Icon;
-public class OriginalsDecorator implements ILightweightLabelDecorator, IResourceChangeListener {
+public class OriginalsDecorator implements ILightweightLabelDecorator {
Set<ILabelProviderListener> listeners = new HashSet<ILabelProviderListener>();
public OriginalsDecorator() {
- ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
+ // TODO register as listener to capture and staging changes (less granular this time)
}
@SuppressWarnings("unused")
@@ -81,99 +78,94 @@ public void removeListener(ILabelProviderListener listener) {
@Override
public void decorate(Object element, IDecoration decoration) {
- IResource r = null;
+ OriginalFileStore r = null;
boolean isDiv = false;
// added/captured, queued/staged BR
- try {
- List<String> labels = new ArrayList<String>();
- if (element instanceof IResource) {
- r = (IResource) element;
- } else if (element instanceof DivType) {
- isDiv = true;
- DivType d = (DivType) element;
- Object adapted = Platform.getAdapterManager().getAdapter(d, IResource.class);
- if (adapted != null && adapted instanceof IResource) {
- r = (IResource) adapted;
- }
- // described, crosswalked
- // MetsProjectNature n = MetsProjectNature.getNatureForMetsObject(d);
- boolean userEdited = false;
- boolean crosswalked = false;
- for (MdSecType md : d.getDmdSec()) {
- if (md != null) {
- String st = md.getSTATUS();
- if (METSConstants.MD_STATUS_CROSSWALK_LINKED.equals(st)) {
- decoration.addOverlay(Icon.CrosswalkedDecor.getImageDescriptor(), IDecoration.BOTTOM_LEFT);
- } else if (METSConstants.MD_STATUS_USER_EDITED.equals(st)) {
- decoration.addOverlay(Icon.UserEditedDecor.getImageDescriptor(), IDecoration.TOP_RIGHT);
- } else if (METSConstants.MD_STATUS_CROSSWALK_USER_LINKED.equals(st)) {
- decoration.addOverlay(Icon.CrosswalkedDecor.getImageDescriptor(), IDecoration.BOTTOM_LEFT);
- }
+ List<String> labels = new ArrayList<String>();
+ if (element instanceof OriginalFileStore) {
+ r = (OriginalFileStore) element;
+ } else if (element instanceof DivType) {
+ isDiv = true;
+ DivType d = (DivType) element;
+ Object adapted = Platform.getAdapterManager().getAdapter(d, OriginalFileStore.class);
+ if (adapted != null && adapted instanceof OriginalFileStore) {
+ r = (OriginalFileStore) adapted;
+ }
+ // described, crosswalked
+ // MetsProjectNature n = MetsProjectNature.getNatureForMetsObject(d);
+ for (MdSecType md : d.getDmdSec()) {
+ if (md != null) {
+ String st = md.getSTATUS();
+ if (METSConstants.MD_STATUS_CROSSWALK_LINKED.equals(st)) {
+ decoration.addOverlay(Icon.CrosswalkedDecor.getImageDescriptor(), IDecoration.BOTTOM_LEFT);
+ } else if (METSConstants.MD_STATUS_USER_EDITED.equals(st)) {
+ decoration.addOverlay(Icon.UserEditedDecor.getImageDescriptor(), IDecoration.TOP_RIGHT);
+ } else if (METSConstants.MD_STATUS_CROSSWALK_USER_LINKED.equals(st)) {
+ decoration.addOverlay(Icon.CrosswalkedDecor.getImageDescriptor(), IDecoration.BOTTOM_LEFT);
}
}
- for (MdSecType md : d.getMdSec()) { // process admin metadata overlays
- if (md != null) {
- if (MetsPackage.eINSTANCE.getAmdSecType_RightsMD().equals(md.eContainingFeature())) {
- decoration.addOverlay(Icon.ACLDecor.getImageDescriptor(), IDecoration.TOP_LEFT);
- }
+ }
+ for (MdSecType md : d.getMdSec()) { // process admin metadata overlays
+ if (md != null) {
+ if (MetsPackage.eINSTANCE.getAmdSecType_RightsMD().equals(md.eContainingFeature())) {
+ decoration.addOverlay(Icon.ACLDecor.getImageDescriptor(), IDecoration.TOP_LEFT);
}
}
- // add labels for links of which this div is the object
- for(SmLinkType sml : METSUtils.getObjectLinks(d)) {
- labels.add(METSConstants.getLinkForArcRole(sml.getArcrole()).label);
- }
-
+ }
+ // add labels for links of which this div is the object
+ for (SmLinkType sml : METSUtils.getObjectLinks(d)) {
+ labels.add(METSConstants.getLinkForArcRole(sml.getArcrole()).label);
}
- ImageDescriptor overlay = null;
- if (r != null && r.getProject() != null && r.getProject().isOpen()) {
- boolean captured = false;
- if (r.findMarkers(IResourceConstants.MARKER_CAPTURED, false, IResource.DEPTH_ZERO).length > 0) {
- captured = true;
- if (!isDiv) {
- labels.add("captured");
- }
- }
- if (!isDiv && r.getParent().equals(r.getProject().getFolder(MetsProjectNature.ORIGINALS_FOLDER_NAME))) {
- IMarker[] m = r.findMarkers(IResourceConstants.MARKER_ORIGINALFILESET, false, IResource.DEPTH_ZERO);
- if (m.length > 0) {
- Object base = m[0].getAttribute("prestagedBase");
- if (base != null) {
- labels.add("prestaged => " + base);
- }
- }
- }
- if (r.findMarkers(IResourceConstants.MARKER_STAGED, false, IResource.DEPTH_ZERO).length > 0) {
- // captured file (original or the div)
- overlay = Icon.StagedDecor.getImageDescriptor();
- labels.add("staged");
- } else {
- if (captured && r instanceof IFile) {
- overlay = Icon.CaptureDecor.getImageDescriptor();
- labels.add("queued");
- }
+ }
+
+ ImageDescriptor overlay = null;
+ if (r != null && r.getProject() != null && r.getProject().isOpen()) {
+ boolean captured = false;
+ if (r.getMetsDivType() != null) {
+ captured = true;
+ if (!isDiv) {
+ labels.add("captured");
}
+ }
+ // TODO make a separate decorator for the Originals object
+ // if (!isDiv && r.getParent().equals(r.getProject().getFolder(MetsProjectNature.ORIGINALS_FOLDER_NAME))) {
+ // IMarker[] m = r.findMarkers(IResourceConstants.MARKER_ORIGINALFILESET, false, IResource.DEPTH_ZERO);
+ // if (m.length > 0) {
+ // Object base = m[0].getAttribute("prestagedBase");
+ // if (base != null) {
+ // labels.add("prestaged => " + base);
+ // }
+ // }
+ // }
+ if (r.getStagingLocatorType() != null) {
+ // captured file (original or the div)
+ overlay = Icon.StagedDecor.getImageDescriptor();
+ labels.add("staged");
} else {
- if (isDiv) {
- labels.add("added");
+ if (captured && !r.fetchInfo().isDirectory()) {
+ overlay = Icon.CaptureDecor.getImageDescriptor();
+ labels.add("queued");
}
}
- if (overlay != null) {
- decoration.addOverlay(overlay, IDecoration.BOTTOM_RIGHT);
+ } else {
+ if (isDiv) {
+ labels.add("added");
}
- if (labels.size() > 0) {
- // decoration.setForegroundColor(org.eclipse.swt.graphics.);
- StringBuilder sb = new StringBuilder();
- sb.append(" [");
- sb.append(labels.remove(0));
- for (String label : labels) {
- sb.append(" ").append(label);
- }
- sb.append("]");
- decoration.addSuffix(sb.toString());
+ }
+ if (overlay != null) {
+ decoration.addOverlay(overlay, IDecoration.BOTTOM_RIGHT);
+ }
+ if (labels.size() > 0) {
+ // decoration.setForegroundColor(org.eclipse.swt.graphics.);
+ StringBuilder sb = new StringBuilder();
+ sb.append(" [");
+ sb.append(labels.remove(0));
+ for (String label : labels) {
+ sb.append(" ").append(label);
}
- } catch (CoreException ignored) {
- ignored.printStackTrace();
+ sb.append("]");
+ decoration.addSuffix(sb.toString());
}
}
@@ -183,53 +175,54 @@ public void decorate(Object element, IDecoration decoration) {
* @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org
* .eclipse.core.resources.IResourceChangeEvent)
*/
- @Override
- public void resourceChanged(IResourceChangeEvent event) {
- Set<Object> changes = new HashSet<Object>();
- IMarkerDelta[] captures = event.findMarkerDeltas(IResourceConstants.MARKER_CAPTURED, false);
- IMarkerDelta[] stages = event.findMarkerDeltas(IResourceConstants.MARKER_STAGED, false);
- for (IMarkerDelta d : captures) {
- if (d.getResource().getProject().isOpen()) {
- changes.add(d.getResource());
- try {
- MetsProjectNature n = (MetsProjectNature) d.getResource().getProject()
- .getNature(MetsProjectNature.NATURE_ID);
- String divID = IResourceConstants.getDivID(d.getResource());
- if (n != null && n.getMetsResource() != null && divID != null) {
- Object div = n.getMetsResource().getEObject(divID);
- if (div != null) {
- changes.add(div);
- }
- }
- } catch (CoreException e1) {
- e1.printStackTrace();
- }
- }
- }
- for (IMarkerDelta d : stages) {
- if (d.getResource().getProject().isOpen()) {
- changes.add(d.getResource());
- try {
- MetsProjectNature n = (MetsProjectNature) d.getResource().getProject()
- .getNature(MetsProjectNature.NATURE_ID);
- String divID = IResourceConstants.getDivID(d.getResource());
- if (n != null && n.getMetsResource() != null && divID != null) {
- Object div = n.getMetsResource().getEObject(divID);
- if (div != null) {
- changes.add(div);
- }
- }
- } catch (CoreException e1) {
- e1.printStackTrace();
- }
- }
- }
- if (changes.size() > 0) {
- LabelProviderChangedEvent e = new LabelProviderChangedEvent(this, changes.toArray());
- for (ILabelProviderListener l : listeners) {
- l.labelProviderChanged(e);
- }
- }
- }
+// @Override
+// public void resourceChanged(IResourceChangeEvent event) {
+// // TODO how to update on changes with file store objects
+// Set<Object> changes = new HashSet<Object>();
+// IMarkerDelta[] captures = event.findMarkerDeltas(IResourceConstants.MARKER_CAPTURED, false);
+// IMarkerDelta[] stages = event.findMarkerDeltas(IResourceConstants.MARKER_STAGED, false);
+// for (IMarkerDelta d : captures) {
+// if (d.getResource().getProject().isOpen()) {
+// changes.add(d.getResource());
+// try {
+// MetsProjectNature n = (MetsProjectNature) d.getResource().getProject()
+// .getNature(MetsProjectNature.NATURE_ID);
+// String divID = IResourceConstants.getDivID(d.getResource());
+// if (n != null && n.getMetsResource() != null && divID != null) {
+// Object div = n.getMetsResource().getEObject(divID);
+// if (div != null) {
+// changes.add(div);
+// }
+// }
+// } catch (CoreException e1) {
+// e1.printStackTrace();
+// }
+// }
+// }
+// for (IMarkerDelta d : stages) {
+// if (d.getResource().getProject().isOpen()) {
+// changes.add(d.getResource());
+// try {
+// MetsProjectNature n = (MetsProjectNature) d.getResource().getProject()
+// .getNature(MetsProjectNature.NATURE_ID);
+// String divID = IResourceConstants.getDivID(d.getResource());
+// if (n != null && n.getMetsResource() != null && divID != null) {
+// Object div = n.getMetsResource().getEObject(divID);
+// if (div != null) {
+// changes.add(div);
+// }
+// }
+// } catch (CoreException e1) {
+// e1.printStackTrace();
+// }
+// }
+// }
+// if (changes.size() > 0) {
+// LabelProviderChangedEvent e = new LabelProviderChangedEvent(this, changes.toArray());
+// for (ILabelProviderListener l : listeners) {
+// l.labelProviderChanged(e);
+// }
+// }
+// }
}
8 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalsLabelProvider.java
View
@@ -28,7 +28,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import unc.lib.cdr.workbench.originals.Original;
+import unc.lib.cdr.workbench.originals.OriginalStub;
import unc.lib.cdr.workbench.views.LabelImageFactory;
import unc.lib.cdr.workbench.views.LabelImageFactory.Icon;
@@ -131,7 +131,7 @@ public Image getImage(Object element) {
return LabelImageFactory.getImage(Icon.File);
}
}
- } else if(element instanceof Original) {
+ } else if(element instanceof OriginalStub) {
return LabelImageFactory.getImage(Icon.OriginalsEl);
}
return provider.getImage(element);
@@ -144,8 +144,8 @@ public Image getImage(Object element) {
*/
@Override
public String getText(Object element) {
- if(element instanceof Original) {
- Original o = (Original)element;
+ if(element instanceof OriginalStub) {
+ OriginalStub o = (OriginalStub)element;
if(o.getName() != null) return o.getName();
return o.getStore().getName();
} else if(element instanceof IFileStore) {
23 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalsLinkJob.java
View
@@ -19,6 +19,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -37,8 +38,8 @@
import org.eclipse.core.runtime.jobs.Job;
import unc.lib.cdr.workbench.IResourceConstants;
-import unc.lib.cdr.workbench.originals.Original;
-import unc.lib.cdr.workbench.originals.OriginalsWrapperFileSystem;
+import unc.lib.cdr.workbench.originals.OriginalStub;
+import unc.lib.cdr.workbench.originals.OriginalsFileSystem;
import unc.lib.cdr.workbench.originals.VolumeUtil;
import unc.lib.cdr.workbench.project.MetsProjectNature;
@@ -73,25 +74,12 @@ protected IStatus run(IProgressMonitor monitor) {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
- IStatus result = null;
System.out.println("starting link");
monitor.beginTask("Linking to originals ...", this.locations.size());
MetsProjectNature n = MetsProjectNature.get(project);
try {
for (URI location : locations) {
- IFileStore fs = OriginalsWrapperFileSystem.wrapStore(location, this.project);
- boolean isDir = fs.fetchInfo().isDirectory();
- String linkName = null;
- IPath path = new Path(fs.toURI().getPath());
- if (path != null && path.segments().length > 0 && path.lastSegment().trim().length() > 0) {
- linkName = path.lastSegment();
- } else if (path.getDevice() != null) {
- linkName = path.getDevice().replaceAll(":", "");
- } else {
- linkName = "ROOT";
- }
- //VolumeUtil.isVolumeRemovable(link);
- //VolumeUtil.recordVolumeFingerprint(link);
+ IFileStore fs = EFS.getStore(location);
URI myprestage = null;
if (this.prestaged && this.prestagedBase != null && this.baselocation != null) {
// calculate staging base for each original location
@@ -107,8 +95,7 @@ protected IStatus run(IProgressMonitor monitor) {
myprestagestr = myprestage.toString() + "/";
}
}
- // TODO recalc prestage base URI and name?
- Original original = new Original(location, this.project, myprestage, null);
+ OriginalStub original = new OriginalStub(location, this.project, myprestage, null);
n.addOriginal(original);
}
monitor.done();
12 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalsPropertyTester.java
View
@@ -17,16 +17,22 @@
import org.eclipse.core.expressions.PropertyTester;
+import unc.lib.cdr.workbench.originals.OriginalFileStore;
+
public class OriginalsPropertyTester extends PropertyTester {
public OriginalsPropertyTester() {
- // TODO Auto-generated constructor stub
}
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
- // TODO Auto-generated method stub
- return false;
+ OriginalFileStore r = (OriginalFileStore) receiver;
+ if (receiver instanceof OriginalFileStore && "isFile".equals(property)) {
+ return expectedValue == null ? !r.fetchInfo().isDirectory()
+ : r.fetchInfo().isDirectory() != ((Boolean) expectedValue).booleanValue();
+ } else {
+ return false;
+ }
}
}
4 workbench_plugin/src/main/java/unc/lib/cdr/workbench/commands/OpenSystemEditorTempCopyHandler.java
View
@@ -22,7 +22,7 @@
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.ide.IDE;
-import unc.lib.cdr.workbench.originals.OriginalsWrapperStore;
+import unc.lib.cdr.workbench.originals.OriginalFileStore;
import unc.lib.cdr.workbench.project.MetsProjectNature;
public class OpenSystemEditorTempCopyHandler extends AbstractHandler implements IHandler {
@@ -38,7 +38,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
openTempCopy(file, event);
} else if(element instanceof DivType) {
DivType d = (DivType)element;
- OriginalsWrapperStore r = MetsProjectNature.getOriginal(d);
+ OriginalFileStore r = MetsProjectNature.getOriginal(d);
openTempCopy(r, event);
}
}
49 ...dr/workbench/originals/OriginalsWrapperStore.java → ...ib/cdr/workbench/originals/OriginalFileStore.java
View
@@ -24,13 +24,13 @@
import unc.lib.cdr.workbench.project.MetsProjectNature;
import unc.lib.cdr.workbench.rcp.Activator;
-public class OriginalsWrapperStore implements IFileStore {
+public class OriginalFileStore implements IFileStore {
private static final String FILETYPE_PREFIX = "f_";
private static final String DIVTYPE_PREFIX = "d_";
private static final String protectedMessage = "Operation cancelled. This file under read only protection within the workbench.";
public static final String SCHEME_PREFIX = "ro+";
protected URI uri = null;
- private IProject project = null;
+ private OriginalStub stub = null;
protected IFileStore wrapped = null;
public IFileStore getWrapped() {
@@ -39,8 +39,8 @@ public IFileStore getWrapped() {
protected int volumeHash = -1;
- public OriginalsWrapperStore(URI uri, IProject project) throws CoreException {
- this.project = project;
+ public OriginalFileStore(URI uri, OriginalStub stub) throws CoreException {
+ this.stub = stub;
this.uri = uri;
if (!uri.getScheme().startsWith(SCHEME_PREFIX)) {
throw new CoreException(new Status(Status.ERROR, Activator.PLUGIN_ID,
@@ -58,9 +58,9 @@ public OriginalsWrapperStore(URI uri, IProject project) throws CoreException {
this.volumeHash = VolumeUtil.makeVolumeFingerprint(wrappedUri);
}
- public OriginalsWrapperStore(IFileStore iFileStore, IProject project) throws CoreException {
+ public OriginalFileStore(IFileStore iFileStore, OriginalStub stub) throws CoreException {
this.wrapped = iFileStore;
- this.project = project;
+ this.stub = stub;
try {
URI wrappedUri = this.wrapped.toURI();
this.uri = new URI(SCHEME_PREFIX + wrappedUri.getScheme() + ":" + wrappedUri.getRawSchemeSpecificPart());
@@ -73,23 +73,23 @@ public OriginalsWrapperStore(IFileStore iFileStore, IProject project) throws Cor
public FileType getMetsFileType() {
try {
- return (FileType) MetsProjectNature.get(project).getMetsResource().getEObject(getFileID());
+ return (FileType) MetsProjectNature.get(stub.getProject()).getMetsResource().getEObject(getFileID());
} catch (NullPointerException e) {
return null;
}
}
- private String getFileID() {
+ public String getFileID() {
return new StringBuilder().append(FILETYPE_PREFIX).append(this.hashCode()).toString();
}
- private String getDivID() {
+ public String getDivID() {
return new StringBuilder().append(DIVTYPE_PREFIX).append(this.hashCode()).toString();
}
public FLocatType getStagingLocatorType() {
try {
- MetsProjectNature n = MetsProjectNature.get(project);
+ MetsProjectNature n = MetsProjectNature.get(stub.getProject());
FileType ft = (FileType) n.getMetsResource().getEObject(getFileID());
for (FLocatType loc : ft.getFLocat()) {
if (METSConstants.FLocat_USE_STAGE.equals(loc.getUSE())) {
@@ -103,7 +103,7 @@ public FLocatType getStagingLocatorType() {
public DivType getMetsDivType() {
try {
- MetsProjectNature n = MetsProjectNature.get(project);
+ MetsProjectNature n = MetsProjectNature.get(stub.getProject());
return (DivType) n.getMetsResource().getEObject(getDivID());
} catch (NullPointerException e) {
return null;
@@ -117,7 +117,7 @@ public int hashCode() {
@Override
public boolean equals(Object obj) {
- return (obj instanceof OriginalsWrapperStore && obj != null && obj.hashCode() == this.hashCode());
+ return (obj instanceof OriginalFileStore && obj != null && obj.hashCode() == this.hashCode());
}
@Override
@@ -140,9 +140,9 @@ public Object getAdapter(Class adapter) {
public IFileStore[] childStores(int options, IProgressMonitor monitor) throws CoreException {
// wraps these in read only
IFileStore[] wrappedResult = wrapped.childStores(options, monitor);
- IFileStore[] result = new OriginalsWrapperStore[wrappedResult.length];
+ IFileStore[] result = new OriginalFileStore[wrappedResult.length];
for (int i = 0; i < wrappedResult.length; i++) {
- result[i] = new OriginalsWrapperStore(wrappedResult[i], project);
+ result[i] = new OriginalFileStore(wrappedResult[i], stub);
}
return result;
}
@@ -167,10 +167,11 @@ public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreExc
return wrapped.fetchInfo();
}
+ @Deprecated
@Override
public IFileStore getChild(IPath path) {
try {
- return new OriginalsWrapperStore(this.wrapped.getChild(path), project);
+ return new OriginalFileStore(this.wrapped.getChild(path), stub);
} catch (CoreException e) {
throw new Error("Unexpected exception", e);
}
@@ -179,7 +180,7 @@ public IFileStore getChild(IPath path) {
@Override
public IFileStore getFileStore(IPath path) {
try {
- return new OriginalsWrapperStore(this.wrapped.getFileStore(path), project);
+ return new OriginalFileStore(this.wrapped.getFileStore(path), stub);
} catch (CoreException e) {
throw new Error("Unexpected exception", e);
}
@@ -188,7 +189,7 @@ public IFileStore getFileStore(IPath path) {
@Override
public IFileStore getChild(String name) {
try {
- return new OriginalsWrapperStore(this.wrapped.getChild(name), project);
+ return new OriginalFileStore(this.wrapped.getChild(name), stub);
} catch (CoreException e) {
throw new Error("Unexpected exception", e);
}
@@ -220,21 +221,25 @@ public IFileStore getParent() {
IFileStore wrappedParent = this.wrapped.getParent();
if (wrappedParent == null)
return null;
- return new OriginalsWrapperStore(this.wrapped.getParent(), project);
+ return new OriginalFileStore(this.wrapped.getParent(), stub);
} catch (CoreException e) {
throw new Error("Unexpected exception", e);
}
}
+ public OriginalStub getOriginalStub() {
+ return stub;
+ }
+
public IProject getProject() {
- return project;
+ return stub.getProject();
}
@Override
public boolean isParentOf(IFileStore other) {
- if (OriginalsWrapperFileSystem.class.isInstance(other.getFileSystem())
- && OriginalsWrapperStore.class.isInstance(other)) {
- OriginalsWrapperStore o = (OriginalsWrapperStore) other;
+ if (OriginalsFileSystem.class.isInstance(other.getFileSystem())
+ && OriginalFileStore.class.isInstance(other)) {
+ OriginalFileStore o = (OriginalFileStore) other;
return wrapped.isParentOf(o.wrapped);
}
return false;
10 ...ava/unc/lib/cdr/workbench/originals/Original.java → ...unc/lib/cdr/workbench/originals/OriginalStub.java
View
@@ -13,7 +13,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.IWorkbench;
-public class Original implements java.io.Serializable {
+public class OriginalStub implements java.io.Serializable {
/**
*
@@ -25,10 +25,10 @@
private String projectName;
private int volumeHash;
private String name;
- private transient OriginalsWrapperStore store = null;
+ private transient OriginalFileStore store = null;
private URI prestageBase;
- public Original(URI base, IProject project, URI prestageBase, String name) {
+ public OriginalStub(URI base, IProject project, URI prestageBase, String name) {
this.base = base;
this.project = project;
this.projectName = project.getName();
@@ -55,7 +55,7 @@ public Original(URI base, IProject project, URI prestageBase, String name) {
private void init() {
try {
- this.store = (OriginalsWrapperStore) OriginalsWrapperFileSystem.wrapStore(base, this.project);
+ this.store = (OriginalFileStore) OriginalsFileSystem.wrapStore(base, this);
this.project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
} catch (CoreException e) {
throw new Error(e);
@@ -91,7 +91,7 @@ public int getVolumeHash() {
return volumeHash;
}
- public OriginalsWrapperStore getStore() {
+ public OriginalFileStore getStore() {
if(this.store == null) init();
return store;
}
13 ...rkbench/originals/OriginalsWrapperFileSystem.java → .../cdr/workbench/originals/OriginalsFileSystem.java
View
@@ -6,30 +6,29 @@
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.filesystem.provider.FileSystem;
import org.eclipse.core.internal.filesystem.NullFileSystem;
-import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import unc.lib.cdr.workbench.rcp.Activator;
-public class OriginalsWrapperFileSystem extends FileSystem {
- private static OriginalsWrapperFileSystem __instance = new OriginalsWrapperFileSystem();
+public class OriginalsFileSystem extends FileSystem {
+ private static OriginalsFileSystem __instance = new OriginalsFileSystem();
- public OriginalsWrapperFileSystem() {
+ public OriginalsFileSystem() {
}
@Override
public IFileStore getStore(URI uri) {
try {
- return new OriginalsWrapperStore(uri, null);
+ return new OriginalFileStore(uri, null);
} catch (CoreException e) {
Activator.getDefault().getLog().log(e.getStatus());
return NullFileSystem.getInstance().getStore(uri);
}
}
- public static IFileStore wrapStore(URI uri, IProject project) throws CoreException {
+ public static IFileStore wrapStore(URI uri, OriginalStub stub) throws CoreException {
IFileStore wrapped = EFS.getStore(uri);
- return new OriginalsWrapperStore(wrapped, project);
+ return new OriginalFileStore(wrapped, stub);
}
}
124 workbench_plugin/src/main/java/unc/lib/cdr/workbench/project/MetsProjectNature.java
View
@@ -24,6 +24,8 @@
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -40,7 +42,9 @@
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
@@ -55,9 +59,9 @@
import org.slf4j.LoggerFactory;
import unc.lib.cdr.workbench.arrange.ArrangementProjectElement;
-import unc.lib.cdr.workbench.originals.Original;
-import unc.lib.cdr.workbench.originals.OriginalsWrapperFileSystem;
-import unc.lib.cdr.workbench.originals.OriginalsWrapperStore;
+import unc.lib.cdr.workbench.originals.OriginalFileStore;
+import unc.lib.cdr.workbench.originals.OriginalStub;
+import unc.lib.cdr.workbench.originals.OriginalsFileSystem;
import unc.lib.cdr.workbench.rcp.Activator;
import unc.lib.cdr.workbench.stage.StagedFilesProjectElement;
@@ -68,10 +72,6 @@
private static final Logger log = LoggerFactory.getLogger(MetsProjectNature.class);
public static final String NATURE_ID = "cdr_producer.projectNature";
- public static final QualifiedName EMF_SESSION_KEY = new QualifiedName(NATURE_ID, "cdr_producer.projectEMFSession");
- public static final QualifiedName EDITING_DOMAIN_KEY = new QualifiedName(NATURE_ID, "cdr_producer.editingDomain");
- // public static final QualifiedName INITIAL_AUTOSTAGE_KEY = new QualifiedName(NATURE_ID,
- // "cdr_producer.init_autostage");
public static final String STAGING_BUILDER_ID = "unc.lib.cdr.workbench.builders.StageBuilder";
public static final String CROSSWALKS_BUILDER_ID = "unc.lib.cdr.workbench.builders.CrosswalksBuilder";
private static final String STAGING_BASE_URI_KEY = "cdr_producer.stagingBaseURI";
@@ -82,7 +82,8 @@
private ICustomProjectElement[] elements = null;
private ArrangementProjectElement arrangementElement = null;
private StagedFilesProjectElement stagedFilesElement = null;
- private ArrayList<Original> originals = null;
+ private ArrayList<OriginalStub> originals = null;
+ private ProjectEMFSession emfSession;
public StagedFilesProjectElement getStagedFilesElement() {
if (stagedFilesElement == null) {
@@ -103,7 +104,7 @@ public MetsProjectNature() {
public ICustomProjectElement[] getProjectElements() {
if (this.elements == null) {
- this.elements = new ICustomProjectElement[] {
+ this.elements = new ICustomProjectElement[] {
/* getArrangementElement(), */getStagedFilesElement() };
}
return this.elements;
@@ -136,16 +137,8 @@ public void save() throws CoreException {
/**
* @return
*/
- private ProjectEMFSession getEMFSession() {
- ProjectEMFSession result = null;
- try {
- if (this.getProject().getSessionProperty(EMF_SESSION_KEY) != null) {
- result = (ProjectEMFSession) this.getProject().getSessionProperty(EMF_SESSION_KEY);
- }
- } catch (CoreException e) {
-
- }
- return result;
+ public ProjectEMFSession getEMFSession() {
+ return this.emfSession;
}
public MetsType1 getMets() {
@@ -176,10 +169,6 @@ public void configure() throws CoreException {
@Override
public void deconfigure() throws CoreException {
save();
- if (this.getEMFSession() != null) {
- this.project.getSessionProperties().remove(EMF_SESSION_KEY);
- }
-
}
@Override
@@ -190,15 +179,13 @@ public IProject getProject() {
@Override
public void setProject(IProject project) {
this.project = project;
- if (this.getEMFSession() == null) {
- try {
- ProjectEMFSession session = new ProjectEMFSession(project);
- project.setSessionProperty(EMF_SESSION_KEY, session);
- project.setSessionProperty(EDITING_DOMAIN_KEY, session.getEditingDomain());
- } catch (CoreException e) {
- log.error("Problem setting up EMF session", e);
- }
+ IEclipsePreferences projectNode = new ProjectScope(project).getNode(Activator.PLUGIN_ID);
+ try {
+ projectNode.flush();
+ } catch (BackingStoreException e) {
+ e.printStackTrace();
}
+ this.emfSession = new ProjectEMFSession(project);
this.loadOriginals();
}
@@ -206,12 +193,12 @@ private void loadOriginals() {
IEclipsePreferences projectNode = new ProjectScope(project).getNode(Activator.PLUGIN_ID);
byte[] s = projectNode.getByteArray(ORIGINALS_KEY, null);
if (s == null) {
- this.originals = new ArrayList<Original>();
+ this.originals = new ArrayList<OriginalStub>();
} else {
try {
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(s));
- this.originals = (ArrayList<Original>) in.readObject();
- log.debug("loaded originals: "+this.originals.size());
+ this.originals = (ArrayList<OriginalStub>) in.readObject();
+ log.debug("loaded originals: " + this.originals.size());
} catch (Exception e) {
throw new Error("Cannot deserialize originals for project", e);
}
@@ -228,21 +215,21 @@ private void saveOriginals() {
}
IEclipsePreferences projectNode = new ProjectScope(project).getNode(Activator.PLUGIN_ID);
projectNode.putByteArray(ORIGINALS_KEY, baos.toByteArray());
- log.debug("wrote originals to preferences");
try {
projectNode.flush();
} catch (BackingStoreException e) {
throw new Error(e);
}
+ log.debug("wrote originals to preferences");
}
-
- public void addOriginal(Original o) {
+
+ public void addOriginal(OriginalStub o) {
this.originals.add(o);
- log.debug("adding original at: "+o.getBase().toString());
+ log.debug("adding original at: " + o.getBase().toString());
this.saveOriginals();
}
-
- public List<Original> getOriginals() {
+
+ public List<OriginalStub> getOriginals() {
return Collections.unmodifiableList(this.originals);
}
@@ -252,13 +239,12 @@ public static IProject getProjectForMetsEObject(EObject object) {
if (objectResource != null) {
for (IProject p : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
if (p.isOpen()) {
- try {
- ProjectEMFSession session = (ProjectEMFSession) p.getSessionProperty(EMF_SESSION_KEY);
- if (session != null && objectResource.equals(session.getMetsResource())) {
+ MetsProjectNature n = MetsProjectNature.get(p);
+ if (n != null) {
+ Resource resource = n.getEMFSession().getMetsResource();
+ if (resource != null && objectResource.equals(resource)) {
return p;
}
- } catch (CoreException ignored) {
- ignored.printStackTrace();
}
}
}
@@ -290,9 +276,9 @@ public static EditingDomain getEditingDomain(EObject object) {
return result;
}
- //public IFolder getOriginalsFolder() {
- //return this.getProject().getFolder(ORIGINALS_FOLDER_NAME);
- //}
+ // public IFolder getOriginalsFolder() {
+ // return this.getProject().getFolder(ORIGINALS_FOLDER_NAME);
+ // }
public static boolean getAutomaticStaging(IProject project) {
boolean result = false;
@@ -314,16 +300,37 @@ public static void setAutomaticStaging(boolean auto, IProject project) {
* @param div
* @return the IResource of the original
*/
- public static OriginalsWrapperStore getOriginal(DivType div) {
- if (div.getCONTENTIDS().size() > 0) {
- for (String contentid : div.getCONTENTIDS()) {
- try {
- java.net.URI originalLoc = new java.net.URI(contentid);
- IProject project = MetsProjectNature.getProjectForMetsEObject(div);
- return (OriginalsWrapperStore)OriginalsWrapperFileSystem.wrapStore(originalLoc, project);
- } catch (Exception ignored) {
+ public static OriginalFileStore getOriginal(DivType div) {
+ try {
+ if (div.getCONTENTIDS().size() > 0) {
+ URI uri = null;
+ for (String contentid : div.getCONTENTIDS()) {
+ try {
+ uri = new URI(contentid);
+ } catch (URISyntaxException e) {
+ throw new Error(e);
+ }
+ if (!"uuid".equals(uri.getScheme()))
+ break;
+ }
+ if (uri != null) {
+ try {
+ IPath divPath = Path.fromOSString(uri.getPath());
+ MetsProjectNature n = MetsProjectNature.getNatureForMetsObject(div);
+ OriginalStub mystub = null;
+ for (OriginalStub stub : n.getOriginals()) {
+ IPath originalStubPath = Path.fromOSString(stub.getBase().getPath());
+ if (originalStubPath.isPrefixOf(divPath)) {
+ mystub = stub;
+ break;
+ }
+ }
+ return (OriginalFileStore) OriginalsFileSystem.wrapStore(uri, mystub);
+ } catch (Exception ignored) {
+ }
}
}
+ } catch (NullPointerException ignored) {
}
return null;
}
@@ -347,11 +354,6 @@ public static MetsProjectNature get(IProject prog) {
public static void setStagingBase(java.net.URI stageURI, IProject project) {
IEclipsePreferences projectNode = new ProjectScope(project).getNode(Activator.PLUGIN_ID);
projectNode.put(STAGING_BASE_URI_KEY, stageURI.toString());
- try {
- projectNode.flush();
- } catch (BackingStoreException e) {
- throw new Error(e);
- }
}
public java.net.URI getStagingBase() {
29 workbench_plugin/src/main/java/unc/lib/cdr/workbench/project/ProjectEMFSession.java
View
@@ -112,8 +112,8 @@ private void load() {
IFile old = getOldMetsFile();
if (!f.toFile().exists() && old.exists()) {
try {
-
- System.out.println("moving "+old.getLocation()+" to "+f);
+
+ System.out.println("moving " + old.getLocation() + " to " + f);
old.move(f, true, new NullProgressMonitor());
} catch (CoreException e) {
throw new Error(e);
@@ -121,13 +121,13 @@ private void load() {
}
String uri = f.toFile().toURI().toString();
try {
- log.debug("METS attempting to load existing file:"+uri);
+ log.debug("METS attempting to load existing file:" + uri);
this.metsResource = this.resourceSet.getResource(URI.createURI(uri), true);
((ResourceImpl) this.metsResource).setIntrinsicIDToEObjectMap(new HashMap());
this.metsResource.load(xmlOptions);
log.debug("METS loaded from existing file");
} catch (Exception e) {
- log.debug("METS being created:"+uri);
+ log.debug("METS being created:" + uri);
this.metsResource = this.resourceSet.createResource(URI.createURI(uri));
((ResourceImpl) this.metsResource).setIntrinsicIDToEObjectMap(new HashMap());
DocumentRoot r = METSUtils.createInitialMetsDocument(project.getName() + " Workbench Manifest");
@@ -153,13 +153,15 @@ private void load() {
public IPath getMetsFile() {
ProjectScope scope = new ProjectScope(this.project);
- return scope.getLocation().append(METS_PATH).makeRelativeTo(this.project.getLocation());
+ IPath metsPath = scope.getLocation().append(METS_PATH);
+ System.err.println("METS FILE PATH: "+metsPath);
+ return metsPath;
}
public IFile getOldMetsFile() {
return this.project.getFile(METS_PATH);
}
-
+
public static ComposedAdapterFactory getAdapterFactory() {
return adapterFactory;
}
@@ -202,18 +204,11 @@ public ExtendedMetaData getExtendedMetaData() {
@Override
public void resourceChanged(IResourceChangeEvent event) {
IResource res = event.getResource();
- if (IProject.class.isInstance(res) && IResourceChangeEvent.PRE_CLOSE == event.getType()) {
+ if (project.equals(res) && IResourceChangeEvent.PRE_CLOSE == event.getType()) {
log.debug("Saving EMF session prior to project close.");
- // save the METS before closing..
- try {
- IProject p = (IProject) res;
- ProjectEMFSession session = (ProjectEMFSession) p.getSessionProperty(MetsProjectNature.EMF_SESSION_KEY);
- session.save();
- } catch (CoreException e) {
- e.printStackTrace();
- } finally {
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
- }
+ IProject p = (IProject) res;
+ MetsProjectNature.get(p).getEMFSession().save();
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
}
}
10 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/HasOriginalFilter.java
View
@@ -4,21 +4,21 @@
import org.eclipse.jface.viewers.IFilter;
-import unc.lib.cdr.workbench.originals.Original;
-import unc.lib.cdr.workbench.originals.OriginalsWrapperStore;
+import unc.lib.cdr.workbench.originals.OriginalStub;
+import unc.lib.cdr.workbench.originals.OriginalFileStore;
import unc.lib.cdr.workbench.project.MetsProjectNature;
public class HasOriginalFilter implements IFilter {
@Override
public boolean select(Object toTest) {
- if(toTest instanceof OriginalsWrapperStore) {
+ if(toTest instanceof OriginalFileStore) {
return true;
} else if (toTest instanceof DivType) {
DivType d = (DivType) toTest;
- OriginalsWrapperStore s = MetsProjectNature.getOriginal(d);
+ OriginalFileStore s = MetsProjectNature.getOriginal(d);
return s != null;
- } else if(toTest instanceof Original) {
+ } else if(toTest instanceof OriginalStub) {
return true;
}
return false;
16 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/HasStagedFileFilter.java
View
@@ -4,24 +4,24 @@
import org.eclipse.jface.viewers.IFilter;
-import unc.lib.cdr.workbench.originals.Original;
-import unc.lib.cdr.workbench.originals.OriginalsWrapperStore;
+import unc.lib.cdr.workbench.originals.OriginalStub;
+import unc.lib.cdr.workbench.originals.OriginalFileStore;
import unc.lib.cdr.workbench.project.MetsProjectNature;
public class HasStagedFileFilter implements IFilter {
@Override
public boolean select(Object toTest) {
- OriginalsWrapperStore original = null;
- if(toTest instanceof OriginalsWrapperStore) {
- original = (OriginalsWrapperStore)toTest;
+ OriginalFileStore original = null;
+ if(toTest instanceof OriginalFileStore) {
+ original = (OriginalFileStore)toTest;
} else if (toTest instanceof DivType) {
DivType d = (DivType) toTest;
original = MetsProjectNature.getOriginal(d);
- } else if(toTest instanceof Original) {
- original = ((Original)toTest).getStore();
+ } else if(toTest instanceof OriginalStub) {
+ original = ((OriginalStub)toTest).getStore();
}
- return original.getStagingLocatorType() != null;
+ return original == null ? false : original.getStagingLocatorType() != null;
}
}
4 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/LabelImageFactory.java
View
@@ -33,7 +33,7 @@
import unc.lib.cdr.workbench.arrange.ArrangementProjectElement;
import unc.lib.cdr.workbench.arrange.DivLinkBucket;
-import unc.lib.cdr.workbench.originals.Original;
+import unc.lib.cdr.workbench.originals.OriginalStub;
import unc.lib.cdr.workbench.project.ICustomProjectElement;
import unc.lib.cdr.workbench.rcp.Activator;
import unc.lib.cdr.workbench.stage.StagedFilesProjectElement;
@@ -112,7 +112,7 @@ public static Icon getIconForObject(Object o) {
} else {
result = Icon.File;
}
- } else if (Original.class.isInstance(o)) {
+ } else if (OriginalStub.class.isInstance(o)) {
result = Icon.OriginalsEl;
}
return result;
6 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/OriginalFingerprintSection.java
View
@@ -22,7 +22,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import unc.lib.cdr.workbench.originals.OriginalsWrapperStore;
+import unc.lib.cdr.workbench.originals.OriginalFileStore;
import unc.lib.cdr.workbench.project.MetsProjectNature;
public class OriginalFingerprintSection extends AbstractPropertySection {
@@ -47,8 +47,8 @@ public void setInput(IWorkbenchPart part, ISelection s) {
if(o instanceof DivType) {
DivType div = (DivType)o;
fileType = (FileType)div.eResource().getEObject(div.getFptr().get(0).getFILEID());
- } else if(o instanceof OriginalsWrapperStore) {
- fileType = ((OriginalsWrapperStore)o).getMetsFileType();
+ } else if(o instanceof OriginalFileStore) {
+ fileType = ((OriginalFileStore)o).getMetsFileType();
}
Assert.isTrue(fileType != null);
}
14 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/OriginalResourcePropertySheetSection.java
View
@@ -22,8 +22,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import unc.lib.cdr.workbench.originals.Original;
-import unc.lib.cdr.workbench.originals.OriginalsWrapperStore;
+import unc.lib.cdr.workbench.originals.OriginalStub;
+import unc.lib.cdr.workbench.originals.OriginalFileStore;
import unc.lib.cdr.workbench.project.MetsProjectNature;
public class OriginalResourcePropertySheetSection extends AbstractPropertySection {
@@ -76,15 +76,15 @@ public void controlResized(ControlEvent e) {
public void setInput(IWorkbenchPart part, ISelection selection) {
// LOG.debug("setInput called: " + selection + selection.getClass());
ISelection pageSelect = null;
- OriginalsWrapperStore original = null;
+ OriginalFileStore original = null;
IStructuredSelection s = (IStructuredSelection) selection;
if (s.getFirstElement() instanceof DivType) {
DivType d = (DivType) s.getFirstElement();
original = MetsProjectNature.getOriginal(d);
- } else if(s.getFirstElement() instanceof Original) {
- original = ((Original)s.getFirstElement()).getStore();
- } else if(s.getFirstElement() instanceof OriginalsWrapperStore) {
- original = (OriginalsWrapperStore)s.getFirstElement();
+ } else if(s.getFirstElement() instanceof OriginalStub) {
+ original = ((OriginalStub)s.getFirstElement()).getStore();
+ } else if(s.getFirstElement() instanceof OriginalFileStore) {
+ original = (OriginalFileStore)s.getFirstElement();
}
pageSelect = new ListSelection(Collections.singletonList(original));
page.selectionChanged(part, pageSelect);
22 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/OriginalVolumeSection.java
View
@@ -1,5 +1,7 @@
package unc.lib.cdr.workbench.views;
+import gov.loc.mets.DivType;
+