Changeset 621

Show
Ignore:
Timestamp:
01/10/11 09:22:50 (17 months ago)
Author:
pajoma
Message:

fixed quite a few bugs

Location:
modules
Files:
37 added
23 modified

Legend:

Unmodified
Added
Removed
  • modules/sapience-injectors-main/src/main/java/sapience/injectors/model/Reference.java

    r492 r621  
    2929 
    3030        public abstract void setSource(Serializable source); 
     31         
    3132 
    3233} 
  • modules/sapience-injectors-main/src/main/java/sapience/injectors/model/xpath/XPathElement.java

    r541 r621  
    113113         * the functions 
    114114         *  
    115          * The following fields are a match (exact match = equals) a) 
    116          * elem[@attribute='value'] b) elem[@attribute='value'] 
    117          *  
    118          * (subsumption match) a) elem[@attribute] (pattern) b) 
    119          * elem[@attribute='value'] 
    120          *  
    121          * (subsumption match) a) elem (pattern) b) elem[@attribute='value'] 
    122          * d 
    123          * (no match) a) elem[@myAttribute] b) elem[@yourAttribute='value'] 
     115         * The following fields are a match  
     116         *  
     117         * (exact match = equals)  
     118         * a) elem[@attribute='value'] b) elem[@attribute='value'] 
     119         *  
     120         * (subsumption match)  
     121         * a) elem[@attribute] (pattern) b) elem[@attribute='value'] 
     122         *  
     123         * (subsumption match)  
     124         * a) elem (pattern) b) elem[@attribute='value'] 
     125         *  
     126         * (no match)  
     127         * a) elem[@myAttribute] b) elem[@yourAttribute='value'] 
    124128         *  
    125129         *  
     
    130134                boolean result = true; 
    131135                int foundAttributes = 0; 
     136                 
     137 
     138                 
    132139 
    133140                // same name (means, same namespace AND same localname 
  • modules/sapience-injectors-main/src/main/java/sapience/injectors/model/xpath/XPathGenerator.java

    r499 r621  
    266266         
    267267         public XPathPattern asXPathPattern(Serializable xpath, NamespaceContext context) throws IOException   { 
    268                 StringBuilder path = new StringBuilder(xpath.toString()); 
    269                 XPathPattern pattern = new XPathPattern(); 
    270                  
    271                 /* the following extensions are supported (default is attribute extension) 
    272                  *   //path1/path2/element[@attr]/child()  the matching element is injected as child of element //path1/path2 
    273                  *   //path1/path2/element[@attr]/after()  the matching element is injected as sibling of element //path1/path2 
    274                  *   //path1/path2/example[@attr]/attribute() the matching element is injected as attribute into the element //path1/path2/example 
    275                  */ 
    276                 pattern.setType(path.substring(path.lastIndexOf("/")+1)); 
    277                 if(pattern.getType()>0) { 
    278                         path = path.delete(path.lastIndexOf("/"), path.length()); 
    279                 } 
    280                  
    281                 XPathStack p = asXPathElementStack(path,context); 
    282                 pattern.addAll(p); 
    283                  
    284                  
    285                 return pattern; 
     268 
     269                 StringBuilder path = new StringBuilder(xpath.toString()); 
     270                 XPathPattern pattern = new XPathPattern(); 
     271 
     272                 // extract unique id from pattern (the pattern ends with @343214, where the number is the hashcode of the reference to inject) 
     273                 int pos = path.lastIndexOf("~");  
     274                 if(pos > 0) { 
     275                         pattern.setUniqueID(path.substring(pos+1));  
     276                         path = path.delete(pos, path.length()); 
     277                 } 
     278 
     279                 /* the following extensions are supported (default is attribute extension) 
     280                  *   //path1/path2/element[@attr]/child()  the matching element is injected as child of element //path1/path2 
     281                  *   //path1/path2/element[@attr]/sibling()  the matching element is injected as sibling of element //path1/path2 
     282                  *   //path1/path2/example[@attr]/attribute() the matching element is injected as attribute into the element //path1/path2/example 
     283                  */ 
     284                 pattern.setType(path.substring(path.lastIndexOf("/")+1)); 
     285                 if(pattern.getType()>0) { 
     286                         path = path.delete(path.lastIndexOf("/"), path.length()); 
     287                 } 
     288 
     289                 XPathStack p = asXPathElementStack(path,context); 
     290                 pattern.addAll(p); 
     291 
     292 
     293                 return pattern; 
    286294         } 
    287295         
     
    448456                StringBuilder sb = new StringBuilder(a); 
    449457                 
     458                 
     459                 
    450460 
    451461                /* 
     
    459469                } 
    460470         
     471                /* 
     472                 *  
     473                 */ 
    461474                 
    462475                /* 
     
    464477                 */ 
    465478                String[] array; 
    466                 // is a URL with artefact 
    467                 if((array = sb.toString().split("#")).length == 2) {     
     479                 
     480                 
     481                 
     482                // is text only (for example "text()='wfs:feature') the text can contain anything  
     483                if(sb.toString().startsWith("text()=")) { 
     484                        res = new XPathElement(new QName(sb.toString()));  
     485                         
     486                 
     487                // is a URL with artefact 
     488                } else if((array = sb.toString().split("#")).length == 2) {      
    468489                        res = new XPathElement(new QName(array[0], array[1])); 
    469                 // is with prefix, e.g. prefix:value, we have to resolve the prefix from the namespace context 
     490                         
     491                        // is with prefix, e.g. prefix:value, we have to resolve the prefix from the namespace context 
    470492                } else if((array = sb.toString().split(":")).length == 2) { 
    471493                        String uri = context.getNamespaceURI(array[0]); 
     
    584606                String str;  
    585607                if((str = ch.getData().trim()).length() == 0) return null; 
    586                 if(str.length() > 16) str = str.substring(0, 16); 
     608                //if(str.length() > 64) str = str.substring(0, 64); 
    587609                return new StringBuilder("text()=\'").append(str).append('\'').toString(); 
    588610        } 
  • modules/sapience-injectors-main/src/main/java/sapience/injectors/model/xpath/XPathMatcher.java

    r541 r621  
    109109         */ 
    110110        public boolean matches(XPathPattern queryStack, XPathStack pathStack) throws  IOException  { 
     111                // [//, ogcwfs:WFS_Capabilities[@xsi:schemaLocation='http://www.opengis.net/wfs http://webservices.ionicsoft.com/worldData/wfs/WORLD/REQUEST/get/DATA/LPR/wfs/1.0.0/WFS-capabilities.xsd' and @version='1.0.0'], ogcwfs:FeatureTypeList, ogcwfs:FeatureType, ogcwfs:Name[@attr='22'], text()='wfs:Airport'] 
     112                // [//, WFS_Capabilities[@xsi:schemaLocation='http://www.opengis.net/wfs http://webservices.ionicsoft.com/worldData/wfs/WORLD/REQUEST/get/DATA/LPR/wfs/1.0.0/WFS-capabilities.xsd' and @version='1.0.0'], FeatureTypeList, FeatureType, Name[@attr='22'], text()='wfs:Airport'] 
     113                 
    111114                if( (queryStack==null) || (pathStack == null) ) return false; 
    112115                return matches(queryStack, pathStack, queryStack.size()-1, pathStack.size()-1); 
     
    230233        private boolean matches(XPathPattern queryStack, XPathStack pathStack, int queryPos, int pathPos) throws IOException { 
    231234                try { 
     235                         
     236                         
     237                         
    232238                        XPathElement path = pathStack.get(pathPos); 
    233239                         
    234240                        XPathElement query = queryStack.get(queryPos); 
     241                         
    235242                                 
    236243                        // break recursion 
     
    243250                         
    244251                        // we skip any text nodes (but only in the current path, and if the reference doesn't have a text node) 
    245                          
    246                          
    247                         if ( (pathStack.get(pathPos).getElementName().getLocalPart().startsWith("text()")) && 
    248                                         (! (queryStack.get(queryPos).getElementName().getLocalPart().startsWith("text()")))) { 
     252                        if ( (path.toString().startsWith("text()")) && 
     253                           (!(query.toString().startsWith("text()")))) { 
    249254                                pathPos--; 
    250255                        } 
  • modules/sapience-injectors-main/src/main/java/sapience/injectors/model/xpath/XPathPattern.java

    r499 r621  
    1616         
    1717        private int flag = 0; 
     18 
     19 
     20        private String id; 
    1821         
    1922        public boolean isAttribute() { 
     
    4144                } 
    4245        } 
     46 
     47        public void setUniqueID(String id) { 
     48                this.id = id; 
     49        } 
    4350         
    4451         
  • modules/sapience-injectors-main/src/main/java/sapience/injectors/stax/extract/StaxBasedExtractor.java

    r554 r621  
    2424import java.util.List; 
    2525import java.util.Map; 
     26import java.util.Random; 
    2627import java.util.logging.Level; 
    2728import java.util.logging.Logger; 
     
    120121                                                } 
    121122                                                 
    122                          
    123                                                  
     123                                                 
     124//                                              System.out.println(getCurrentPath().toString());  
    124125                                                 
    125126                                                if ((marked = getMatcher().matches(getCurrentPath(), annotation_paths)) > -1) { 
     
    135136                                                                 
    136137                                                                // build element id 
    137                                                                 String elementID = getCurrentPath().serialize(new StringBuilder(), getNamespaceContext()).append("/attribute()").toString(); 
     138                                                                String elementID = this.generateElementID(getCurrentPath(), "attribute()", resultingXMLString);                                                          
    138139                                                                String reference = nshelper.injectNamespace(new StringBuilder(resultingXMLString.toString()), elementID, getNamespaceContext()).toString(); 
     140                                                                  
    139141                                                                result.put(elementID, reference); 
    140142                                                                 
     
    177179                                                         
    178180                                                        // build result 
    179                                                         String elementID = popper.serialize(new StringBuilder(), getNamespaceContext()).append("/child()").toString(); 
     181                                                        String elementID = this.generateElementID(popper, "child()", resultingXMLString);  
    180182                                                        String reference = nshelper.injectNamespace(new StringBuilder(resultingXMLString.toString()), elementID, getNamespaceContext()).toString(); 
    181183                                                        result.put(elementID, reference); 
     
    187189                                                         
    188190                                                } else if(matchingPattern.isSiblingElement()) { 
    189                                                         String elementID = preceding_path.serialize(new StringBuilder(), getNamespaceContext()).append("/sibling()").toString(); 
     191                                                        String elementID = this.generateElementID(preceding_path, "sibling()", resultingXMLString);  
    190192                                                        // declare the prefixes used in the xpath and reference to the reference as namespaces 
    191193                                                        String reference = nshelper.injectNamespace(new StringBuilder(resultingXMLString.toString()), elementID, getNamespaceContext()).toString(); 
     
    200202                                         
    201203                                                 
    202                                         } 
    203  
    204                                         preceding_path = (XPathStack) getCurrentPath().clone(); 
    205                                         if(characters != null) { 
    206                                                 preceding_path.push(characters); 
    207                                         } 
    208                                          
     204                                        } else { 
     205                                                // we only set the new preceding path if the current wasn't a matching pattern (otherwise we will have the problem that  
     206                                                // the key of the next line will be a reference (only the case if we have two references in a row)  
     207                                                preceding_path = (XPathStack) getCurrentPath().clone(); 
     208                                                if(characters != null) { 
     209                                                        preceding_path.push(characters); 
     210                                                } 
     211                                        } 
    209212 
    210213                                        getCurrentPath().pop(); 
     
    247250                return result; 
    248251 
     252        } 
     253 
     254 
     255 
     256         
     257        private String generateElementID(XPathStack currentPath, String function, StringWriter reference) { 
     258                StringBuilder sb = currentPath.serialize(new StringBuilder(), getNamespaceContext()); 
     259                sb.append("/").append(function); 
     260                sb.append("~").append(reference.hashCode());             
     261                return sb.toString();  
    249262        } 
    250263 
  • modules/sapience-injectors-main/src/main/java/sapience/injectors/stax/inject/ModelBasedStaxStreamInjector.java

    r546 r621  
    8989        public Map<XPathPattern, Reference> references; // the references from the database 
    9090 
    91         private Reference interceptingElement = null; 
     91        private List<Reference> interceptingElements = null; 
    9292          
    9393        private static final Logger logger = Logger.getLogger(ModelBasedStaxStreamInjector.class.getName()); 
     
    119119                XPathElement characters = null; 
    120120                int marked;  
     121                interceptingElements = new ArrayList<Reference>();  
    121122                 
    122123                try { 
     
    126127                         
    127128                        while (r.hasNext()) { 
     129 
     130                                 
    128131                                 
    129132                                XMLEvent e = r.nextEvent(); 
     
    148151                                        // check if the current xpath is in our list of attribute references 
    149152                                        for(XPathPattern p : references.keySet()) { 
     153                                                if(references.get(p) == null) continue;  
     154                                                 
    150155                                                if(p.isAttribute()) { 
    151156                                                        if(getMatcher().matches(p, getCurrentPath())) { 
    152157                                                                se = this.handleAttribute(w, references.get(p), se); 
    153                                                                 references.remove(p); 
    154                                                                 break;  //otherwise ConcurrentModificationException 
     158                                                                references.put(p, null);        // removing it would lead to concurrentmodificationexcpetion 
    155159                                                        } 
    156160                                                } 
     
    164168                                         
    165169                                        // before removing from stack, we check if the current path with added characters is a match (which means we have to add a new element now) 
     170                                        XPathStack currentPath = getCurrentPath(); 
     171                 
     172                                                 
     173                                         
    166174                                        for(XPathPattern p : references.keySet()) { 
    167                                                 if(getMatcher().matches(p, getCurrentPath())) { 
     175                                                 
     176                                                if(references.get(p) == null) continue;  
     177                                                 
     178         
     179                                                if(getMatcher().matches(p, currentPath)) { 
    168180                                                        if(p.isSiblingElement()) { 
    169                                                                 this.interceptingElement = references.get(p); 
     181                                                                // injection happens below 
     182                                                                this.interceptingElements.add(references.get(p));  
     183                                                                 
    170184                                                        } else if (p.isChildElement()) { 
    171185                                                                // we can add it directly 
     
    175189                                                                throw new IOException("Invalid Reference: "+p); 
    176190                                                        } 
    177                                                         references.remove(p); 
    178                                                         break; //otherwise ConcurrentModificationException 
     191                                                        references.put(p, null);        // removing it would lead to concurrentmodificationexcpetion 
     192                                                        //references.remove(p); 
     193                                                        //break; //otherwise ConcurrentModificationException 
    179194                                                         
    180195                                                } 
     
    193208                                         
    194209                                        // if the intercepting is not null, the preceding element was a match, hence we inject some xml before writing a new element 
    195                                         if(this.interceptingElement != null) { 
    196                                                 w.add(getXMLEventFactory().createSpace("\n")); 
    197                                                 writeElementIntoStream(w, interceptingElement); 
     210                                        if(this.interceptingElements.size() > 0) { 
     211                                                // write all references into stream 
     212                                                for (Reference ref : this.interceptingElements) { 
     213                                                        w.add(getXMLEventFactory().createSpace("\n")); 
     214                                                        writeElementIntoStream(w, ref); 
     215                                                } 
     216                 
     217                                                // reset list 
     218                                                this.interceptingElements.clear();  
    198219                                        }  
    199220                                         
     
    227248         
    228249         
    229         // test 
    230 //      public void inject(InputStream in, OutputStream out, List<Reference> refs) throws IOException { 
    231 //              try { 
    232 //                      XMLEventReader reader = getXMLInputFactory().createXMLEventReader(in); 
    233 //                      XMLEventWriter writer = getXMLOutputFactory().createXMLEventWriter(out); 
    234 //                       
    235 //                      while (reader.hasNext()) { 
    236 //                              XMLEvent event = reader.nextTag(); 
    237 //                              switch(event.getEventType()) { 
    238 //                                      case XMLEvent.START_ELEMENT: 
    239 //                                              StartElementEvent see = new StartElementEvent((StartElement)event); 
    240 //                                              for (Iterator it = see.getAttributes(); it.hasNext(); ) { 
    241 //                                                      Attribute att = (Attribute) it.next(); 
    242 //                                                      System.out.println("Path: " + getCurrentPath()); 
    243 //                                                      System.out.println("Attribute: " + att.getValue()); 
    244 //                                              } 
    245 //                                              writer.add(see); 
    246 //                                              break; 
    247 //                                               
    248 //                                      case XMLEvent.END_ELEMENT: 
    249 //                                               
    250 //                                              break; 
    251 //                               
    252 //                              } 
    253 //                      } 
    254 //              } 
    255 //              catch (XMLStreamException e) { 
    256 //              // TODO Auto-generated catch block 
    257 //                      e.printStackTrace(); 
    258 //              } catch (XPathExpressionException e) { 
    259 //                      // TODO Auto-generated catch block 
    260 //                      e.printStackTrace(); 
    261 //              } 
    262 //              finally { 
    263 //                      in.close(); 
    264 //              } 
    265 //      } 
     250 
    266251 
    267252 
     
    276261                createEventsForElement(w, ref); 
    277262                 
    278                 // written into stream, reset interception 
    279                 this.interceptingElement = null; 
    280                  
    281         } 
    282  
    283         /** 
    284          * Helper method: writes the given reference into the output stream. We distinguish between injecting elements and attributes. For the former, we add the reference AFTER the element  
    285          * represented by the XPath expression. In the case of the attribute, we inject the reference into an existing element in the XML.   
    286          *  
    287          * @param w XMLEventWriter 
    288          * @param ref Reference 
    289          * @throws IOException 
    290          * @throws XMLStreamException 
    291          * @see ModelBasedStaxStreamInjector#handleNewElement(XMLEventWriter, Reference) 
    292          * @see ModelBasedStaxStreamInjector#handleAttribute(XMLEventWriter, Reference) 
    293          */ 
    294         @Deprecated 
    295         private void inject(XMLEventWriter w, Reference ref) throws IOException, XMLStreamException { 
    296                 String annot = ref.getTarget().toString(); 
    297                 // identify event type of ref 
    298                 if(annot.getBytes()[0] == '<') { 
    299                         this.interceptingElement = ref; 
    300                 } else { 
    301                         handleAttribute(w,ref, null);    
    302                 } 
    303         } 
     263        } 
     264 
     265 
    304266         
    305267 
     
    405367 
    406368         
    407         //test 
    408 //      private StartElement handleAttribute(XMLEventWriter w, Reference ref, StartElement se) throws XMLStreamException { 
    409 //              /* we are having attributes which are in both, the reference and the current element. We only add  
    410 //               * a new Attribute event, if it is not already contained in the Start Element 
    411 //               *  
    412 //               * Example:  
    413 //               *      reference <element ns:attr1="value" reference="http://example.com"> 
    414 //               *  element   <element ns:attr1="value"> 
    415 //               */ 
    416 //              StringBuilder referenceString = new StringBuilder(ref.getTarget().toString()); 
    417 //              Matcher matcher = findAttributeInReference.matcher(referenceString); 
    418 //               
    419 //               
    420 //              // copy namespaces 
    421 //              LocalNamespaceContext lnc = new LocalNamespaceContext((BaseNsContext) se.getNamespaceContext()); 
    422 //              while(matcher.find()) { 
    423 //                      int start = matcher.start(); 
    424 //                      int end = matcher.end(); 
    425 //                       
    426 //                      String key = null;  
    427 //                      String prefix = null; 
    428 //                      String value = null; 
    429 //                       
    430 //                      // [ns:attr1, "value"] 
    431 //                      String[] l = referenceString.substring(start, end).split("="); 
    432 //                      if(l.length>0) { 
    433 //                              // [ns, attr1] 
    434 //                              String[] n = l[0].split(":"); 
    435 //                              if(n.length==2) { 
    436 //                                      key = n[1]; 
    437 //                                      prefix = n[0]; 
    438 //                              } else { 
    439 //                                      key = n[0]; 
    440 //                              } 
    441 //                              if(l.length == 2) { 
    442 //                                      value = l[1].substring(1, l[1].length()-1); // remove "" 
    443 //                                       
    444 //                              } 
    445 //                      }  
    446 //                       
    447 //                      // check if this is a namespace definition 
    448 //                      if(( prefix != null) && ("xmlns".contentEquals(prefix)) ){ 
    449 //                              lnc.put(key, value); 
    450 //                      } else { 
    451 //                              QName name = null; 
    452 //                              // create QName 
    453 //                              if(prefix != null) { 
    454 //                                      name = new QName(null, key, prefix); 
    455 //                              } else { 
    456 //                                      String namespaceURI = se.getNamespaceContext().getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX); 
    457 //                                      name = new QName(namespaceURI, key); 
    458 //                              }        
    459 //                              if(name != null) { 
    460 //                                      Attribute created = getXMLEventFactory().createAttribute(name, value); 
    461 //                                      attributeList.add(created); 
    462 //                              } 
    463 //                      } 
    464 //              } 
    465 //               
    466 //              // remove redundant attribute from reference list 
    467 //              Iterator<?> it = se.getAttributes(); 
    468 //              while(it.hasNext()) { 
    469 //                      Attribute ae = (Attribute) it.next(); 
    470 //                      for(Attribute ar : attributeList) { 
    471 //                              if( (ar.getName().getLocalPart().contentEquals(ae.getName().getLocalPart())) && 
    472 //                                      (ar.getValue().contentEquals(ae.getValue()))) { 
    473 //                                      attributeList.remove(ar); 
    474 //                                      break; 
    475 //                              } 
    476 //                              else 
    477 //                                      return ar; 
    478 //                      } 
    479 //              } 
    480 //               
    481 //              // merge everything again 
    482 //              while(it.hasNext()) { 
    483 //                      attributeList.addAll(attributeList); 
    484 //              } 
    485 //               
    486 //              // create a new element with the attribute set and return it 
    487 //              //return StartElementEventImpl.construct(se.getLocation(), se.getName(), attributeList.iterator(), lnc.getNamespaces().iterator(), lnc); 
    488 //              return null; 
    489 //      } 
     369         
    490370         
    491371         
     
    560440                        localElement.setElementID(path); 
    561441                         
    562                         // test 
    563 //                      if (path.toString().endsWith("attribute()")) { 
    564 //                               
    565 //                      } 
    566 //                      else if (path.toString().endsWith("sibling()")) { 
    567 //                               
    568 //                      } 
    569 //                      else { // child() 
    570 //                               
    571 //                      } 
    572442                         
    573443                        // update the reference 
  • modules/sapience-injectors-parent/pom.xml

    r575 r621  
    11<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
    2     <parent> 
    3                 <groupId>sapience</groupId> 
    4                 <artifactId>sapience-parent</artifactId> 
    5                 <version>1.0</version> 
    6                  
    7         </parent> 
     2<!--    <parent>--> 
     3<!--            <groupId>sapience</groupId>--> 
     4<!--            <artifactId>sapience-parent</artifactId>--> 
     5<!--            <version>1.0</version>--> 
     6<!--            --> 
     7<!--    </parent>--> 
    88   
    99  <modelVersion>4.0.0</modelVersion> 
    1010   
    1111  <artifactId>sapience-injectors-parent</artifactId> 
     12        <groupId>sapience</groupId> 
    1213  <packaging>pom</packaging> 
    1314  <version>0.2</version> 
     
    3233         
    3334        <dependencies> 
     35                        <dependency> 
     36                        <groupId>junit</groupId> 
     37                        <artifactId>junit</artifactId> 
     38                        <version>4.6</version> 
     39                        <scope>test</scope> 
     40                </dependency> 
     41                 
     42                 
    3443                <!--  SPRING --> 
    3544                <dependency> 
  • modules/sapience-injectors-testclient/src/main/resources/InjectorConfig.xml

    r564 r621  
    1414                <configuration id="wfs-110-capabilities" class="sapience.injectors.wfs.v110.WFS110_GetCapabilitiesConfig" /> 
    1515                <configuration id="wfs-110-feature" class="sapience.injectors.wfs.v110.WFS110_DescribeFeatureConfig" /> 
     16                <configuration id="wfs-100-capabilities" class="sapience.injectors.wfs.v100.WFS100_GetCapabilitiesConfig" /> 
     17                <configuration id="wfs-100-feature" class="sapience.injectors.wfs.v100.WFS100_DescribeFeatureConfig" /> 
    1618                <configuration id="sos-100-capabilities" class="sapience.injectors.sos.v100.SOS100_GetCapabilitiesConfig" /> 
    1719        </configurations> 
  • modules/sapience-injectors-testclient/src/test/java/sapience/injectors/testclient/TestLifeCycle.java

    r609 r621  
    33import java.io.IOException; 
    44 
    5 import org.junit.Before; 
     5import org.springframework.beans.factory.annotation.Autowired; 
     6 
     7import sapience.injectors.factories.ConfigurationFactory; 
     8import sapience.lookup.LookupImpl; 
    69 
    710/** 
     
    1316public abstract class TestLifeCycle extends BaseTest { 
    1417         
     18        @Autowired ConfigurationFactory config; 
    1519 
    1620        public void testLifeCycle() throws IOException { 
    1721                this.testExtract(); 
    1822                this.testInject(); 
     23         
     24                try { 
     25                         
     26                         
     27                        LookupImpl lookup = (LookupImpl) config.getLookup(); 
     28                 
     29                        lookup.getReferenceController().deleteAllRecords();  
     30                } catch (Exception e) { 
     31                        throw new IOException(e);  
     32                }  
     33        } 
     34         
     35 
     36 
     37        public ConfigurationFactory getConfiguration() { 
     38                return config;  
    1939        } 
    2040         
  • modules/sapience-injectors-testclient/src/test/java/sapience/injectors/testclient/wfs/v110/GetCapabilities/Suite_01.java

    r575 r621  
    1313import sapience.injectors.Configuration; 
    1414import sapience.injectors.Injector; 
     15import sapience.injectors.Lookup; 
    1516import sapience.injectors.factories.ConfigurationFactory; 
    1617import sapience.injectors.model.Reference; 
    1718import sapience.injectors.testclient.TestLifeCycle; 
     19import sapience.lookup.LookupImpl; 
    1820 
    1921public class Suite_01 extends TestLifeCycle { 
    2022 
    21         @Autowired ConfigurationFactory config; 
     23 
    2224 
    2325        private String sid; 
     
    3335        @Override 
    3436        public void testExtract() throws IOException { 
    35  
     37                sid = asHEX("http://example.com/wfs/Suite_01"); 
     38                 
     39                List<Reference> check2 = getConfiguration().getLookup().check(sid); 
     40                assertEquals(0, check2.size());  
     41                 
    3642                InputStream inputStream = null; 
    37                 sid = asHEX("http://example.com/wfs/Suite_01"); 
     43                 
    3844                inputStream = getFileStream(annotatedFile); 
    39                 Configuration c = config.getConfiguration(inputStream); 
    40                 config.getLookup().put(sid, c.getExtractor().extract(sid, inputStream)); 
    41                 List<Reference> check = config.getLookup().check(sid); 
    42                 assertEquals(1, check.size());   
     45                Configuration c = getConfiguration().getConfiguration(inputStream); 
     46                List<Reference> extracted = c.getExtractor().extract(sid, inputStream);  
     47                 
     48                getConfiguration().getLookup().put(sid, extracted); 
     49                List<Reference> check = getConfiguration().getLookup().check(sid); 
     50                assertEquals(2, check.size());   
    4351 
    4452        } 
     
    5159                inputStream = getFileStream(notAnnotatedFile); 
    5260                 
    53                 Configuration c = config.getConfiguration(inputStream); 
     61                Configuration c = getConfiguration().getConfiguration(inputStream); 
    5462                Injector injector = c.getInjector(); 
    5563                ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
     
    5967                 
    6068                System.out.println(result); 
     69                 
     70         
    6171 
    6272        } 
  • modules/sapience-injectors-testclient/src/test/java/sapience/injectors/testclient/wfs/v110/GetCapabilities/Suite_02.java

    r575 r621  
    4040                config.getLookup().put(sid, c.getExtractor().extract(sid, inputStream)); 
    4141                List<Reference> check = config.getLookup().check(sid); 
    42                 assertEquals(1, check.size());   
     42                assertEquals(2, check.size());   
    4343 
    4444        } 
  • modules/sapience-injectors-testclient/src/test/resources/samples/wfs110/wfs110-capabilities-testcases/01-serviceIdentification-annotation.xml

    r574 r621  
    2525         <ows:Keyword>Framework Data Layer</ows:Keyword> 
    2626         <ows:Keyword>BlueOx</ows:Keyword> 
    27          <ows:Type ows:codeSpace="http://core/WebServices/BlueOx">String</ows:Type> 
     27         <ows:Type ows:codeSpace="http://core/WebServices/BlueOx1.rdf">String</ows:Type> 
     28                 <ows:Type ows:codeSpace="http://core/WebServices/BlueOx2.rdf">String</ows:Type> 
    2829      </ows:Keywords> 
    2930      <ows:ServiceType>WFS</ows:ServiceType> 
  • modules/sapience-injectors-testclient/src/test/resources/samples/wfs110/wfs110-capabilities-testcases/02-featureType-annotation.xml

    r574 r621  
    244244            <ows:Keyword>arborial</ows:Keyword> 
    245245            <ows:Keyword>diversity</ows:Keyword> 
    246             <ows:Type ows:codeSpace="http://www.concepts.org/BlueOx">ontology</ows:Type> 
     246            <ows:Type ows:codeSpace="http://www.concepts.org/BlueOx.rdf">ontology</ows:Type> 
     247                        <ows:Type ows:codeSpace="http://www.concepts.org/BlueOx.wsdl">wsdl</ows:Type> 
    247248         </ows:Keywords> 
    248249         <wfs:DefaultSRS>EPSG:62696405</wfs:DefaultSRS> 
     
    439440   </ogc:Filter_Capabilities> 
    440441</wfs:WFS_Capabilities> 
     442 
  • modules/sapience-injectors-wfs/src/main/java/sapience/injectors/wfs/v110/WFS110_DescribeFeatureConfig.java

    r570 r621  
    1212         
    1313        public String[] getHeaderPattern() { 
    14                 return new String[]{"test"}; 
    15 //              return new String[] {"<.*schema.*",".*xmlns.*http://www.w3.org/2001/XMLSchema.*", ".*xmlns.*http://www.opengis.net/gml.*" }; 
     14 
     15                return new String[] {"<.*schema.*",".*xmlns.*http://www.w3.org/2001/XMLSchema.*", ".*xmlns.*http://www.opengis.net/gml.*" }; 
    1616        } 
    1717 
  • modules/sapience-injectors-wfs/src/main/java/sapience/injectors/wfs/v110/WFS110_GetCapabilitiesConfig.java

    r574 r621  
    1212 
    1313        public String[] getAnnotationXPathExpressions() { 
    14                 String p1 = "//{http://www.opengis.net/ows}ServiceIdentification/{http://www.opengis.net/ows}Keywords/{http://www.opengis.net/ows}Type[@{http://www.opengis.net/ows}codeSpace]/attribute()"; 
     14                String p1 = "//{http://www.opengis.net/ows}ServiceIdentification/{http://www.opengis.net/ows}Keywords/{http://www.opengis.net/ows}Type[@{http://www.opengis.net/ows}codeSpace]/child()"; 
    1515                String p2 = "//{http://www.opengis.net/wfs}FeatureTypeList/{http://www.opengis.net/wfs}FeatureType/{http://www.opengis.net/ows}Keywords/{http://www.opengis.net/ows}Type[@{http://www.opengis.net/ows}codeSpace]/sibling()"; 
    16                 return new String[] {p1,p2}; 
     16                String p3 = "//{http://www.opengis.net/wfs}FeatureTypeList/{http://www.opengis.net/wfs}FeatureType/{http://www.opengis.net/wfs}MetadataURL/sibling()"; 
     17                return new String[] {p1,p2,p3}; 
    1718        } 
    1819 
  • modules/sapience-injectors-wps

    • Property svn:ignore
      •  

        old new  
        44.classpath 
        55*.db 
         6build 
  • modules/sapience-injectors-wsdl

    • Property svn:ignore
      •  

        old new  
        44.classpath 
        55*.db 
         6build 
  • modules/sapience-lookup-hibernate/.project

    r612 r621  
    1717                </buildCommand> 
    1818                <buildCommand> 
    19                         <name>org.maven.ide.eclipse.maven2Builder</name> 
     19                        <name>org.eclipse.wst.validation.validationbuilder</name> 
    2020                        <arguments> 
    2121                        </arguments> 
    2222                </buildCommand> 
    2323                <buildCommand> 
    24                         <name>org.eclipse.wst.validation.validationbuilder</name> 
     24                        <name>org.maven.ide.eclipse.maven2Builder</name> 
    2525                        <arguments> 
    2626                        </arguments> 
  • modules/sapience-lookup-hibernate/src/main/java/sapience/lookup/hibernate/controller/ReferenceController.java

    r513 r621  
    7979                Transaction transaction = null; 
    8080                try { 
    81                         startDatabaseAccess();  
     81                        startDatabaseAccess(); 
     82                        session.clear();  
     83                        session.flush();  
     84                         
    8285                        if(!tableExists()) throw new TableNotExistException(DbProperties.getString("Reference")); 
    8386                        transaction = session.beginTransaction(); 
    8487                        StringBuffer sb = new StringBuffer(); 
    85                         sb.append("DELETE "); 
    86                         sb.append("FROM "); 
     88                        sb.append("DELETE FROM "); 
    8789                        sb.append(DbProperties.getString("Reference")); 
    8890                        Query query = session.createQuery(sb.toString()); 
    8991                        query.executeUpdate(); 
    9092                        transaction.commit(); 
     93                        session.flush();  
    9194                        if (tableIsEmpty()) { 
    9295                                logger.log(Level.FINE, "All records deleted!"); 
     
    106109        } 
    107110 
     111         
     112         
    108113        /* 
    109114         * (non-Javadoc) 
  • modules/sapience-lookup-hibernate/src/main/java/sapience/lookup/hibernate/model/HibernateReference.java

    r539 r621  
    106106        } 
    107107 
     108 
    108109} 
  • modules/sapience-lookup-hibernate/src/main/resources/META-INF/sqlite.cfg.xml

    r519 r621  
    4343                        <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> 
    4444                        <!-- Echo all executed SQL to stdout --> 
    45                         <property name="show_sql">true</property> 
     45                        <property name="show_sql">false</property> 
    4646                        <!-- Drop and re-create the database schema on startup --> 
    47                         <property name="hbm2ddl.auto">none</property> 
     47                        <property name="hbm2ddl.auto">create</property> 
    4848 
    4949                        <mapping class="sapience.lookup.hibernate.model.HibernateReference"/> 
  • modules/sapience-lookup-parent/pom.xml

    r576 r621  
    11<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
    2     <parent> 
    3                 <groupId>sapience</groupId> 
    4                 <artifactId>sapience-parent</artifactId> 
    5                 <version>1.0</version> 
    6         </parent> 
     2<!--    <parent>--> 
     3<!--            <groupId>sapience</groupId>--> 
     4<!--            <artifactId>sapience-parent</artifactId>--> 
     5<!--            <version>1.0</version>--> 
     6<!--    </parent>--> 
    77   
    88  <modelVersion>4.0.0</modelVersion> 
    99   
    1010  <artifactId>sapience-lookup-parent</artifactId> 
     11  <groupId>sapience</groupId> 
    1112  <packaging>pom</packaging> 
    1213  <version>0.1</version>