15 package cz.vutbr.fit.knot.annotations.comet.protocolV2_0;
25 import cz.vutbr.fit.knot.annotations.document.Pair;
29 import java.util.ArrayList;
30 import java.util.Arrays;
31 import java.util.Iterator;
32 import java.util.List;
33 import java.util.logging.Level;
34 import java.util.logging.Logger;
35 import org.w3c.dom.Element;
36 import org.w3c.dom.NodeList;
102 String uriAttr = typesQueryElement.getAttribute(
"uri");
103 if(uriAttr == null || uriAttr.isEmpty()){
108 requestInfo.addQueryTypes(uriAttr);
110 if (session.
getQueriedTypes() != null && !session.getQueriedTypes().contains(uriAttr)) {
111 session.addQueriedTypes(uriAttr);
123 NodeList typesMsg = typesElement.getElementsByTagName(
"type");
124 int typesCount = typesMsg.getLength();
126 for(
int index = 0; index < typesCount; index++){
127 Element modifyTypesEl = (Element) typesMsg.item(index);
128 if(modifyTypesEl != null) {
144 this.direcAncestorPair.clear();
145 this.ancestorPair.clear();
158 PersistM persistMan = AppBean.getPersistenceManager();
161 String nameAttr = typeElement.getAttribute(
"name");
162 if(nameAttr == null){
167 String uriAttr = typeElement.getAttribute(
"uri");
173 String groupUriAttr = typeElement.getAttribute(
"groupUri");
174 if(groupUriAttr == null){
179 String ontologyUriAttr = typeElement.getAttribute(
"ontologyUri");
180 if(ontologyUriAttr == null){
181 ontologyUriAttr =
"";
185 String restrictedAttributesAttr = typeElement.getAttribute(
"restrictedAttributes");
186 if(restrictedAttributesAttr == null){
187 restrictedAttributesAttr =
"";
191 if (nameAttr.isEmpty()) {
192 int langNum = requestInfo.getSession().getLanguageNum();
193 int lod = requestInfo.getSession().getProtocolLOD();
194 String info =
"<type name=\"" + nameAttr +
"\" "
195 +
"uri=\"" + uriAttr +
"\" "
196 +
"invalidAttribute=\"name\"/>";
199 String msg =
"Empty required attribute of add type of annotation.";
200 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
204 if (uriAttr.isEmpty()) {
205 int langNum = requestInfo.getSession().getLanguageNum();
206 int lod = requestInfo.getSession().getProtocolLOD();
207 String info =
"<type name=\"" + nameAttr +
"\" "
208 +
"uri=\"" + uriAttr +
"\" "
209 +
"invalidAttribute=\"uri\"/>";
212 String msg =
"Empty required attribute of add type of annotation.";
213 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
219 String foundAncUri =
"";
221 String namesStr = uriAttr.replace(AppBean.getBaseTypeUri(),
"");
222 String[] namesArr = namesStr.split(
"/");
223 ArrayList<String> names =
new ArrayList<String>(Arrays.asList(namesArr));
224 int nSize = names.size();
228 foundAncUri = uriAttr.substring(0, uriAttr.lastIndexOf(
"/"));
232 if (groupUriAttr.isEmpty()) {
233 int langNum = requestInfo.getSession().getLanguageNum();
234 int lod = requestInfo.getSession().getProtocolLOD();
235 String info =
"<type name=\"" + nameAttr +
"\" "
236 +
"uri=\"" + uriAttr +
"\" "
237 +
"invalidAttribute=\"groupUri\"/>";
240 String msg =
"Empty required attribute of add type of annotation.";
241 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
245 if (restrictedAttributesAttr.isEmpty()) {
246 int langNum = requestInfo.getSession().getLanguageNum();
247 int lod = requestInfo.getSession().getProtocolLOD();
248 String info =
"<type name=\"" + nameAttr +
"\" "
249 +
"uri=\"" + uriAttr +
"\" "
250 +
"invalidAttribute=\"restrictedAttributes\"/>";
253 String msg =
"Empty required attribute of add type of annotation.";
254 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
260 Integer groupId = null;
262 groupId = Integer.decode(groupUriAttr.replace(AppBean.getBaseGroupUri(),
""));
263 }
catch(NumberFormatException e){
264 int langNum = requestInfo.getSession().getLanguageNum();
265 int lod = requestInfo.getSession().getProtocolLOD();
266 String info =
"<type name=\"" + nameAttr +
"\" "
267 +
"uri=\"" + uriAttr +
"\" "
268 +
"invalidAttribute=\"groupUri\"/>";
271 String msg =
"Can't decode group id.";
272 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
277 Object[] groupParams =
new Object[2];
278 groupParams[0] =
"id";
279 groupParams[1] = groupId;
280 @SuppressWarnings(
"unchecked")
281 List<UserGroup> groupsList = persistMan.queryDB(
"UserGroup.findById", groupParams);
282 if(groupsList == null || groupsList.isEmpty()){
284 int langNum = requestInfo.getSession().getLanguageNum();
285 int lod = requestInfo.getSession().getProtocolLOD();
286 String info =
"<type name=\"" + nameAttr +
"\" "
287 +
"uri=\"" + uriAttr +
"\" "
288 +
"invalidAttribute=\"groupUri\"/>";
291 String msg =
"Can't find group with id:" + groupId.toString();
292 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
298 Object[] typeParams =
new Object[4];
299 typeParams[0] =
"uri";
300 typeParams[1] = uriAttr;
301 typeParams[2] =
"groupId";
302 typeParams[3] = groupId;
303 @SuppressWarnings(
"unchecked")
304 List<AnnotType> typesList = persistMan.queryDB(
"AnnotType.findByUriAndGroup", typeParams);
306 if (typesList != null && !typesList.isEmpty() && !update) {
308 int langNum = requestInfo.getSession().getLanguageNum();
309 int lod = requestInfo.getSession().getProtocolLOD();
310 String info =
"<type name=\"" + nameAttr +
"\" uri=\"" + uriAttr +
"\"/>";
313 String msg =
"Attempt to create of duplicit type of annotation; uri: " + uriAttr;
314 Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
317 }
else if ((typesList == null || typesList.isEmpty()) && update) {
319 int langNum = requestInfo.getSession().getLanguageNum();
320 int lod = requestInfo.getSession().getProtocolLOD();
321 String info =
"<type name=\"" + nameAttr +
"\" uri=\"" + uriAttr +
"\"/>";
324 String msg =
"Unknown type of annotation for update: uri: " + uriAttr;
325 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
331 typeForChange = typesList.get(0);
335 ArrayList<AnnotType> ancestors =
new ArrayList<AnnotType>();
337 NodeList ancestorsMsg = typeElement.getElementsByTagName(
"directAncestors");
338 Element ancestorsEl = (Element) ancestorsMsg.item(0);
340 if (ancestorsEl != null) {
341 String primaryAncestorUri = ancestorsEl.getAttribute(
"primary");
342 if (primaryAncestorUri != null && !primaryAncestorUri.isEmpty()) {
343 primaryAncestor =
getAncestor(nameAttr, uriAttr, primaryAncestorUri);
344 if (primaryAncestor == null) {
345 this.direcAncestorPair.add(
new Pair<String, AnnotType>(primaryAncestorUri, type));
347 if (!primaryAncestorUri.equals(foundAncUri)) {
349 int langNum = requestInfo.getSession().getLanguageNum();
350 int lod = requestInfo.getSession().getProtocolLOD();
351 String info =
"<type name=\"" + nameAttr +
"\" "
352 +
"uri=\"" + uriAttr +
"\" "
353 +
"invalidAttribute=\"uri\"/>";
356 String msg =
"URI of added type of annotation contains wrong ancestor.";
357 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
361 }
else if (!foundAncUri.isEmpty()) {
363 int langNum = requestInfo.getSession().getLanguageNum();
364 int lod = requestInfo.getSession().getProtocolLOD();
365 String info =
"<type name=\"" + nameAttr +
"\" "
366 +
"uri=\"" + uriAttr +
"\" "
367 +
"invalidAttribute=\"uri\"/>";
370 String msg =
"URI of added type of annotation contains missing ancestor.";
371 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
376 NodeList ancestorMsg = ancestorsEl.getElementsByTagName(
"ancestor");
377 int ancestorsCount = ancestorMsg.getLength();
378 for(
int index = 0; index < ancestorsCount; index++){
379 Element ancestorEl = (Element) ancestorMsg.item(index);
380 String currentAncestorUri =
processAncestors(nameAttr, uriAttr, ancestorEl);
382 if (currentAncestor != null) {
383 ancestors.add(currentAncestor);
385 this.ancestorPair.add(
new Pair<String, AnnotType>(currentAncestorUri, type));
388 }
else if (!foundAncUri.isEmpty()) {
390 int langNum = requestInfo.getSession().getLanguageNum();
391 int lod = requestInfo.getSession().getProtocolLOD();
392 String info =
"<type name=\"" + nameAttr +
"\" "
393 +
"uri=\"" + uriAttr +
"\" "
394 +
"invalidAttribute=\"uri\"/>";
397 String msg =
"URI of added type of annotation contains missing ancestor.";
398 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
404 String comment = null;
405 NodeList commentNL = typeElement.getElementsByTagName(
"comment");
406 if (commentNL.getLength() != 0) {
407 for(
int index = 0; index < commentNL.getLength(); index ++){
408 Element commentEl = (Element) commentNL.item(index);
409 if(commentEl.getParentNode().getNodeName().equals(typeElement.getNodeName())){
410 comment = MessageProcessor.getElementContent(commentEl);
417 if(!typeForChange.
getName().equals(nameAttr)){
419 int langNum = requestInfo.getSession().getLanguageNum();
420 int lod = requestInfo.getSession().getProtocolLOD();
421 String info =
"<type name=\"" + typeForChange.getName()
422 +
"\" uri=\"" + typeForChange.
getUri()
423 +
"\" invalidAttribute=\"name\"/>";
424 String msg =
"Attempt to change name of the type of annotation: "
425 + typeForChange.getName() +
" - " + nameAttr;
428 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
433 if(!typeForChange.
getGroup().getUri().equals(groupUriAttr)){
435 int langNum = requestInfo.getSession().getLanguageNum();
436 int lod = requestInfo.getSession().getProtocolLOD();
437 String info =
"<type name=\"" + typeForChange.getName()
438 +
"\" uri=\"" + typeForChange.
getUri()
439 +
"\" invalidAttribute=\"groupUri\"/>";
440 String msg =
"Attempt to change group of the type of annotation.";
443 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
448 if(((typeForChange.
getAncestorType() == null && primaryAncestor != null) ||
449 (typeForChange.
getAncestorType() != null && primaryAncestor != null)) &&
450 !(typeForChange.getAncestorType().equals(primaryAncestor))){
452 int langNum = requestInfo.getSession().getLanguageNum();
453 int lod = requestInfo.getSession().getProtocolLOD();
454 String info =
"<type name=\"" + typeForChange.getName()
455 +
"\" uri=\"" + typeForChange.
getUri()
456 +
"\" invalidAttribute=\"ancestor\"/>";
457 String msg =
"Attempt to change ancestor type of annotation.";
460 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
465 type.setId(typeForChange.getId());
468 type.setGroup(groupsList.get(0));
470 if(restrictedAttributesAttr.equalsIgnoreCase(
"true")){
471 type.setRestrictedAtt(
true);
473 type.setRestrictedAtt(
false);
476 type.setName(nameAttr);
478 type.setUri(uriAttr);
480 type.setUriInOntology(ontologyUriAttr);
483 type.setAncestorType(primaryAncestor);
484 type.setAncestorTypes(ancestors);
487 type.setComment(comment);
490 ArrayList<AnnotTypeAttr> attributes =
new ArrayList<AnnotTypeAttr>();
491 NodeList attributesMsg = typeElement.getElementsByTagName(
"attributes");
492 Element attributesEl = (Element) attributesMsg.item(0);
493 if(attributesEl != null){
494 NodeList attributeMsg = attributesEl.getElementsByTagName(
"attribute");
495 int attributesCount = attributeMsg.getLength();
496 for(
int index = 0; index < attributesCount; index++){
497 Element attributeEl = (Element) attributeMsg.item(index);
499 if (currentAttr != null) {
500 attributes.add(currentAttr);
509 type.setAttributes(attributes);
512 requestInfo.getFlier().AddEditedType(type);
514 requestInfo.getFlier().AddAddedType(type);
530 Object[] params =
new Object[2];
534 PersistM persistMan = AppBean.getPersistenceManager();
535 @SuppressWarnings(
"unchecked")
536 List <AnnotType>aList = persistMan.queryDB(
"AnnotType.findByUri", params);
537 if (aList != null && !aList.isEmpty()) {
539 ancestor = aList.get(0);
542 Iterator<AnnotType> atIter = (Iterator<AnnotType>)
requestInfo.
getFlier().getAddedTypes().iterator();
543 while(atIter.hasNext() && ancestor == null) {
545 if (addedT.
getUri().equals(uri)) {
550 if(ancestor == null) {
552 int langNum = requestInfo.getSession().getLanguageNum();
553 int lod = requestInfo.getSession().getProtocolLOD();
554 String info =
"<type name=\"" + name
555 +
"\" uri=\"" + typeUri +
"\" ancestor=\"" + uri +
"\"/>";
558 String msg =
"Unknown annotation type ancestor with uri:" + uri +
"";
559 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
577 String uriAttr = ancestorEl.getAttribute(
"uri");
578 if(uriAttr == null || uriAttr.isEmpty()){
579 int langNum = requestInfo.getSession().getLanguageNum();
580 int lod = requestInfo.getSession().getProtocolLOD();
581 String info =
"<type name=\"" + name
582 +
"\" uri=\"" + uri +
"\"/>";
585 String msg =
"Bad ancestor type in new type of annotation.";
586 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
603 Boolean isRequired =
false;
606 String typeAttr = attributeEl.getAttribute(
"type");
607 if(typeAttr == null){
612 String nameAttr = attributeEl.getAttribute(
"name");
613 if(nameAttr == null){
618 String typeUriAttr = attributeEl.getAttribute(
"typeUri");
619 if(typeUriAttr == null){
624 String ontologyUriAttr = attributeEl.getAttribute(
"ontologyUri");
625 if(ontologyUriAttr == null){
626 ontologyUriAttr =
"";
630 String requiredAttr = attributeEl.getAttribute(
"required");
631 if(requiredAttr == null){
634 if(requiredAttr.equalsIgnoreCase(
"true")){
639 if(nameAttr.isEmpty()){
641 int langNum = requestInfo.getSession().getLanguageNum();
642 int lod = requestInfo.getSession().getProtocolLOD();
643 String info =
"<attribute typeName=\"" + annotType.getName() +
"\" "
644 +
"typeUri=\"" + annotType.
getUri() +
"\" "
645 +
"name=\"" + nameAttr +
"\" "
646 +
"ontologyUri=\"" + ontologyUriAttr +
"\" "
647 +
"invalidAttribute=\"name\"/>";
650 String msg =
"Missing name, type uri or required attribute.";
651 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
655 if(typeUriAttr.isEmpty()){
657 int langNum = requestInfo.getSession().getLanguageNum();
658 int lod = requestInfo.getSession().getProtocolLOD();
659 String info =
"<attribute typeName=\"" + annotType.getName() +
"\" "
660 +
"typeUri=\"" + annotType.
getUri() +
"\" "
661 +
"name=\"" + nameAttr +
"\" "
662 +
"ontologyUri=\"" + ontologyUriAttr +
"\" "
663 +
"invalidAttribute=\"type\"/>";
666 String msg =
"Missing name, type uri or required attribute.";
667 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
671 if (requiredAttr.isEmpty()) {
673 int langNum = requestInfo.getSession().getLanguageNum();
674 int lod = requestInfo.getSession().getProtocolLOD();
675 String info =
"<attribute typeName=\"" + annotType.getName() +
"\" "
676 +
"typeUri=\"" + annotType.
getUri() +
"\" "
677 +
"name=\"" + nameAttr +
"\" "
678 +
"ontologyUri=\"" + ontologyUriAttr +
"\" "
679 +
"invalidAttribute=\"required\"/>";
682 String msg =
"Missing name, type uri or required attribute.";
683 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
689 String comment = null;
690 NodeList commentMsg = attributeEl.getElementsByTagName(
"comment");
691 Element commentEl = (Element) commentMsg.item(0);
692 if(commentEl != null){
693 comment = MessageProcessor.getElementContent(commentEl);
699 String typeName = Constants.SIMPLE_TYPES_NAMES_V2.get(Constants.SIMPLE_TYPES_URI_V2.indexOf(typeUriAttr));
700 newAttr =
new AnnotTypeAttr(annotType, nameAttr, typeName, isRequired);
702 newAttr.setComment(comment);
704 newAttr.setUriInOntology(ontologyUriAttr);
708 int langNum = requestInfo.getSession().getLanguageNum();
709 int lod = requestInfo.getSession().getProtocolLOD();
710 String info =
"<attribute typeName=\"" + annotType.getName()
711 +
"\" typeUri=\"" + annotType.
getUri()
712 +
"\" name=\"" + nameAttr
713 +
"\" ontologyUri=\"" + ontologyUriAttr +
"\"/>";
716 String msg =
"Duplicit attribute of the type of annotation.";
717 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
724 Object[] typeParams =
new Object[2];
725 typeParams[0] =
"uri";
726 typeParams[1] = typeUriAttr;
727 PersistM persistMan = AppBean.getPersistenceManager();
728 List tList = persistMan.queryDB(
"AnnotType.findByUri", typeParams);
729 if (tList != null && !tList.isEmpty()) {
733 newAttr =
new AnnotTypeAttr(annotType, nameAttr, attrStructType, isRequired);
735 newAttr.setComment(comment);
737 newAttr.setUriInOntology(ontologyUriAttr);
740 if(typeAttr.equals(
"linked")){
741 newAttr.setSimpleType(
"annotationLink");
742 }
else if(typeAttr.equals(
"nested")){
743 newAttr.setSimpleType(
"nestedAnnotation");
748 int langNum = requestInfo.getSession().getLanguageNum();
749 int lod = requestInfo.getSession().getProtocolLOD();
750 String info =
"<attribute typeName=\"" + annotType.getName()
751 +
"\" typeUri=\"" + annotType.
getUri()
752 +
"\" name=\"" + nameAttr
753 +
"\" ontologyUri=\"" + ontologyUriAttr +
"\"/>";
756 String msg =
"Duplicit attribute of the type of annotation.";
757 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
763 ArrayList<AnnotType> addedTypes = requestInfo.getFlier().getAddedTypes();
764 if(addedTypes != null && !addedTypes.isEmpty()){
765 Iterator<AnnotType> addedTypesIt = addedTypes.iterator();
766 while(addedTypesIt.hasNext()){
767 AnnotType actualType = addedTypesIt.next();
768 if(actualType.
getUri().equals(typeUriAttr)){
770 newAttr =
new AnnotTypeAttr(annotType, nameAttr, actualType, isRequired);
772 newAttr.setComment(comment);
775 if(typeAttr.equals(
"linked")){
776 newAttr.setSimpleType(
"annotationLink");
777 }
else if(typeAttr.equals(
"nested")){
778 newAttr.setSimpleType(
"nestedAnnotation");
783 int langNum = requestInfo.getSession().getLanguageNum();
784 int lod = requestInfo.getSession().getProtocolLOD();
785 String info =
"<attribute typeName=\"" + annotType.getName()
786 +
"\" typeUri=\"" + annotType.
getUri()
787 +
"\" name=\"" + nameAttr
788 +
"\" ontologyUri=\"" + ontologyUriAttr +
"\"/>";
791 String msg =
"Duplicit attribute of the type of annotation.";
792 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
799 int langNum = requestInfo.getSession().getLanguageNum();
800 int lod = requestInfo.getSession().getProtocolLOD();
802 String info =
"<attribute typeName=\"" + annotType.getName() +
"\" "
803 +
"typeUri=\"" + annotType.
getUri() +
"\" "
804 +
"name=\"" + nameAttr +
"\" "
805 +
"ontologyUri=\"" + ontologyUriAttr +
"\" "
806 +
"invalidAttribute=\"typeUri\"/>";
809 String msg =
"Unknown structured type of attribute of the type of annotation: " + typeUriAttr;
810 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
827 NodeList typesMsgs = typeElement.getElementsByTagName(
"type");
828 int typesListSize = typesMsgs.getLength();
829 for(
int index = 0; index < typesListSize; index ++){
830 Element currentTypeEl = (Element) typesMsgs.item(index);
843 String typeUri = typeElement.getAttribute(
"uri");
844 if(typeUri == null || typeUri.isEmpty()){
846 int langNum = requestInfo.getSession().getLanguageNum();
847 int lod = requestInfo.getSession().getProtocolLOD();
848 String info =
"<type uri=\"" + typeUri +
"\"/>";
851 String msg =
"Attempt to remove type of annotation without uri.";
852 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
859 Object[] params =
new Object[2];
862 @SuppressWarnings(
"unchecked")
863 List<AnnotType> typesList = AppBean.getPersistenceManager().queryDB(
"AnnotType.findByUri", params);
864 if(typesList == null || typesList.isEmpty()){
865 int langNum = requestInfo.getSession().getLanguageNum();
866 int lod = requestInfo.getSession().getProtocolLOD();
867 String info =
"<type uri=\"" + typeUri +
"\"/>";
870 String msg =
"Attempt to remove unknown type of annotation: " + typeUri;
871 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
879 params[1] = dType.getId();
880 List aList = AppBean.getPersistenceManager().queryDB(
"Annotation.findByType", params);
881 if(aList != null && !aList.isEmpty()) {
883 int langNum = requestInfo.getSession().getLanguageNum();
884 int lod = requestInfo.getSession().getProtocolLOD();
885 String info =
"<type name=\"" + dType.getName() +
"\" uri=\"" + dType.
getUri() +
"\"/>";
888 String msg =
"Attempt to delete used type of annotation: " + typeUri;
889 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
893 params[0] =
"ancestor";
894 params[1] = dType.getId();
895 List aTList = AppBean.getPersistenceManager().queryDB(
"AnnotType.findByAncestor", params);
896 if(aTList != null && !aTList.isEmpty()) {
898 int langNum = requestInfo.getSession().getLanguageNum();
899 int lod = requestInfo.getSession().getProtocolLOD();
900 String info =
"<type name=\"" + dType.getName() +
"\" uri=\"" + dType.
getUri() +
"\"/>";
903 String msg =
"Attempt to delete type of annotation with subtypes: " + typeUri;
904 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
908 requestInfo.getFlier().AddRemovedType(dType);
922 Iterator<AnnotTypeAttr> attrsIt = annotType.getAttributes().iterator();
923 while(attrsIt.hasNext()){
924 if(attrsIt.next().getName().equals(name)){
943 Iterator<Pair<String,AnnotType>> ancestIt = this.ancestorPair.iterator();
944 while(ancestIt.hasNext()){
945 Pair<String,AnnotType> actualPair = ancestIt.next();
947 if(findedAncestor == null){
949 int langNum = requestInfo.getSession().getLanguageNum();
950 int lod = requestInfo.getSession().getProtocolLOD();
951 String info =
"<type name=\"" + actualPair.right.getName()
952 +
"\" uri=\"" + actualPair.right.getUri() +
"\" ancestor=\"" + actualPair.left +
"\"/>";
955 String msg =
"Bad ancestor type in new type of annotation: " + actualPair.left;
956 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
965 actualType.addAncestorType(findedAncestor);
982 Iterator<Pair<String,AnnotType>> ancestIt = this.direcAncestorPair.iterator();
983 while(ancestIt.hasNext()){
984 Pair<String,AnnotType> actualPair = ancestIt.next();
986 if(findedAncestor == null){
988 int langNum = requestInfo.getSession().getLanguageNum();
989 int lod = requestInfo.getSession().getProtocolLOD();
990 String info =
"<type name=\"" + actualPair.right.getName()
991 +
"\" uri=\"" + actualPair.right.getUri() +
"\" ancestor=\"" + actualPair.left +
"\"/>";
994 String msg =
"Bad ancestor type in new type of annotation: " + actualPair.left;
995 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
1003 AnnotType actualType = actualPair.right;
1004 actualType.setAncestorType(findedAncestor);
1018 Iterator<AnnotType> typesIt = types.iterator();
1019 while(typesIt.hasNext()){
1021 if(actualType.
getUri().equals(uri)){
1035 Iterator<AnnotType> typesIt = types.iterator();
1036 while(typesIt.hasNext()){
1038 if(actualType.
getUri().equals(uri)){
1053 Iterator<AnnotType> typesIt = types.iterator();
1054 while(typesIt.hasNext()){
1058 int langNum = requestInfo.getSession().getLanguageNum();
1059 int lod = requestInfo.getSession().getProtocolLOD();
1060 String context =
"<type name=\"" + actualType.getName() +
"\" uri=\"" + actualType.
getUri() +
"\" invalidAttribute=\"directAncestors\"/>";
1063 String msg =
"Primary ancestor not choosed.";
1064 Logger.getLogger(P2AnnotTypeProcessor.class.getName()).log(Level.ALL, msg);
1071 actualType.setAncestorTypes(
new ArrayList<AnnotType>());
1073 actualType.addAncestorType(actualType.getAncestorType());
1076 actualType.addAncestorType(actualType.getAncestorType());
1090 if(typesFromFlier != null){
1091 Iterator<AnnotType> annotTypeIt = typesFromFlier.iterator();
1092 while(annotTypeIt.hasNext()){
1094 if(tmpType.
getUri() != null && tmpType.getUri().equals(uri)){
1101 PersistM persistMan = AppBean.getPersistenceManager();
1102 Object[] typeParams =
new Object[2];
1104 typeParams[0] =
"uri";
1105 typeParams[1] = uri;
1107 @SuppressWarnings(
"unchecked")
1108 List<AnnotType> attrsList = persistMan.queryDB(
"AnnotType.findByUri", typeParams);
1109 if(attrsList == null || attrsList.isEmpty()){
1113 return attrsList.get(0);
List< AnnotTypeAttr > getAttributes()
static final int ERROR_20_TYPE_NAME_MODIFY
AnnotTypeAttr processTypeAttribute(Element attributeEl, AnnotType annotType)
static final int LOG_LEVEL_ALL_ERRORS
void setMissingDirectAncestors(ArrayList< AnnotType > types, RequestInfo requestInfo)
void checkAncestors(ArrayList< AnnotType > types, RequestInfo requestInfo)
Persistence manager (database manipulator)
void deleteTypeByUri(ArrayList< AnnotType > types, String uri)
ArrayList< String > getQueriedTypes()
Class representing attribute of type of annotation.
void procesAnnotType(Element typeElement, RequestInfo requestInfo, boolean update)
void procesTypesAdd(Element typesElement, RequestInfo requestInfo)
void procesTypesRemove(Element typesElement, RequestInfo requestInfo)
AnnotType getAncestorType()
static final int ERROR_92_DUPLICIT_ATTRIBUTE_OF_TYPE
Singleton for storing global variables.
void procesDeleteTypes(Element typeElement, RequestInfo requestInfo)
static final int ERROR_49_DUPLICIT_TYPE
void procesDeleteAnnotType(Element typeElement, RequestInfo requestInfo)
ArrayList< Pair< String, AnnotType > > ancestorPair
static final int ERROR_51_TYPE_W_SUBTYPE_DEL
ArrayList< Pair< String, AnnotType > > direcAncestorPair
void procesAnnotTypes(Element typesElement, RequestInfo requestInfo, boolean update)
Static class which parses and process XML with messages.
Class representing user group.
ArrayList< AnnotType > getAncestorTypesAL()
boolean containsAttrName(AnnotType annotType, String name)
AnnotType findTypeByUri(ArrayList< AnnotType > types, String uri)
static final int ERROR_47_USED_TYPE_DEL
static final int ERROR_17_TYPE_ATTRIBUTES_MALFORMED
Class which parses and process XML with messages with types for protocol version 2.
static final ArrayList< String > SIMPLE_TYPES_URI_V2
static final int LOG_LEVEL
void setMissingAncestors(ArrayList< AnnotType > types, RequestInfo requestInfo)
Class representing type of annotation.
Flier with informations for comet handlers.
static AnnotType searchAnnotType(String uri, ArrayList< AnnotType > typesFromFlier)
Processed informations about client request.
String processAncestors(String name, String uri, Element ancestorEl)
Class responsible for localised strings.
void procesTypeQuery(Element typesQueryElement, RequestInfo requestInfo)
Informations about client session.
static final int ERROR_55_TYPE_ANCESTORS_MALFORMED
static final int ERROR_16_TYPE_MALFORMED
static final int ERROR_19_TYPE_UNKNOWN
void procesTypesChange(Element typesElement, RequestInfo requestInfo)
AnnotType getAncestor(String name, String typeUri, String uri)