Skip to content

Commit

Permalink
Version 1.1.0 final
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Stevens committed Oct 23, 2014
1 parent 785a756 commit 94bc196
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 47 deletions.
35 changes: 23 additions & 12 deletions src/org/archiviststoolkit/plugin/dbCopyFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) { }

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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:");
Expand Down Expand Up @@ -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;
Expand Down
33 changes: 5 additions & 28 deletions src/org/archiviststoolkit/plugin/dbCopyFrame.jfd
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<string>javax.swing.JLabel</string>
<void method="setProperty">
<string>text</string>
<string> Archives Space Version: v1.0.9</string>
<string> Archives Space Version: v1.0.9 - v1.1.x</string>
</void>
<void method="setProperty">
<string>horizontalTextPosition</string>
Expand Down Expand Up @@ -1091,34 +1091,11 @@
</void>
<void method="add">
<object class="com.jformdesigner.model.FormComponent">
<string>javax.swing.JLabel</string>
<string>javax.swing.JTextField</string>
<void method="setProperty">
<string>text</string>
<string>Resources To Copy </string>
</void>
<void property="name">
<string>resourcesToCopyLabel</string>
</void>
</object>
<object class="com.jformdesigner.model.FormLayoutConstraints">
<class>com.jgoodies.forms.layout.CellConstraints</class>
<void method="setProperty">
<string>gridX</string>
<int>3</int>
</void>
<void method="setProperty">
<string>gridY</string>
<int>21</int>
<string>-refid_unique</string>
</void>
<void method="setProperty">
<string>gridWidth</string>
<int>5</int>
</void>
</object>
</void>
<void method="add">
<object class="com.jformdesigner.model.FormComponent">
<string>javax.swing.JTextField</string>
<void property="name">
<string>resourcesToCopyTextField</string>
</void>
Expand All @@ -1127,15 +1104,15 @@
<class>com.jgoodies.forms.layout.CellConstraints</class>
<void method="setProperty">
<string>gridX</string>
<int>7</int>
<int>3</int>
</void>
<void method="setProperty">
<string>gridY</string>
<int>21</int>
</void>
<void method="setProperty">
<string>gridWidth</string>
<int>7</int>
<int>11</int>
</void>
</object>
</void>
Expand Down
24 changes: 24 additions & 0 deletions src/org/archiviststoolkit/plugin/utils/aspace/ASpaceCopyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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
*
Expand Down
34 changes: 27 additions & 7 deletions src/org/archiviststoolkit/plugin/utils/aspace/ASpaceMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 94bc196

Please sign in to comment.