Revision 1173

tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 1173)
23 23
import org.txm.core.preferences.TBXPreferences;
24 24
import org.txm.core.preferences.TXMPreferences;
25 25
import org.txm.objects.Project;
26
import org.txm.objects.Workspace;
27
import org.txm.stat.utils.LogMonitor;
26 28
import org.txm.utils.logger.Log;
27 29

  
28 30
// FIXME: At this moment, an empty list is created for children, to not return
......
1159 1161
	}
1160 1162

  
1161 1163
	/**
1162
	 * Deletes all non persistent results.
1164
	 * Deletes all non persistent results and save the results to persist.
1163 1165
	 */
1164 1166
	public static void deleteAllNonPersistentResults() {
1165 1167
		List<TXMResult> results = Toolbox.workspace.getDeepChildren();
......
1787 1789
	 * @throws Exception
1788 1790
	 */
1789 1791
	public boolean compute() {
1790
		return this.compute(null);
1792
		return this.compute(new LogMonitor("Computing "+this));
1791 1793
	}
1792 1794

  
1793 1795

  
......
1834 1836
			// TODO where do we put this parent compute ? :o
1835 1837
			//		if (parent != null && !parent.getHasBeenComputedOnce()) { // parent must be computed at least one time
1836 1838
			// SJ: other way, test the object itself
1837
			// FIXME: this code shoud be moved back in the !skipComputing section ?
1838
			if (this.parent != null && !(this.parent instanceof Project)) {
1839
			// FIXME: this code should be moved back in the !skipComputing section ?
1840
			if (this.parent != null && !(this.parent instanceof Project) && !(this.parent instanceof Workspace)) {
1839 1841

  
1840 1842
				Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": starting parent (" + this.parent.getClass().getSimpleName() + ") computing process...");
1841 1843

  
tmp/org.txm.core/src/java/org/txm/objects/Project.java (revision 1173)
178 178
	 */
179 179
	public Project(Workspace workspace, String name) throws Exception {
180 180
		super("project/" + name + "/" + createUUID() + "_Project", workspace);
181
		
181 182
		this.internalPersistable = true;
182 183
		this.pName = name;
183 184
		this.dirty = false;
......
196 197
		super(parametersNodePath);
197 198
		initRCPStuffs();
198 199

  
200
		this.internalPersistable = true;
199 201
		this.dirty = false;
200 202
		this.hasBeenComputedOnce = true;
201 203
		this.setVisible(false);
......
211 213
		//		}
212 214
		//		
213 215
		//		this.scope = new BasePreferenceScope(this);
214
		
216

  
215 217
		// reloading existing results
216 218
		this.loadResults();
217 219
	}
......
706 708

  
707 709
		return true;
708 710
	}
709
	
711

  
710 712
	@Override
711 713
	public boolean loadParameters() throws Exception {
712 714

  
......
1094 1096
	public static void loadTXMResultsFromProjectScope(IProject rcpProject) {
1095 1097
		//IScopeContext projectScope = new ProjectScope(projects[i]);
1096 1098
		ArrayList<String> resultNodePaths = TXMPreferences.getAllResultsNodePaths("project/" + rcpProject.getName() + "/");
1097
		
1099

  
1098 1100
		Log.info("Toolbox.initialize(): loading project " + rcpProject.getName() + "...");
1099 1101
		Log.info("Toolbox.initialize(): " + resultNodePaths.size() + " node(s) found in project " + rcpProject.getName() + "...");
1100
		
1102

  
1101 1103
		for (String parametersNodePath : resultNodePaths) {
1102 1104

  
1103 1105
			// skip non-TXMResult preference node
1104
//			if (TXMPreferences.getString(TXMPreferences.BUNDLE_ID, nodeQualifier).isEmpty())	{
1105
//				continue;
1106
//			}
1106
			//			if (TXMPreferences.getString(TXMPreferences.BUNDLE_ID, nodeQualifier).isEmpty())	{
1107
			//				continue;
1108
			//			}
1107 1109

  
1108 1110
			try {
1109 1111

  
1110 1112
				Log.finest("Toolbox.initialize(): checking result type linked to node path " + parametersNodePath);
1111
				
1113

  
1112 1114
				String className = TXMPreferences.preferencesRootNode.node(parametersNodePath).get("class", ""); //$NON-NLS-1$
1113
				
1115

  
1114 1116
				if(!className.equals(Project.class.getName()))	{ // already constructed
1115
				//	Log.finest("Toolbox.initialize(): not a project, result skipped (classame = " + className + ").");
1117
					//	Log.finest("Toolbox.initialize(): not a project, result skipped (classame = " + className + ").");
1116 1118
					continue;
1117 1119
				}
1118
				
1120

  
1119 1121
				Log.finest("Toolbox.initialize(): loading from result node path " + parametersNodePath);
1120 1122
				//Log.finest("Toolbox.initialize(): class = " + TXMPreferences.getString("class", nodeQualifier));
1121 1123
				//TXMPreferences.dump();
1122
				
1124

  
1123 1125
				Log.finest("Toolbox.initialize(): class = " + className); //$NON-NLS-1$
1124 1126
				Log.finest("Toolbox.initialize(): parent_uuid = " + TXMPreferences.preferencesRootNode.node(parametersNodePath).get(TXMPreferences.PARENT_UUID, "")); //$NON-NLS-1$
1125 1127
				String bundleId = TXMPreferences.preferencesRootNode.node(parametersNodePath).get(TXMPreferences.BUNDLE_ID, ""); //$NON-NLS-1$
......
1129 1131
					Log.finest("Warning: can not restore object with bundle name " + bundleId); //$NON-NLS-1$
1130 1132
					continue;
1131 1133
				}
1132
				
1134

  
1133 1135
				Log.info("Toolbox.initialize(): creating project " + rcpProject.getName() + ".");
1134 1136
				Class<?> cl = bundle.loadClass(className);
1135 1137
				Constructor<?> cons = cl.getConstructor(String.class);
1136 1138
				TXMResult result = (TXMResult) cons.newInstance(parametersNodePath);
1137
				
1139

  
1138 1140
				// not an internal persistence (eg. corpus or partition)
1139 1141
				if (!result.isInternalPersistable())	{
1140 1142
					result.setUserPersistable(true);	
......
1145 1147
			}
1146 1148
		}
1147 1149
	}
1148
	
1150

  
1151
	/**
1152
	 * store parameters and save in the properties files
1153
	 * 
1154
	 * @return
1155
	 */
1149 1156
	public boolean save() {
1150 1157
		try {
1151 1158
			autoSaveParametersFromAnnotations();
1152
			saveParameters(true);
1159
			saveParameters();
1160
			List<TXMResult> results = this.getDeepChildren();
1161
			for (int i = 0; i < results.size(); i++) {
1162
				TXMResult r = results.get(i);
1163
				if (r.mustBePersisted())	{ 
1164
					r.autoSaveParametersFromAnnotations();
1165
					r.saveParameters();
1166
					TXMPreferences.flush(r);
1167
				}
1168
			}
1153 1169
		} catch (Exception e) {
1154
			// TODO Auto-generated catch block
1155 1170
			e.printStackTrace();
1171
			return false;
1156 1172
		}
1157 1173
		return true;
1158 1174
	}
tmp/org.txm.core/src/java/org/txm/objects/Text.java (revision 1173)
62 62
	 */
63 63
	public Text(Project project) {
64 64
		super(project);
65
		
65 66
		this.setVisible(false);
66 67
		this.internalPersistable = true;
67 68
	}
......
74 75
	 */
75 76
	public Text(String parametersNodePath) {
76 77
		super(parametersNodePath);
78
		
77 79
		this.setVisible(false);
78 80
		this.internalPersistable = true;
79 81
	}
......
100 102
			ed.setIndex(pdf);
101 103
		} catch (Exception e2) {	} 
102 104
		
103
		pName = e.getAttribute("name"); //$NON-NLS-1$
105
		userName = pName = e.getAttribute("name"); //$NON-NLS-1$
104 106
		
105 107
		Element editionsnode = (Element) e.getElementsByTagName("editions").item(0); //$NON-NLS-1$
106 108
		NodeList editionList = editionsnode.getElementsByTagName("edition"); //$NON-NLS-1$
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/LoadBinaryCorporaDirectory.java (revision 1173)
134 134
					public void run() {
135 135
						
136 136
						for (Project newProject2 : newProjects) {
137
							newProject2.save();
137
							newProject2.compute();
138 138
						}
139 139
						
140 140
						RestartTXM.reloadViews();
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/LoadBinaryCorpus.java (revision 1173)
200 200
						}
201 201
						
202 202
						if (newProject2 != null) {
203
							newProject2.save();
203
							newProject2.compute();
204 204
							RestartTXM.reloadViews();
205 205
							//System.out.println("Select newly loaded corpus: "+base2.getCorpora().values());
206 206
							CorporaView.select(newProject2.getChildren(MainCorpus.class));

Also available in: Unified diff