From 94bc19676944bd8a178b57041180dd83ac762656 Mon Sep 17 00:00:00 2001 From: Nathan Stevens Date: Thu, 23 Oct 2014 09:21:22 -0400 Subject: [PATCH] Version 1.1.0 final --- .../archiviststoolkit/plugin/dbCopyFrame.java | 35 ++++++++++++------- .../archiviststoolkit/plugin/dbCopyFrame.jfd | 33 +++-------------- .../plugin/utils/aspace/ASpaceCopyUtil.java | 24 +++++++++++++ .../plugin/utils/aspace/ASpaceMapper.java | 34 ++++++++++++++---- 4 files changed, 79 insertions(+), 47 deletions(-) diff --git a/src/org/archiviststoolkit/plugin/dbCopyFrame.java b/src/org/archiviststoolkit/plugin/dbCopyFrame.java index 15865a9..156af4c 100644 --- a/src/org/archiviststoolkit/plugin/dbCopyFrame.java +++ b/src/org/archiviststoolkit/plugin/dbCopyFrame.java @@ -33,7 +33,7 @@ * @author Nathan Stevens */ public class dbCopyFrame extends JFrame { - public static final String VERSION = "Archives Space Data Migrator v1.0.9.4 (08-25-2014)"; + public static final String VERSION = "Archives Space Data Migrator v1.1.0 (10-21-2014)"; // The application when running within the AT private ApplicationFrame mainFrame = null; @@ -123,8 +123,7 @@ private void hideAdvanceFeatures() { numResourceToCopyLabel.setVisible(false); numResourceToCopyTextField.setVisible(false); deleteResourcesCheckBox.setVisible(false); - resourcesToCopyLabel.setVisible(false); - resourcesToCopyTextField.setVisible(false); + //resourcesToCopyTextField.setVisible(false); recordURIComboBox.setVisible(false); paramsLabel.setVisible(false); paramsTextField.setVisible(false); @@ -352,10 +351,17 @@ public void run() { if(!ids.isEmpty()) { String[] sa = ids.split("\\s*,\\s*"); for(String id: sa) { - resourcesIDsList.add(id); + // check to see if we not dealing with a special command + if(!id.startsWith("-")) { + resourcesIDsList.add(id); + } else { + processSpecialOption(ascopy, id); + } } - resourcesToCopy = resourcesIDsList.size(); + if(!resourcesIDsList.isEmpty()) { + resourcesToCopy = resourcesIDsList.size(); + } } } catch (NumberFormatException nfe) { } @@ -393,6 +399,14 @@ public void run() { performer.start(); } + /** + * Method to process special commands access + */ + private void processSpecialOption(ASpaceCopyUtil ascopy, String option) { + // only command we support for now is whether to make the refid unique or not + ascopy.setRefIdOption(option); + } + /** * Method to start the a thread that will look for and attempt to fix * repository mismatches @@ -743,7 +757,6 @@ private void initComponents() { numResourceToCopyLabel = new JLabel(); numResourceToCopyTextField = new JTextField(); deleteResourcesCheckBox = new JCheckBox(); - resourcesToCopyLabel = new JLabel(); resourcesToCopyTextField = new JTextField(); outputConsoleLabel = new JLabel(); copyProgressBar = new JProgressBar(); @@ -824,7 +837,7 @@ private void initComponents() { })); //---- apiLabel ---- - apiLabel.setText(" Archives Space Version: v1.0.9"); + apiLabel.setText(" Archives Space Version: v1.0.9 - v1.1.x"); apiLabel.setHorizontalTextPosition(SwingConstants.CENTER); contentPanel.add(apiLabel, cc.xy(1, 1)); @@ -1039,10 +1052,9 @@ public void actionPerformed(ActionEvent e) { deleteResourcesCheckBox.setText("Delete Previously Saved Resources"); contentPanel.add(deleteResourcesCheckBox, cc.xy(1, 21)); - //---- resourcesToCopyLabel ---- - resourcesToCopyLabel.setText("Resources To Copy "); - contentPanel.add(resourcesToCopyLabel, cc.xywh(3, 21, 5, 1)); - contentPanel.add(resourcesToCopyTextField, cc.xywh(7, 21, 7, 1)); + //---- resourcesToCopyTextField ---- + resourcesToCopyTextField.setText("-refid_unique"); + contentPanel.add(resourcesToCopyTextField, cc.xywh(3, 21, 11, 1)); //---- outputConsoleLabel ---- outputConsoleLabel.setText("Output Console:"); @@ -1229,7 +1241,6 @@ public void actionPerformed(ActionEvent e) { private JLabel numResourceToCopyLabel; private JTextField numResourceToCopyTextField; private JCheckBox deleteResourcesCheckBox; - private JLabel resourcesToCopyLabel; private JTextField resourcesToCopyTextField; private JLabel outputConsoleLabel; private JProgressBar copyProgressBar; diff --git a/src/org/archiviststoolkit/plugin/dbCopyFrame.jfd b/src/org/archiviststoolkit/plugin/dbCopyFrame.jfd index ab870a0..13f3790 100644 --- a/src/org/archiviststoolkit/plugin/dbCopyFrame.jfd +++ b/src/org/archiviststoolkit/plugin/dbCopyFrame.jfd @@ -51,7 +51,7 @@ javax.swing.JLabel text - Archives Space Version: v1.0.9 + Archives Space Version: v1.0.9 - v1.1.x horizontalTextPosition @@ -1091,34 +1091,11 @@ - javax.swing.JLabel + javax.swing.JTextField text - Resources To Copy - - - resourcesToCopyLabel - - - - com.jgoodies.forms.layout.CellConstraints - - gridX - 3 - - - gridY - 21 + -refid_unique - - gridWidth - 5 - - - - - - javax.swing.JTextField resourcesToCopyTextField @@ -1127,7 +1104,7 @@ com.jgoodies.forms.layout.CellConstraints gridX - 7 + 3 gridY @@ -1135,7 +1112,7 @@ gridWidth - 7 + 11 diff --git a/src/org/archiviststoolkit/plugin/utils/aspace/ASpaceCopyUtil.java b/src/org/archiviststoolkit/plugin/utils/aspace/ASpaceCopyUtil.java index 09d8aff..b101d63 100644 --- a/src/org/archiviststoolkit/plugin/utils/aspace/ASpaceCopyUtil.java +++ b/src/org/archiviststoolkit/plugin/utils/aspace/ASpaceCopyUtil.java @@ -168,6 +168,13 @@ public class ASpaceCopyUtil { // A string builder object to track errors private StringBuilder errorBuffer = new StringBuilder(); + // String which specifies how ref_ids are to be handled. The options are below + public static final String REFID_ORIGINAL = "-refid_original"; + public static final String REFID_UNIQUE = "-refid_unique"; + public static final String REFID_NONE = "-refid_none"; + + private String refIdOption = REFID_UNIQUE; + /** * The main constructor, used when running as a stand alone application * @@ -248,6 +255,23 @@ public void setResetPassword(String resetPassword) { this.resetPassword = resetPassword; } + /** + * Method to set the ref id option + * @param option + */ + public void setRefIdOption(String option) { + refIdOption = option; + } + + /** + * Method to return the ref id options + * + * @return + */ + public String getRefIdOption() { + return refIdOption; + } + /** * Method to set the output console * diff --git a/src/org/archiviststoolkit/plugin/utils/aspace/ASpaceMapper.java b/src/org/archiviststoolkit/plugin/utils/aspace/ASpaceMapper.java index 73abfa0..123c4cc 100644 --- a/src/org/archiviststoolkit/plugin/utils/aspace/ASpaceMapper.java +++ b/src/org/archiviststoolkit/plugin/utils/aspace/ASpaceMapper.java @@ -242,10 +242,13 @@ public String convertSubject(Subjects record) throws Exception { json.put("publish", publishHashMap.get("subjects")); // set the subject source - String source = record.getSubjectSource(); - if(!source.isEmpty()) { - source = enumUtil.getASpaceSubjectSource(record.getSubjectSource()); + String source = record.getSubjectSource().trim(); + source = enumUtil.getASpaceSubjectSource(source); + if(source != null && !source.isEmpty()) { json.put("source", source); + } else { + // source is now required in ASpace v1.1.0 + json.put("source", "local"); } // set the subject terms and term type @@ -1463,8 +1466,17 @@ private JSONObject convertResourceComponent(ResourcesComponents record) throws E /* add field required for archival_object.rb */ - // make the ref id unique otherwise ASpace complains - String refId = record.getPersistentId() + "_" + randomString.nextString(); + // see if to make the ref id unique, leave blank, or just use the original (default) + String refId; + + if(aspaceCopyUtil.getRefIdOption().equalsIgnoreCase(ASpaceCopyUtil.REFID_UNIQUE)) { + refId = record.getPersistentId() + "_" + randomString.nextString(); + } else if(aspaceCopyUtil.getRefIdOption().equalsIgnoreCase(ASpaceCopyUtil.REFID_NONE)) { + refId = ""; + } else { + refId = record.getPersistentId(); + } + json.put("ref_id", refId); String level = enumUtil.getASpaceArchivalObjectLevel(record.getLevel()); @@ -1814,7 +1826,12 @@ public void addNotes(JSONArray notesJA, ArchDescription record) throws Exception JSONObject noteJS = new JSONObject(); noteJS.put("label", note.getTitle()); - noteJS.put("publish", !note.getInternalOnly()); + + if(note.getInternalOnly() != null) { + noteJS.put("publish", !note.getInternalOnly()); + } else { + noteJS.put("publish", true); + } // se if to add any content if(note.getContent() != null && !note.getContent().isEmpty()) { @@ -2308,9 +2325,12 @@ private String fixUrl(String url) { // check to see if its a proper uri format if(lowercaseUrl.contains("://")) { return url; - } else if(lowercaseUrl.startsWith("/") || lowercaseUrl.contains(":\\")) { + } else if(lowercaseUrl.startsWith("/")) { url = "file://" + url; return url; + } else if(lowercaseUrl.contains(":\\")) { + url = "file:///" + url; + return url; } else { url = "http://" + url; return url;