comparison src/de/mpiwg/dwinter/duomo/lexdump/LexOWLTransformer.java @ 2:273164f81926

bug in transformer handleroles
author dwinter
date Thu, 03 Feb 2011 16:08:06 +0100
parents 0fa29ab5e5e0
children d9fd32ecae24
comparison
equal deleted inserted replaced
1:0fa29ab5e5e0 2:273164f81926
52 // Verwendung 52 // Verwendung
53 53
54 public LexOWLTransformer(OWLImporter owlDoc, LexDumpImporter lexDoc) throws IOException { 54 public LexOWLTransformer(OWLImporter owlDoc, LexDumpImporter lexDoc) throws IOException {
55 this.owlDoc = owlDoc; 55 this.owlDoc = owlDoc;
56 this.lexDoc = lexDoc; 56 this.lexDoc = lexDoc;
57 missing = new FileWriter(new File("/tmp/missing.out","w")); 57 missing = new FileWriter(new File("/tmp/missing.out"));
58 } 58 }
59 59
60 /** 60 /**
61 * @param args 61 * @param args
62 * @throws Exception 62 * @throws Exception
204 String role = lexDoc.getValue(nomiq, "./role"); 204 String role = lexDoc.getValue(nomiq, "./role");
205 205
206 if (!name.equals("") && !role.equals("")) { 206 if (!name.equals("") && !role.equals("")) {
207 recordNamesRoles = handleNameWithRole(recordInd, name, role); 207 recordNamesRoles = handleNameWithRole(recordInd, name, role);
208 } else if (!role.equals("")) { 208 } else if (!role.equals("")) {
209 recordNamesRoles = handleRole(recordInd, role); 209 recordNamesRoles = createOrGetRole(role);
210 } else if (!name.equals("")) { 210 } else if (!name.equals("")) {
211 recordNamesRoles = handleName(recordInd, name); 211 recordNamesRoles = createOrGetName(name);
212 } 212 }
213 213
214 if (recordNamesRoles != null) { 214 if (recordNamesRoles != null) {
215 owlDoc.setProperty(eventInstance, 215 owlDoc.setProperty(eventInstance,
216 "recordsDuomoObjectNameRoles", recordNamesRoles); 216 "recordsDuomoObjectNameRoles", recordNamesRoles);
399 } 399 }
400 } 400 }
401 return toClass; 401 return toClass;
402 } 402 }
403 403
404 private OWLIndividual handleRole(OWLIndividual recordInd, String role) { 404
405 OWLIndividual roleInd = owlDoc.getIndividualByReadableId(
406 "IndicesRoles", role);
407 if (roleInd == null) {
408 roleInd = createRole(role);
409 }
410
411 return roleInd;
412 }
413
414 private OWLIndividual handleName(OWLIndividual recordInd, String name) {
415 OWLIndividual nameInd = owlDoc.getIndividualByReadableId(
416 "IndicesNames", name);
417 if (nameInd == null) {
418 nameInd = createRole(name);
419 }
420
421 return nameInd;
422 }
423 405
424 private OWLIndividual handleNameWithRole(OWLIndividual recordInd, 406 private OWLIndividual handleNameWithRole(OWLIndividual recordInd,
425 String name, String role) { 407 String name, String role) {
426 // teste ob schon ein solcer Eintrag existiert 408 // teste ob schon ein solcer Eintrag existiert
427 OWLIndividual nameInd = owlDoc.getIndividualByReadableId( 409 OWLIndividual nameInd = owlDoc.getIndividualByReadableId(
434 // existierten. 416 // existierten.
435 } 417 }
436 OWLIndividual roleInd = owlDoc.getIndividualByReadableId( 418 OWLIndividual roleInd = owlDoc.getIndividualByReadableId(
437 "IndicesRoles", role); 419 "IndicesRoles", role);
438 if (roleInd == null) { 420 if (roleInd == null) {
439 roleInd = createRole(role); 421 roleInd = createOrGetRole(role);
440 createNewNameWithRole = true; // role existierte nicht dann kann 422 createNewNameWithRole = true; // role existierte nicht dann kann
441 // auch NameWithRole nicht 423 // auch NameWithRole nicht
442 // existierten. 424 // existierten.
443 } 425 }
444 OWLIndividual nameWithRoleInd = null; 426 OWLIndividual nameWithRoleInd = null;
501 private OWLIndividual createOrGetName(String name) { 483 private OWLIndividual createOrGetName(String name) {
502 OWLIndividual nameInd = owlDoc.createOrGetInstanceWithIdentifier("IndicesNames","IdentifierNames",name); 484 OWLIndividual nameInd = owlDoc.createOrGetInstanceWithIdentifier("IndicesNames","IdentifierNames",name);
503 return nameInd; 485 return nameInd;
504 } 486 }
505 487
506 private OWLIndividual createRole(String name) { 488 private OWLIndividual createOrGetRole(String name) {
507 OWLIndividual roleInd = owlDoc.createOrGetInstanceWithIdentifier("IndicesRoles","IdentifierRoles",name); 489 OWLIndividual roleInd = owlDoc.createOrGetInstanceWithIdentifier("IndicesRoles","IdentifierRoles",name);
508 return roleInd; 490 return roleInd;
509 } 491 }
510 492
511 private OWLIndividual createRecord(Element record, OWLIndividual cardInd) 493 private OWLIndividual createRecord(Element record, OWLIndividual cardInd)