1 | /**
|
---|
2 | *#########################################################################
|
---|
3 | *
|
---|
4 | * A component of the Gatherer application, part of the Greenstone digital
|
---|
5 | * library suite from the New Zealand Digital Library Project at the
|
---|
6 | * University of Waikato, New Zealand.
|
---|
7 | *
|
---|
8 | * <BR><BR>
|
---|
9 | *
|
---|
10 | * Author: John Thompson, Greenstone Digital Library, University of Waikato
|
---|
11 | *
|
---|
12 | * <BR><BR>
|
---|
13 | *
|
---|
14 | * Copyright (C) 1999 New Zealand Digital Library Project
|
---|
15 | *
|
---|
16 | * <BR><BR>
|
---|
17 | *
|
---|
18 | * This program is free software; you can redistribute it and/or modify
|
---|
19 | * it under the terms of the GNU General Public License as published by
|
---|
20 | * the Free Software Foundation; either version 2 of the License, or
|
---|
21 | * (at your option) any later version.
|
---|
22 | *
|
---|
23 | * <BR><BR>
|
---|
24 | *
|
---|
25 | * This program is distributed in the hope that it will be useful,
|
---|
26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
28 | * GNU General Public License for more details.
|
---|
29 | *
|
---|
30 | * <BR><BR>
|
---|
31 | *
|
---|
32 | * You should have received a copy of the GNU General Public License
|
---|
33 | * along with this program; if not, write to the Free Software
|
---|
34 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
35 | *########################################################################
|
---|
36 | */
|
---|
37 |
|
---|
38 |
|
---|
39 |
|
---|
40 |
|
---|
41 |
|
---|
42 |
|
---|
43 | package org.greenstone.gatherer.msm;
|
---|
44 | /**
|
---|
45 | * Title: The Gatherer<br>
|
---|
46 | * Description: The Gatherer: a tool for gathering and enriching digital collections.<br>
|
---|
47 | * Copyright: Copyright (c) 2001<br>
|
---|
48 | * Company: The University of Waikato<br>
|
---|
49 | * Written: /04/02<br>
|
---|
50 | * @author John Thompson, Greenstone Digital Libraries
|
---|
51 | * @version 2.1
|
---|
52 | */
|
---|
53 | import org.greenstone.gatherer.msm.Declarations;
|
---|
54 | import org.greenstone.gatherer.msm.MetadataSetManager;
|
---|
55 | /** This class provides all the information required to correctly perform metadata actions, with regard to the users previously indicated preferences in terms of importing and renaming. */
|
---|
56 | final public class MSMAction {
|
---|
57 | private boolean hfile = false;
|
---|
58 | /** The type of action required in subsequent actions involving the specified set and source element. */
|
---|
59 | private int action = Declarations.NO_ACTION;
|
---|
60 | private String set = null;
|
---|
61 | private String source = null;
|
---|
62 | /** The fully qualified name of the target element (which must be currently in the loaded metadata sets, otherwise the set it belongs to cannot be determined. */
|
---|
63 | private String target = null;
|
---|
64 | /** Constructor. Note that the standard action FORCE_MERGE is only named so for clarity and is translated into its actual action RENAME when this profile is created.
|
---|
65 | * @param action An <i>int</i> representing what action needs to be taken in subsequent access of the given set and source element.
|
---|
66 | * @param target A <strong>String</strong> representing the fully qualified name of the target element.
|
---|
67 | * @param hfile If this action was created from the hfile parsing stage, does the element require a replacement to change its alias value into a real one. Note that this profile item may be created for fully namespaced elements as well, to ensure aliases are always remapped.
|
---|
68 | */
|
---|
69 | public MSMAction(int action, String target) {
|
---|
70 | this.target = target;
|
---|
71 | switch(action) {
|
---|
72 | case Declarations.DELETE:
|
---|
73 | this.action = action;
|
---|
74 | break;
|
---|
75 | case Declarations.FORCE_MERGE:
|
---|
76 | this.action = Declarations.RENAME;
|
---|
77 | break;
|
---|
78 | case Declarations.RENAME:
|
---|
79 | this.action = action;
|
---|
80 | break;
|
---|
81 | case Declarations.SKIP:
|
---|
82 | this.action = action;
|
---|
83 | this.target = null;
|
---|
84 | break;
|
---|
85 | default:
|
---|
86 | this.action = Declarations.NO_ACTION;
|
---|
87 | }
|
---|
88 | }
|
---|
89 | /** Constructor. Note that the standard action FORCE_MERGE is only named so for clarity and is translated into its actual action RENAME when this profile is created.
|
---|
90 | * @param action An <i>int</i> representing what action needs to be taken in subsequent access of the given set and source element.
|
---|
91 | * @param target A <strong>String</strong> representing the fully qualified name of the target element.
|
---|
92 | * @param hfile If this action was created from the hfile parsing stage, does the element require a replacement to change its alias value into a real one. Note that this profile item may be created for fully namespaced elements as well, to ensure aliases are always remapped.
|
---|
93 | */
|
---|
94 | public MSMAction(int action, String target, boolean hfile) {
|
---|
95 | this.hfile = hfile;
|
---|
96 | this.target = target;
|
---|
97 | switch(action) {
|
---|
98 | case Declarations.FORCE_MERGE:
|
---|
99 | this.action = Declarations.RENAME;
|
---|
100 | break;
|
---|
101 | case Declarations.RENAME:
|
---|
102 | this.action = action;
|
---|
103 | break;
|
---|
104 | case Declarations.SKIP:
|
---|
105 | this.action = action;
|
---|
106 | this.target = null;
|
---|
107 | break;
|
---|
108 | default:
|
---|
109 | this.action = Declarations.NO_ACTION;
|
---|
110 | }
|
---|
111 | }
|
---|
112 |
|
---|
113 | public MSMAction(String set, String source, int action, String target) {
|
---|
114 | this(action, target);
|
---|
115 | this.set = set;
|
---|
116 | this.source = source;
|
---|
117 | }
|
---|
118 |
|
---|
119 | /** Method for retrieving the appropriate action from this class.
|
---|
120 | * @return An <i>int</i> specifying a particular action.
|
---|
121 | */
|
---|
122 | public int getAction() {
|
---|
123 | return action;
|
---|
124 | }
|
---|
125 | public String getSet() {
|
---|
126 | return set;
|
---|
127 | }
|
---|
128 | public String getSource() {
|
---|
129 | return source;
|
---|
130 | }
|
---|
131 | /** Method for retrieving the target element of this action.
|
---|
132 | * @return A <strong>String</strong> stating the fully qualified name of the target element, within the namespace of one of the currently loaded metadata sets.
|
---|
133 | */
|
---|
134 | public String getTarget() {
|
---|
135 | return target;
|
---|
136 | }
|
---|
137 | public boolean isHFile() {
|
---|
138 | return hfile;
|
---|
139 | }
|
---|
140 | }
|
---|