| 1 |
|
//import org.eclipse.osgi.util.NLS;
|
| 2 |
|
//import org.txm.core.messages.TXMCoreMessages;
|
| 3 |
|
//import org.txm.searchengine.cqp.CQPSearchEngine;
|
| 4 |
|
//import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
|
| 5 |
|
//import org.txm.searchengine.cqp.corpus.query.Query;
|
| 6 |
|
//import org.txm.utils.logger.Log;
|
| 7 |
|
//import org.w3c.dom.Element;
|
| 8 |
|
//import org.w3c.dom.NodeList;
|
| 9 |
|
|
| 10 |
|
//import java.util.ArrayList;
|
| 11 |
|
//import java.util.List;
|
| 12 |
|
//
|
| 13 |
|
//import org.txm.core.messages.TXMCoreMessages;
|
| 14 |
|
//import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
|
| 15 |
|
//import org.txm.searchengine.cqp.corpus.query.Query;
|
| 16 |
|
//import org.txm.utils.logger.Log;
|
| 17 |
|
//import org.w3c.dom.Element;
|
| 18 |
|
//import org.w3c.dom.NodeList;
|
| 19 |
|
|
| 20 |
|
//
|
| 21 |
|
//import java.util.List;
|
| 22 |
|
//
|
| 23 |
|
//import org.eclipse.osgi.util.NLS;
|
| 24 |
|
//import org.txm.core.messages.TXMCoreMessages;
|
| 25 |
|
//import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
|
| 26 |
|
//import org.txm.searchengine.cqp.clientExceptions.InvalidCqpIdException;
|
| 27 |
|
//import org.txm.searchengine.cqp.core.functions.selection.SelectionResult;
|
| 28 |
|
//import org.txm.searchengine.cqp.corpus.query.Query;
|
| 29 |
|
//import org.txm.searchengine.cqp.corpus.query.QueryPart;
|
| 30 |
|
//import org.txm.utils.logger.Log;
|
| 31 |
|
//import org.w3c.dom.Element;
|
| 32 |
|
//
|
| 33 |
|
//
|
| 34 |
|
//
|
| 35 |
|
//
|
| 36 |
|
// /**
|
| 37 |
|
// * Creates a partition using a list of CQP queries and names each part.
|
| 38 |
|
// *
|
| 39 |
|
// * @param name the name
|
| 40 |
|
// * @param queries the queries
|
| 41 |
|
// * @param partnames the partnames
|
| 42 |
|
// * @param registered the registered
|
| 43 |
|
// * @return the partition
|
| 44 |
|
// * @throws CqiClientException the cqi client exception
|
| 45 |
|
// */
|
| 46 |
|
// public Partition createPartition(String name, List<String> queries, List<String> partnames, boolean registered) throws Exception {
|
| 47 |
|
// Partition partition = new Partition(this);
|
| 48 |
|
// partition.setParameters(name, queries, partnames);
|
| 49 |
|
// partition.compute();
|
| 50 |
|
// if (!registered) {
|
| 51 |
|
// partition.registerToParent();
|
| 52 |
|
// }
|
| 53 |
|
// return partition;
|
| 54 |
|
// }
|
| 55 |
|
//
|
| 56 |
|
// /**
|
| 57 |
|
// * Creates the partition.
|
| 58 |
|
// *
|
| 59 |
|
// * @param structure the structure
|
| 60 |
|
// * @param property the property
|
| 61 |
|
// * @param values the values
|
| 62 |
|
// * @param registered the registered
|
| 63 |
|
// * @return the partition
|
| 64 |
|
// * @throws CqiClientException the cqi client exception
|
| 65 |
|
// */
|
| 66 |
|
// public Partition createPartition(String name, StructuralUnit structure, StructuralUnitProperty property, List<String> values, boolean registered) throws Exception {
|
| 67 |
|
// Partition partition = new Partition(this);
|
| 68 |
|
// partition.setParameters(name, property, values);
|
| 69 |
|
// partition.compute();
|
| 70 |
|
// if (!registered) {
|
| 71 |
|
// partition.registerToParent();
|
| 72 |
|
// }
|
| 73 |
|
// return partition;
|
| 74 |
|
// }
|
| 75 |
|
//
|
| 76 |
|
// /**
|
| 77 |
|
// * Creates a subcorpus using workspace definition.
|
| 78 |
|
// *
|
| 79 |
|
// * @param elem the XML element
|
| 80 |
|
// * @return the subcorpus
|
| 81 |
|
// * @throws CqiClientException the cqi client exception
|
| 82 |
|
// */
|
| 83 |
|
// public Subcorpus createSubcorpus(Element elem) throws CqiClientException {
|
| 84 |
|
// Query query = new Query(elem.getAttribute("query")); //$NON-NLS-1$
|
| 85 |
|
// String subcorpusName = elem.getAttribute("name"); //$NON-NLS-1$
|
| 86 |
|
//
|
| 87 |
|
// Subcorpus subcorpus;
|
| 88 |
|
// String subcorpusCqpId = subcorpusNamePrefix + getNextSubcorpusCounter();
|
| 89 |
|
//
|
| 90 |
|
// // long start = System.currentTimeMillis();
|
| 91 |
|
// try {
|
| 92 |
|
// CQPSearchEngine.getCqiClient().cqpQuery(this.getQualifiedCqpId(), subcorpusCqpId,
|
| 93 |
|
// query.getQueryString());
|
| 94 |
|
// subcorpus = new Subcorpus(subcorpusCqpId, subcorpusName, this, query);
|
| 95 |
|
// subcorpus.setSelfElement(elem);
|
| 96 |
|
// } catch (Exception e) {
|
| 97 |
|
// throw new CqiClientException(e);
|
| 98 |
|
// }
|
| 99 |
|
//
|
| 100 |
|
// return subcorpus;
|
| 101 |
|
// }
|
| 102 |
|
//
|
| 103 |
|
// /**
|
| 104 |
|
// * Create a named subcorpus from a query on this corpus.
|
| 105 |
|
// *
|
| 106 |
|
// * @param query
|
| 107 |
|
// * the query
|
| 108 |
|
// * @param subcorpusName
|
| 109 |
|
// * the resulting subcorpus name
|
| 110 |
|
// *
|
| 111 |
|
// * @return the resulting subcorpus
|
| 112 |
|
// *
|
| 113 |
|
// * @throws CqiClientException
|
| 114 |
|
// * the cqi client exception
|
| 115 |
|
// */
|
| 116 |
|
// public Subcorpus createSubcorpus(Query query, String subcorpusName)
|
| 117 |
|
// throws CqiClientException {
|
| 118 |
|
// Subcorpus sc = createSubcorpus(query, subcorpusName, false);
|
| 119 |
|
// return sc;
|
| 120 |
|
// }
|
| 121 |
|
//
|
| 122 |
|
// /**
|
| 123 |
|
// * Creates a subcorpus and save configuration in the workspace.
|
| 124 |
|
// *
|
| 125 |
|
// * @param query the query
|
| 126 |
|
// * @param subcorpusName the subcorpus name
|
| 127 |
|
// * @param registered the registered
|
| 128 |
|
// * @return the subcorpus
|
| 129 |
|
// * @throws CqiClientException the cqi client exception
|
| 130 |
|
// */
|
| 131 |
|
// public Subcorpus createSubcorpus(Query query, String subcorpusName,
|
| 132 |
|
// boolean registered) throws CqiClientException {
|
| 133 |
|
// Subcorpus subcorpus;
|
| 134 |
|
// String subcorpusCqpId = subcorpusNamePrefix + getNextSubcorpusCounter().toString();
|
| 135 |
|
// Log.finest(TXMCoreMessages.CREATING_SUBCORPUS + this.getQualifiedCqpId()
|
| 136 |
|
// + " " + subcorpusName + " " + query.getQueryString()); //$NON-NLS-1$ //$NON-NLS-2$
|
| 137 |
|
//
|
| 138 |
|
// long start = System.currentTimeMillis();
|
| 139 |
|
// try {
|
| 140 |
|
// CQPSearchEngine.getCqiClient().cqpQuery(
|
| 141 |
|
// this.getQualifiedCqpId(), subcorpusCqpId,
|
| 142 |
|
// query.getQueryString());
|
| 143 |
|
// //System.out.println("SUBCORPUS: "+subcorpusCqpId+" q="+query.getQueryString());
|
| 144 |
|
// subcorpus = new Subcorpus(subcorpusCqpId, subcorpusName, this, query);
|
| 145 |
|
// } catch (Exception e) {
|
| 146 |
|
// throw new CqiClientException(e);
|
| 147 |
|
// }
|
| 148 |
|
// long end = System.currentTimeMillis();
|
| 149 |
|
// Log.finest(TXMCoreMessages.SUBCORPUS_CREATED + subcorpusName
|
| 150 |
|
// + TXMCoreMessages.in + (end - start));
|
| 151 |
|
//
|
| 152 |
|
// if (!registered) subcorpus.registerToParent();
|
| 153 |
|
// return subcorpus;
|
| 154 |
|
// }
|
| 155 |
|
//
|
| 156 |
|
// public Subcorpus createSubcorpus(String name, QueryResult queryResult) throws InvalidCqpIdException {
|
| 157 |
|
// Subcorpus sub = new Subcorpus(queryResult.getCqpId(), name, this, null);
|
| 158 |
|
// return sub;
|
| 159 |
|
// }
|
| 160 |
|
//
|
| 161 |
|
// public Subcorpus createSubcorpus(String name, String cqpid) throws InvalidCqpIdException {
|
| 162 |
|
// Subcorpus sub = new Subcorpus(cqpid, name, this, null);
|
| 163 |
|
// return sub;
|
| 164 |
|
// }
|
| 165 |
|
//
|
| 166 |
|
// /**
|
| 167 |
|
// * Creates the subcorpus.
|
| 168 |
|
// *
|
| 169 |
|
// * @param elem the elem
|
| 170 |
|
// * @return the subcorpus
|
| 171 |
|
// * @throws CqiClientException the cqi client exception
|
| 172 |
|
// */
|
| 173 |
|
// public Subcorpus createSubcorpus(String name, SelectionResult selectionResult) throws CqiClientException {
|
| 174 |
|
// Subcorpus sub = createSubcorpus(this.getStructuralUnit("text"), this.getStructuralUnit("text").getProperty("id"), selectionResult, name); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
| 175 |
|
// sub.setSelectionResult(selectionResult);
|
| 176 |
|
// return sub;
|
| 177 |
|
// }
|
| 178 |
|
//
|
| 179 |
|
// /**
|
| 180 |
|
// * Creates the subcorpus.
|
| 181 |
|
// *
|
| 182 |
|
// * @param structuralUnit the structural unit
|
| 183 |
|
// * @param structuralUnitProperty the structural unit property
|
| 184 |
|
// * @param values the values
|
| 185 |
|
// * @param subcorpusName the subcorpus name
|
| 186 |
|
// * @return the subcorpus
|
| 187 |
|
// * @throws CqiClientException the cqi client exception
|
| 188 |
|
// */
|
| 189 |
|
// public Subcorpus createSubcorpus(StructuralUnit structuralUnit,
|
| 190 |
|
// StructuralUnitProperty structuralUnitProperty, List<String> values,
|
| 191 |
|
// String subcorpusName) throws CqiClientException {
|
| 192 |
|
// if (values.size() == 0) {
|
| 193 |
|
// Log.warning(TXMCoreMessages.noValuesGiven);
|
| 194 |
|
// return null;
|
| 195 |
|
// }
|
| 196 |
|
// String value = ""; //$NON-NLS-1$
|
| 197 |
|
// for (String v : values)
|
| 198 |
|
// value += Query.addBackSlash(v) + "|"; //$NON-NLS-1$
|
| 199 |
|
// value = value.substring(0, value.length() - 1);
|
| 200 |
|
//
|
| 201 |
|
// Query query = new QueryPart(structuralUnit, structuralUnitProperty, value);
|
| 202 |
|
// return createSubcorpus(query, subcorpusName);
|
| 203 |
|
// //return createSubcorpus(structuralUnit, structuralUnitProperty, value, subcorpusName);
|
| 204 |
|
// }
|
| 205 |
|
//
|
| 206 |
|
// /**
|
| 207 |
|
// * Create a subcorpus from a structural unit, a property on this structural
|
| 208 |
|
// * unit and a value for this property.
|
| 209 |
|
// *
|
| 210 |
|
// * @param structuralUnit the structural unit
|
| 211 |
|
// * @param structuralUnitProperty the structural unit property
|
| 212 |
|
// * @param value the value
|
| 213 |
|
// * @param subcorpusName the subcorpus name
|
| 214 |
|
// * @return the subcorpus
|
| 215 |
|
// * @throws CqiClientException the cqi client exception
|
| 216 |
|
// * @author Sylvain Loiseau
|
| 217 |
|
// */
|
| 218 |
|
// public Subcorpus createSubcorpus(StructuralUnit structuralUnit,
|
| 219 |
|
// StructuralUnitProperty structuralUnitProperty, String value,
|
| 220 |
|
// String subcorpusName) throws CqiClientException {
|
| 221 |
|
// Query query = new QueryPart(structuralUnit, structuralUnitProperty,
|
| 222 |
|
// Query.addBackSlash(value));
|
| 223 |
|
// // System.out.println("forged query : "+query.getQueryString());
|
| 224 |
|
// return createSubcorpus(query, subcorpusName);
|
| 225 |
|
// }
|
| 226 |
|
//
|
| 227 |
|
// /**
|
| 228 |
|
// * Create a subcorpus from a structural unit, a property on this structural
|
| 229 |
|
// * unit and a value for this property.
|
| 230 |
|
// *
|
| 231 |
|
// * @param structuralUnit the structural unit
|
| 232 |
|
// * @param structuralUnitProperty the structural unit property
|
| 233 |
|
// * @param value the value
|
| 234 |
|
// * @param subcorpusName the subcorpus name
|
| 235 |
|
// * @return the subcorpus
|
| 236 |
|
// * @throws CqiClientException the cqi client exception
|
| 237 |
|
// * @author Sylvain Loiseau
|
| 238 |
|
// */
|
| 239 |
|
// public Subcorpus createSubcorpusWithQueryString(StructuralUnit structuralUnit,
|
| 240 |
|
// StructuralUnitProperty structuralUnitProperty, String value,
|
| 241 |
|
// String subcorpusName) throws CqiClientException {
|
| 242 |
|
// Query query = new QueryPart(structuralUnit, structuralUnitProperty,
|
| 243 |
|
// value);
|
| 244 |
|
// // System.out.println("forged query : "+query.getQueryString());
|
| 245 |
|
// return createSubcorpus(query, subcorpusName);
|
| 246 |
|
// }
|
| 247 |
|
//
|
| 248 |
|
// /**
|
| 249 |
|
// * Drop all the partitions.
|
| 250 |
|
// *
|
| 251 |
|
// * @throws CqiClientException
|
| 252 |
|
// * the cqi client exception
|
| 253 |
|
// */
|
| 254 |
|
// public void dropAllPartitions() throws CqiClientException {
|
| 255 |
|
// List<Partition> _partitions = (List<Partition>) getChildren(Partition.class);
|
| 256 |
|
// for (Partition partition : _partitions) {
|
| 257 |
|
// this.dropPartition(partition);
|
| 258 |
|
// }
|
| 259 |
|
// _partitions = null;
|
| 260 |
|
// }
|
| 261 |
|
//
|
| 262 |
|
// /**
|
| 263 |
|
// * Drop all the subcorpora.
|
| 264 |
|
// *
|
| 265 |
|
// * @throws CqiClientException
|
| 266 |
|
// * the cqi client exception
|
| 267 |
|
// */
|
| 268 |
|
// public void dropAllSubcorpora() throws CqiClientException {
|
| 269 |
|
// //System.out.println("!! drop all subcorpora: "+subcorpora.size());
|
| 270 |
|
// List<Subcorpus> subcorpora = getSubcorpora();
|
| 271 |
|
// while(subcorpora.size() > 0) {
|
| 272 |
|
// this.dropSubcorpus(subcorpora.get(0));
|
| 273 |
|
// }
|
| 274 |
|
// }
|
| 275 |
|
//
|
| 276 |
|
// /**
|
| 277 |
|
// * Drops a partition.
|
| 278 |
|
// *
|
| 279 |
|
// * @param partition
|
| 280 |
|
// * the partition
|
| 281 |
|
// *
|
| 282 |
|
// * @throws CqiClientException
|
| 283 |
|
// * the cqi client exception
|
| 284 |
|
// */
|
| 285 |
|
// public void dropPartition(Partition partition) throws CqiClientException {
|
| 286 |
|
// Log.finest(SearchEngineCoreMessages.info_deletingPartition + partition.getName());
|
| 287 |
|
// for (Part part : partition.getParts())
|
| 288 |
|
// try {
|
| 289 |
|
// CQPSearchEngine.getCqiClient().dropSubCorpus(part.getQualifiedCqpId());
|
| 290 |
|
// } catch (Exception e) {
|
| 291 |
|
// throw new CqiClientException(e);
|
| 292 |
|
// }
|
| 293 |
|
// }
|
| 294 |
|
//
|
| 295 |
|
// /**
|
| 296 |
|
// * Drop query result.
|
| 297 |
|
// *
|
| 298 |
|
// * @param queryResult
|
| 299 |
|
// * the query result
|
| 300 |
|
// *
|
| 301 |
|
// * @throws CqiClientException
|
| 302 |
|
// * the cqi client exception
|
| 303 |
|
// */
|
| 304 |
|
// public void dropQueryResult(QueryResult queryResult)
|
| 305 |
|
// throws CqiClientException {
|
| 306 |
|
// Log.finest(SearchEngineCoreMessages.deletingQueryResultP0 + queryResult.getName());
|
| 307 |
|
// try {
|
| 308 |
|
// CQPSearchEngine.getCqiClient().dropSubCorpus(queryResult.getQualifiedCqpId());
|
| 309 |
|
// } catch (Exception e) {
|
| 310 |
|
// throw new CqiClientException(e);
|
| 311 |
|
// }
|
| 312 |
|
// }
|
| 313 |
|
//
|
| 314 |
|
// /**
|
| 315 |
|
// * Drops a subcorpus in CQP also its subcorpus and partitions.
|
| 316 |
|
// *
|
| 317 |
|
// * @param subcorpus
|
| 318 |
|
// * the subcorpus
|
| 319 |
|
// *
|
| 320 |
|
// * @throws CqiClientException
|
| 321 |
|
// * the cqi client exception
|
| 322 |
|
// */
|
| 323 |
|
// public boolean dropSubcorpus(Corpus subcorpus) throws CqiClientException {
|
| 324 |
|
// Log.finest(NLS.bind(TXMCoreMessages.DROP_SUBCORPUS, subcorpus.getName()));
|
| 325 |
|
// subcorpus.dropAllSubcorpora();
|
| 326 |
|
// subcorpus.dropAllPartitions();
|
| 327 |
|
// try {
|
| 328 |
|
// CQPSearchEngine.getCqiClient().dropSubCorpus(subcorpus.getQualifiedCqpId());
|
| 329 |
|
// } catch (Exception e) {
|
| 330 |
|
// throw new CqiClientException(e);
|
| 331 |
|
// }
|
| 332 |
|
// return true;
|
| 333 |
|
// }
|
| 334 |
|
//
|
| 335 |
|
//
|
| 336 |
|
//
|
| 337 |
|
//
|
| 338 |
|
|
| 339 |
|
// /* (non-Javadoc)
|
| 340 |
|
// * @see org.txm.objects.TxmObject#load()
|
| 341 |
|
// */
|
| 342 |
|
// protected boolean _loadCorpus() {
|
| 343 |
|
// //System.out.println("*** Load corpus: "+name);
|
| 344 |
|
// if (getSelfElement() == null) {
|
| 345 |
|
// return false;
|
| 346 |
|
// }
|
| 347 |
|
//
|
| 348 |
|
// // 1- texts queries then
|
| 349 |
|
// // 2- get metadatas, pattributes, sattributes, editions, biblios, uis,
|
| 350 |
|
// super._load();
|
| 351 |
|
// // System.out.println("Load corpus : "+this.name);
|
| 352 |
|
// this.loadMetadata(); // read <prop>s
|
| 353 |
|
//
|
| 354 |
|
// // 3- build saved subcorpus and partition
|
| 355 |
|
// //System.out.println("restore subcorpora: "+selfElement);
|
| 356 |
|
// NodeList preBuildElems = getSelfElement().getElementsByTagName("preBuild"); //$NON-NLS-1$
|
| 357 |
|
// if (preBuildElems.getLength() > 0) {
|
| 358 |
|
// Element preBuildElem = (Element) preBuildElems.item(0);
|
| 359 |
|
// NodeList subcorpusElems = preBuildElem.getElementsByTagName("subcorpus"); //$NON-NLS-1$
|
| 360 |
|
// for (int i = 0 ; i < subcorpusElems.getLength() ; i++) {
|
| 361 |
|
// Element subcorpusElem = (Element) subcorpusElems.item(i);
|
| 362 |
|
// if (!subcorpusElem.getParentNode().equals(preBuildElem)) continue; //level 1 elements
|
| 363 |
|
// //System.out.println("subcorpus "+subcorpusElem.getAttribute("name"));
|
| 364 |
|
// try {
|
| 365 |
|
// Subcorpus subcorp = this.createSubcorpus(subcorpusElem);
|
| 366 |
|
// subcorp.load(subcorpusElem);
|
| 367 |
|
// } catch (CqiClientException e) {
|
| 368 |
|
// Log.warning(this.name + TXMCoreMessages.failedToRestoreSubcorpus + name
|
| 369 |
|
// + " : " + e); //$NON-NLS-1$
|
| 370 |
|
// }
|
| 371 |
|
// }
|
| 372 |
|
//
|
| 373 |
|
// NodeList partitionElems = preBuildElem.getElementsByTagName("partition"); //$NON-NLS-1$
|
| 374 |
|
// for (int i = 0 ; i < partitionElems.getLength() ; i++) {
|
| 375 |
|
// Element partitionElem = (Element) partitionElems.item(i);
|
| 376 |
|
// if (!partitionElem.getParentNode().equals(preBuildElem)) continue; //level 1 elements
|
| 377 |
|
// String name = partitionElem.getAttribute("name"); //$NON-NLS-1$
|
| 378 |
|
// List<String> names = new ArrayList<String>();
|
| 379 |
|
// List<String> queries = new ArrayList<String>();
|
| 380 |
|
//
|
| 381 |
|
// NodeList partElems = partitionElem.getElementsByTagName("part"); //$NON-NLS-1$
|
| 382 |
|
// for (int j = 0; j < partElems.getLength(); j++) {
|
| 383 |
|
// Element part = (Element) partElems.item(j);
|
| 384 |
|
// names.add(part.getAttribute("name")); //$NON-NLS-1$
|
| 385 |
|
// queries.add(part.getAttribute("query")); //$NON-NLS-1$
|
| 386 |
|
// }
|
| 387 |
|
// try {
|
| 388 |
|
// //System.out.println("Create Partition with corpus "+this+" : "+name+", queries "+queries+", names "+names);
|
| 389 |
|
// Partition partition = this.createPartition(name, queries, names, true);
|
| 390 |
|
// partition.load(partitionElem);
|
| 391 |
|
// } catch (Exception e) {
|
| 392 |
|
// Log.warning(this.name + TXMCoreMessages.failedToRestorePartition + name
|
| 393 |
|
// + " : " + e); //$NON-NLS-1$
|
| 394 |
|
// //c.getParentNode().removeChild(c);
|
| 395 |
|
// }
|
| 396 |
|
// }
|
| 397 |
|
// }
|
| 398 |
|
//
|
| 399 |
|
// return true;
|
| 400 |
|
// }
|
| 401 |
|
|
| 402 |
|
|
| 403 |
|
///*
|
| 404 |
|
// * (non-Javadoc)
|
| 405 |
|
// *
|
| 406 |
|
// * @see org.txm.searchengine.cqp.corpus.Corpus#getLocale()
|
| 407 |
|
// */
|
| 408 |
|
//@Override
|
| 409 |
|
//protected boolean _loadSubcorpus() {
|
| 410 |
|
// if (getSelfElement() != null) {
|
| 411 |
|
// this.query = new Query(getSelfElement().getAttribute("query")); //$NON-NLS-1$
|
| 412 |
|
//
|
| 413 |
|
// NodeList subcorpusElems = getSelfElement().getElementsByTagName("subcorpus"); //$NON-NLS-1$
|
| 414 |
|
// for (int i = 0 ; i < subcorpusElems.getLength() ; i++) {
|
| 415 |
|
// Element subcorpusElem = (Element) subcorpusElems.item(i);
|
| 416 |
|
// try {
|
| 417 |
|
// Subcorpus subcorp = this.createSubcorpus(subcorpusElem);
|
| 418 |
|
// subcorp.load(subcorpusElem);
|
| 419 |
|
// } catch (CqiClientException e) {
|
| 420 |
|
// Log.warning(this.name + TXMCoreMessages.failedToRestoreSubcorpus + name
|
| 421 |
|
// + " : " + e); //$NON-NLS-1$
|
| 422 |
|
// }
|
| 423 |
|
// }
|
| 424 |
|
//
|
| 425 |
|
// NodeList partitionElems = getSelfElement().getElementsByTagName("partition"); //$NON-NLS-1$
|
| 426 |
|
// for (int i = 0 ; i < partitionElems.getLength() ; i++) {
|
| 427 |
|
// Element partitionElem = (Element) partitionElems.item(i);
|
| 428 |
|
// String name = partitionElem.getAttribute("name"); //$NON-NLS-1$
|
| 429 |
|
// List<String> names = new ArrayList<String>();
|
| 430 |
|
// List<String> queries = new ArrayList<String>();
|
| 431 |
|
//
|
| 432 |
|
// NodeList partElems = partitionElem.getElementsByTagName("part"); //$NON-NLS-1$
|
| 433 |
|
// for (int j = 0; j < partElems.getLength(); j++) {
|
| 434 |
|
// Element part = (Element) partElems.item(j);
|
| 435 |
|
// names.add(part.getAttribute("name")); //$NON-NLS-1$
|
| 436 |
|
// queries.add(part.getAttribute("query")); //$NON-NLS-1$
|
| 437 |
|
// }
|
| 438 |
|
// try {
|
| 439 |
|
// //System.out.println("Create Partition with corpus "+this+" : "+name+", queries "+queries+", names "+names);
|
| 440 |
|
// Partition partition = this.createPartition(name, queries, names, true);
|
| 441 |
|
// partition.load(partitionElem);
|
| 442 |
|
// } catch (Exception e) {
|
| 443 |
|
// Log.warning(this.name + TXMCoreMessages.failedToRestorePartition + name
|
| 444 |
|
// + " : " + e); //$NON-NLS-1$
|
| 445 |
|
// //c.getParentNode().removeChild(c);
|
| 446 |
|
// }
|
| 447 |
|
// }
|
| 448 |
|
// }
|
| 449 |
|
// initSelectionResult();
|
| 450 |
|
// //System.out.println("Subcorpus.load: Selection of "+this+" = "+selectionResult);
|
| 451 |
|
// //return super.load();
|
| 452 |
|
// return true;
|
| 453 |
|
//}
|
| 454 |
|
|
| 455 |
|
// /* (non-Javadoc)
|
| 456 |
|
// * @see org.txm.objects.TxmObject#load()
|
| 457 |
|
// */
|
| 458 |
|
// @Override
|
| 459 |
|
// protected boolean _loadPartition() {
|
| 460 |
|
// if (this.getUUID().length() > 0) return true; // partition already persisted
|
| 461 |
|
//
|
| 462 |
|
// if (this.hasBeenComputedOnce) return true; // partition already computed
|
| 463 |
|
//
|
| 464 |
|
// if (this.getSelfElement() != null && this.getParent() != null) {
|
| 465 |
|
// NodeList partList = getSelfElement().getChildNodes();
|
| 466 |
|
// for (int i = 0; i < partList.getLength(); i++) {
|
| 467 |
|
// if (partList.item(i).getNodeType() == 1) {
|
| 468 |
|
// Element c = (Element) partList.item(i);
|
| 469 |
|
// if (c.getNodeName().equals("part")) //$NON-NLS-1$
|
| 470 |
|
// {
|
| 471 |
|
// String pname = c.getAttribute("name"); //$NON-NLS-1$
|
| 472 |
|
// String pshortname = c.getAttribute("shortname"); //$NON-NLS-1$
|
| 473 |
|
// String pquery = c.getAttribute("query"); //$NON-NLS-1$
|
| 474 |
|
// for (Part part : getParts())
|
| 475 |
|
// if (part.getName().equals(pname)) {
|
| 476 |
|
// part.setName(pname);
|
| 477 |
|
// part.setShortName(pshortname);
|
| 478 |
|
// part.setQuery(pquery);
|
| 479 |
|
// }
|
| 480 |
|
// }
|
| 481 |
|
// }
|
| 482 |
|
// }
|
| 483 |
|
// this.loadMetadata();
|
| 484 |
|
// return true;
|
| 485 |
|
// }
|
| 486 |
|
//
|
| 487 |
|
// return false;
|
| 488 |
|
// }
|
| 489 |
|
|
| 490 |
|
|
| 491 |
|
///**
|
| 492 |
|
// * Creates the part.
|
| 493 |
|
// *
|
| 494 |
|
// * @param partitionName the partition name
|
| 495 |
|
// * @param partName the part name
|
| 496 |
|
// * @param query the query
|
| 497 |
|
// * @return the part
|
| 498 |
|
// * @throws CqiClientException the cqi client exception
|
| 499 |
|
// */
|
| 500 |
|
//private Part createPart(String partitionName, String partName, Query query) throws CqiClientException {
|
| 501 |
|
// if (partName.length() == 0) {
|
| 502 |
|
// partName = "-"; //$NON-NLS-1$
|
| 503 |
|
// }
|
| 504 |
|
// return createPart(partitionName, partName, query.getQueryString());
|
| 505 |
|
//}
|
| 506 |
|
//
|
| 507 |
|
///**
|
| 508 |
|
// * Create a part with a raw query.
|
| 509 |
|
// *
|
| 510 |
|
// * @param partitionName the partition name
|
| 511 |
|
// * @param partName the part name
|
| 512 |
|
// * @param query the query
|
| 513 |
|
// * @return the part
|
| 514 |
|
// * @throws CqiClientException the cqi client exception
|
| 515 |
|
// *
|
| 516 |
|
// * @author Sylvain Loiseau, mdecorde
|
| 517 |
|
// */
|
| 518 |
|
//public Part createPart(String partitionName, String partName, String query) throws CqiClientException {
|
| 519 |
|
// Part part;
|
| 520 |
|
// String partCqpId = CqpObject.partNamePrefix + Corpus.getNextSubcorpusCounter();
|
| 521 |
|
// Log.finest(NLS.bind(TXMCoreMessages.CREATING_PART,partName, query));
|
| 522 |
|
// long start = System.currentTimeMillis();
|
| 523 |
|
// try {
|
| 524 |
|
// CQPSearchEngine.getCqiClient().cqpQuery(this.getParent().getQualifiedCqpId(), partCqpId, query);
|
| 525 |
|
// part = new Part(partCqpId, partitionName, partName, this, new Query(query));
|
| 526 |
|
//
|
| 527 |
|
// // FIXME: persistence tests: define the UUID as the concatenation of all part CQP id
|
| 528 |
|
//// this.uniqueID += partCqpId;
|
| 529 |
|
//
|
| 530 |
|
// } catch (Exception e) {
|
| 531 |
|
// try {
|
| 532 |
|
// throw new CqiClientException(TXMCoreMessages.failedToCreatePartColon + partitionName + "_" + partName + e + " last error: " + CQPSearchEngine.getCqiClient().getLastCQPError()); //$NON-NLS-1$ //$NON-NLS-2$
|
| 533 |
|
// } catch (Exception e1) {
|
| 534 |
|
// System.out.println(TXMCoreMessages.failedToGetLastCQPErrorColon+e1);
|
| 535 |
|
// org.txm.utils.logger.Log.printStackTrace(e1);
|
| 536 |
|
// return null;
|
| 537 |
|
// }
|
| 538 |
|
// }
|
| 539 |
|
// long end = System.currentTimeMillis();
|
| 540 |
|
// Log.finest(NLS.bind(TXMCoreMessages.info_partCreatedInXMs, partitionName + "_" + partName, (end - start))); //$NON-NLS-1
|
| 541 |
|
//
|
| 542 |
|
// return part;
|
| 543 |
|
//}
|