Changeset 600 for AE/installer2/src/net/oni2/aeinstaller/backend/depot
- Timestamp:
- Jan 10, 2013, 12:12:01 AM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller/backend/depot
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/backend/depot/DepotManager.java
r592 r600 18 18 import net.oni2.aeinstaller.backend.depot.model.TaxonomyTerm; 19 19 import net.oni2.aeinstaller.backend.depot.model.TaxonomyVocabulary; 20 import net.oni2.aeinstaller.backend.mods.ECompatiblePlatform; 20 21 import net.oni2.aeinstaller.backend.network.DrupalJSONQuery; 21 22 … … 287 288 288 289 /** 289 * @return Mod-Nodes 290 */ 291 public Vector<NodeMod> getModPackageNodes() { 292 Vector<NodeMod> result = new Vector<NodeMod>(); 293 TaxonomyTerm tt = getTaxonomyTerm(DepotConfig.getTaxonomyName_InstallType_Package()); 294 if (tt == null) 295 return result; 296 297 int packageterm_id = tt.getTid(); 298 290 * Get a node by node id 291 * 292 * @param id 293 * Node id 294 * @return Node 295 */ 296 public Node getNodeById(int id) { 297 return nodes.get(id); 298 } 299 300 /** 301 * Get a Mod-Node by a given package number 302 * 303 * @param packageNumber 304 * Package number to find 305 * @return The Mod-Node or null 306 */ 307 public NodeMod getNodeByPackageNumber(int packageNumber) { 299 308 Vector<Node> files = getNodesByType(DepotConfig.getNodeType_Mod()); 300 309 for (Node n : files) { 301 310 if (n instanceof NodeMod) { 302 311 NodeMod nm = (NodeMod) n; 303 if (nm.getTaxonomyTerms().get(vocabId_instmethod) 304 .contains(packageterm_id)) 312 if (nm.getPackageNumber() == packageNumber) 313 return nm; 314 } 315 } 316 return null; 317 } 318 319 /** 320 * @return Mod-Nodes 321 */ 322 public Vector<NodeMod> getModPackageNodes() { 323 Vector<NodeMod> result = new Vector<NodeMod>(); 324 String instMethName = DepotConfig.getTaxonomyName_InstallType_Package(); 325 326 Vector<Node> files = getNodesByType(DepotConfig.getNodeType_Mod()); 327 for (Node n : files) { 328 if (n instanceof NodeMod) { 329 NodeMod nm = (NodeMod) n; 330 if (nm.getInstallMethod().getName() 331 .equalsIgnoreCase(instMethName)) 305 332 result.add(nm); 306 333 } … … 317 344 */ 318 345 public boolean isModValidOnPlatform(NodeMod node, Settings.Platform platform) { 319 int termId = node.getTaxonomyTerms().get(vocabId_platform).iterator() 320 .next(); 321 String validPlatform = getTaxonomyTerm(termId).getName(); 322 if (validPlatform.equalsIgnoreCase(DepotConfig.getTaxonomyName_Platform_Both())) 323 return true; 324 325 if ((platform == Platform.WIN) || (platform == Platform.LINUX)) 326 return validPlatform.equalsIgnoreCase(DepotConfig.getTaxonomyName_Platform_Win()); 327 else if (platform == Platform.MACOS) 328 return validPlatform.equalsIgnoreCase(DepotConfig.getTaxonomyName_Platform_Mac()); 329 else 330 return false; 346 ECompatiblePlatform plat = node.getPlatform(); 347 switch (plat) { 348 case BOTH: 349 return true; 350 case WIN: 351 return (platform == Platform.WIN) 352 || (platform == Platform.LINUX); 353 case MACOS: 354 return (platform == Platform.MACOS); 355 } 356 return false; 331 357 } 332 358 … … 344 370 */ 345 371 public boolean isModOfType(NodeMod node, HashSet<Integer> type, boolean or) { 346 boolean matching = true; 347 if (or) 348 matching = false; 372 boolean matching = !or; 373 HashSet<TaxonomyTerm> terms = node.getTypes(); 349 374 350 375 for (int t : type) { 351 376 if (or) 352 matching |= node.getTaxonomyTerms().get(vocabId_type) 353 .contains(t); 377 matching |= terms.contains(t); 354 378 else 355 matching &= node.getTaxonomyTerms().get(vocabId_type) 356 .contains(t); 379 matching &= terms.contains(t); 357 380 } 358 381 return matching; 382 } 383 384 /** 385 * @return VocabId of Platform vocabulary 386 */ 387 public int getVocabIdPlatform() { 388 return vocabId_platform; 389 } 390 391 /** 392 * @return VocabId of Install method vocabulary 393 */ 394 public int getVocabIdInstMethod() { 395 return vocabId_instmethod; 396 } 397 398 /** 399 * @return VocabId of Type vocabulary 400 */ 401 public int getVocabIdType() { 402 return vocabId_type; 403 } 404 405 /** 406 * @param id 407 * ID of file to get 408 * @return the file 409 */ 410 public File getFile(int id) { 411 return files.get(id); 359 412 } 360 413 -
AE/installer2/src/net/oni2/aeinstaller/backend/depot/model/NodeMod.java
r592 r600 4 4 import java.util.HashSet; 5 5 import java.util.Vector; 6 7 import net.oni2.aeinstaller.backend.depot.DepotConfig; 8 import net.oni2.aeinstaller.backend.depot.DepotManager; 9 import net.oni2.aeinstaller.backend.mods.ECompatiblePlatform; 6 10 7 11 import org.json.JSONArray; … … 74 78 75 79 /** 76 * @return the taxonomyTerms80 * @return Types 77 81 */ 78 public HashMap<Integer, HashSet<Integer>> getTaxonomyTerms() { 79 return taxonomyTerms; 82 public HashSet<TaxonomyTerm> getTypes() { 83 HashSet<TaxonomyTerm> tt = new HashSet<TaxonomyTerm>(); 84 for (int t : taxonomyTerms.get(DepotManager.getInstance() 85 .getVocabIdType())) { 86 tt.add(DepotManager.getInstance().getTaxonomyTerm(t)); 87 } 88 return tt; 80 89 } 81 90 82 91 /** 83 * @return the fields92 * @return Install method 84 93 */ 85 public HashMap<String, String> getFields() { 86 return fields; 94 public TaxonomyTerm getInstallMethod() { 95 return DepotManager.getInstance().getTaxonomyTerm( 96 taxonomyTerms 97 .get(DepotManager.getInstance().getVocabIdInstMethod()) 98 .iterator().next()); 99 } 100 101 /** 102 * @return Compatible platform 103 */ 104 public ECompatiblePlatform getPlatform() { 105 TaxonomyTerm term = DepotManager.getInstance().getTaxonomyTerm( 106 taxonomyTerms 107 .get(DepotManager.getInstance().getVocabIdPlatform()) 108 .iterator().next()); 109 110 String validPlatform = term.getName(); 111 if (validPlatform.equalsIgnoreCase(DepotConfig 112 .getTaxonomyName_Platform_Both())) 113 return ECompatiblePlatform.BOTH; 114 if (validPlatform.equalsIgnoreCase(DepotConfig 115 .getTaxonomyName_Platform_Win())) 116 return ECompatiblePlatform.WIN; 117 if (validPlatform.equalsIgnoreCase(DepotConfig 118 .getTaxonomyName_Platform_Mac())) 119 return ECompatiblePlatform.MACOS; 120 121 return null; 122 } 123 124 /** 125 * @return Creator of mod 126 */ 127 public String getCreator() { 128 if (fields.get("creator") != null) 129 return fields.get("creator"); 130 else 131 return ""; 132 } 133 134 /** 135 * @return Version of mod 136 */ 137 public String getVersion() { 138 if (fields.get("version") != null) 139 return fields.get("version"); 140 else 141 return ""; 142 } 143 144 /** 145 * @return Package number 146 */ 147 public int getPackageNumber() { 148 return Integer.parseInt(fields.get("package_number")); 87 149 } 88 150 }
Note:
See TracChangeset
for help on using the changeset viewer.