Skip to content

Commit 94bc196

Browse files
author
Nathan Stevens
committed
Version 1.1.0 final
1 parent 785a756 commit 94bc196

4 files changed

Lines changed: 79 additions & 47 deletions

File tree

src/org/archiviststoolkit/plugin/dbCopyFrame.java

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* @author Nathan Stevens
3434
*/
3535
public class dbCopyFrame extends JFrame {
36-
public static final String VERSION = "Archives Space Data Migrator v1.0.9.4 (08-25-2014)";
36+
public static final String VERSION = "Archives Space Data Migrator v1.1.0 (10-21-2014)";
3737

3838
// The application when running within the AT
3939
private ApplicationFrame mainFrame = null;
@@ -123,8 +123,7 @@ private void hideAdvanceFeatures() {
123123
numResourceToCopyLabel.setVisible(false);
124124
numResourceToCopyTextField.setVisible(false);
125125
deleteResourcesCheckBox.setVisible(false);
126-
resourcesToCopyLabel.setVisible(false);
127-
resourcesToCopyTextField.setVisible(false);
126+
//resourcesToCopyTextField.setVisible(false);
128127
recordURIComboBox.setVisible(false);
129128
paramsLabel.setVisible(false);
130129
paramsTextField.setVisible(false);
@@ -352,10 +351,17 @@ public void run() {
352351
if(!ids.isEmpty()) {
353352
String[] sa = ids.split("\\s*,\\s*");
354353
for(String id: sa) {
355-
resourcesIDsList.add(id);
354+
// check to see if we not dealing with a special command
355+
if(!id.startsWith("-")) {
356+
resourcesIDsList.add(id);
357+
} else {
358+
processSpecialOption(ascopy, id);
359+
}
356360
}
357361

358-
resourcesToCopy = resourcesIDsList.size();
362+
if(!resourcesIDsList.isEmpty()) {
363+
resourcesToCopy = resourcesIDsList.size();
364+
}
359365
}
360366
} catch (NumberFormatException nfe) { }
361367

@@ -393,6 +399,14 @@ public void run() {
393399
performer.start();
394400
}
395401

402+
/**
403+
* Method to process special commands access
404+
*/
405+
private void processSpecialOption(ASpaceCopyUtil ascopy, String option) {
406+
// only command we support for now is whether to make the refid unique or not
407+
ascopy.setRefIdOption(option);
408+
}
409+
396410
/**
397411
* Method to start the a thread that will look for and attempt to fix
398412
* repository mismatches
@@ -743,7 +757,6 @@ private void initComponents() {
743757
numResourceToCopyLabel = new JLabel();
744758
numResourceToCopyTextField = new JTextField();
745759
deleteResourcesCheckBox = new JCheckBox();
746-
resourcesToCopyLabel = new JLabel();
747760
resourcesToCopyTextField = new JTextField();
748761
outputConsoleLabel = new JLabel();
749762
copyProgressBar = new JProgressBar();
@@ -824,7 +837,7 @@ private void initComponents() {
824837
}));
825838

826839
//---- apiLabel ----
827-
apiLabel.setText(" Archives Space Version: v1.0.9");
840+
apiLabel.setText(" Archives Space Version: v1.0.9 - v1.1.x");
828841
apiLabel.setHorizontalTextPosition(SwingConstants.CENTER);
829842
contentPanel.add(apiLabel, cc.xy(1, 1));
830843

@@ -1039,10 +1052,9 @@ public void actionPerformed(ActionEvent e) {
10391052
deleteResourcesCheckBox.setText("Delete Previously Saved Resources");
10401053
contentPanel.add(deleteResourcesCheckBox, cc.xy(1, 21));
10411054

1042-
//---- resourcesToCopyLabel ----
1043-
resourcesToCopyLabel.setText("Resources To Copy ");
1044-
contentPanel.add(resourcesToCopyLabel, cc.xywh(3, 21, 5, 1));
1045-
contentPanel.add(resourcesToCopyTextField, cc.xywh(7, 21, 7, 1));
1055+
//---- resourcesToCopyTextField ----
1056+
resourcesToCopyTextField.setText("-refid_unique");
1057+
contentPanel.add(resourcesToCopyTextField, cc.xywh(3, 21, 11, 1));
10461058

10471059
//---- outputConsoleLabel ----
10481060
outputConsoleLabel.setText("Output Console:");
@@ -1229,7 +1241,6 @@ public void actionPerformed(ActionEvent e) {
12291241
private JLabel numResourceToCopyLabel;
12301242
private JTextField numResourceToCopyTextField;
12311243
private JCheckBox deleteResourcesCheckBox;
1232-
private JLabel resourcesToCopyLabel;
12331244
private JTextField resourcesToCopyTextField;
12341245
private JLabel outputConsoleLabel;
12351246
private JProgressBar copyProgressBar;

src/org/archiviststoolkit/plugin/dbCopyFrame.jfd

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<string>javax.swing.JLabel</string>
5252
<void method="setProperty">
5353
<string>text</string>
54-
<string> Archives Space Version: v1.0.9</string>
54+
<string> Archives Space Version: v1.0.9 - v1.1.x</string>
5555
</void>
5656
<void method="setProperty">
5757
<string>horizontalTextPosition</string>
@@ -1091,34 +1091,11 @@
10911091
</void>
10921092
<void method="add">
10931093
<object class="com.jformdesigner.model.FormComponent">
1094-
<string>javax.swing.JLabel</string>
1094+
<string>javax.swing.JTextField</string>
10951095
<void method="setProperty">
10961096
<string>text</string>
1097-
<string>Resources To Copy </string>
1098-
</void>
1099-
<void property="name">
1100-
<string>resourcesToCopyLabel</string>
1101-
</void>
1102-
</object>
1103-
<object class="com.jformdesigner.model.FormLayoutConstraints">
1104-
<class>com.jgoodies.forms.layout.CellConstraints</class>
1105-
<void method="setProperty">
1106-
<string>gridX</string>
1107-
<int>3</int>
1108-
</void>
1109-
<void method="setProperty">
1110-
<string>gridY</string>
1111-
<int>21</int>
1097+
<string>-refid_unique</string>
11121098
</void>
1113-
<void method="setProperty">
1114-
<string>gridWidth</string>
1115-
<int>5</int>
1116-
</void>
1117-
</object>
1118-
</void>
1119-
<void method="add">
1120-
<object class="com.jformdesigner.model.FormComponent">
1121-
<string>javax.swing.JTextField</string>
11221099
<void property="name">
11231100
<string>resourcesToCopyTextField</string>
11241101
</void>
@@ -1127,15 +1104,15 @@
11271104
<class>com.jgoodies.forms.layout.CellConstraints</class>
11281105
<void method="setProperty">
11291106
<string>gridX</string>
1130-
<int>7</int>
1107+
<int>3</int>
11311108
</void>
11321109
<void method="setProperty">
11331110
<string>gridY</string>
11341111
<int>21</int>
11351112
</void>
11361113
<void method="setProperty">
11371114
<string>gridWidth</string>
1138-
<int>7</int>
1115+
<int>11</int>
11391116
</void>
11401117
</object>
11411118
</void>

src/org/archiviststoolkit/plugin/utils/aspace/ASpaceCopyUtil.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ public class ASpaceCopyUtil {
168168
// A string builder object to track errors
169169
private StringBuilder errorBuffer = new StringBuilder();
170170

171+
// String which specifies how ref_ids are to be handled. The options are below
172+
public static final String REFID_ORIGINAL = "-refid_original";
173+
public static final String REFID_UNIQUE = "-refid_unique";
174+
public static final String REFID_NONE = "-refid_none";
175+
176+
private String refIdOption = REFID_UNIQUE;
177+
171178
/**
172179
* The main constructor, used when running as a stand alone application
173180
*
@@ -248,6 +255,23 @@ public void setResetPassword(String resetPassword) {
248255
this.resetPassword = resetPassword;
249256
}
250257

258+
/**
259+
* Method to set the ref id option
260+
* @param option
261+
*/
262+
public void setRefIdOption(String option) {
263+
refIdOption = option;
264+
}
265+
266+
/**
267+
* Method to return the ref id options
268+
*
269+
* @return
270+
*/
271+
public String getRefIdOption() {
272+
return refIdOption;
273+
}
274+
251275
/**
252276
* Method to set the output console
253277
*

src/org/archiviststoolkit/plugin/utils/aspace/ASpaceMapper.java

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,13 @@ public String convertSubject(Subjects record) throws Exception {
242242
json.put("publish", publishHashMap.get("subjects"));
243243

244244
// set the subject source
245-
String source = record.getSubjectSource();
246-
if(!source.isEmpty()) {
247-
source = enumUtil.getASpaceSubjectSource(record.getSubjectSource());
245+
String source = record.getSubjectSource().trim();
246+
source = enumUtil.getASpaceSubjectSource(source);
247+
if(source != null && !source.isEmpty()) {
248248
json.put("source", source);
249+
} else {
250+
// source is now required in ASpace v1.1.0
251+
json.put("source", "local");
249252
}
250253

251254
// set the subject terms and term type
@@ -1463,8 +1466,17 @@ private JSONObject convertResourceComponent(ResourcesComponents record) throws E
14631466

14641467
/* add field required for archival_object.rb */
14651468

1466-
// make the ref id unique otherwise ASpace complains
1467-
String refId = record.getPersistentId() + "_" + randomString.nextString();
1469+
// see if to make the ref id unique, leave blank, or just use the original (default)
1470+
String refId;
1471+
1472+
if(aspaceCopyUtil.getRefIdOption().equalsIgnoreCase(ASpaceCopyUtil.REFID_UNIQUE)) {
1473+
refId = record.getPersistentId() + "_" + randomString.nextString();
1474+
} else if(aspaceCopyUtil.getRefIdOption().equalsIgnoreCase(ASpaceCopyUtil.REFID_NONE)) {
1475+
refId = "";
1476+
} else {
1477+
refId = record.getPersistentId();
1478+
}
1479+
14681480
json.put("ref_id", refId);
14691481

14701482
String level = enumUtil.getASpaceArchivalObjectLevel(record.getLevel());
@@ -1814,7 +1826,12 @@ public void addNotes(JSONArray notesJA, ArchDescription record) throws Exception
18141826
JSONObject noteJS = new JSONObject();
18151827

18161828
noteJS.put("label", note.getTitle());
1817-
noteJS.put("publish", !note.getInternalOnly());
1829+
1830+
if(note.getInternalOnly() != null) {
1831+
noteJS.put("publish", !note.getInternalOnly());
1832+
} else {
1833+
noteJS.put("publish", true);
1834+
}
18181835

18191836
// se if to add any content
18201837
if(note.getContent() != null && !note.getContent().isEmpty()) {
@@ -2308,9 +2325,12 @@ private String fixUrl(String url) {
23082325
// check to see if its a proper uri format
23092326
if(lowercaseUrl.contains("://")) {
23102327
return url;
2311-
} else if(lowercaseUrl.startsWith("/") || lowercaseUrl.contains(":\\")) {
2328+
} else if(lowercaseUrl.startsWith("/")) {
23122329
url = "file://" + url;
23132330
return url;
2331+
} else if(lowercaseUrl.contains(":\\")) {
2332+
url = "file:///" + url;
2333+
return url;
23142334
} else {
23152335
url = "http://" + url;
23162336
return url;

0 commit comments

Comments
 (0)