[Yanel-commits] rev 59424 - public/yanel/contributions/realms/konakart-yanel-realm/res-types/overview/src/java/org/wyona/yanel/resources/konakart/overview

michi at wyona.com michi at wyona.com
Sat Jul 16 19:23:45 CEST 2011


Author: michi
Date: 2011-07-16 19:23:44 +0200 (Sat, 16 Jul 2011)
New Revision: 59424

Modified:
   public/yanel/contributions/realms/konakart-yanel-realm/res-types/overview/src/java/org/wyona/yanel/resources/konakart/overview/KonakartOverviewSOAPInfResource.java
Log:
trackable implemented

Modified: public/yanel/contributions/realms/konakart-yanel-realm/res-types/overview/src/java/org/wyona/yanel/resources/konakart/overview/KonakartOverviewSOAPInfResource.java
===================================================================
--- public/yanel/contributions/realms/konakart-yanel-realm/res-types/overview/src/java/org/wyona/yanel/resources/konakart/overview/KonakartOverviewSOAPInfResource.java	2011-07-15 18:19:55 UTC (rev 59423)
+++ public/yanel/contributions/realms/konakart-yanel-realm/res-types/overview/src/java/org/wyona/yanel/resources/konakart/overview/KonakartOverviewSOAPInfResource.java	2011-07-16 17:23:44 UTC (rev 59424)
@@ -1,9 +1,12 @@
-/*-
+/*
  * Copyright 2010 Wyona
  */
 
 package org.wyona.yanel.resources.konakart.overview;
 
+import org.wyona.yanel.core.api.attributes.AnnotatableV1;
+import org.wyona.yanel.core.api.attributes.TrackableV1;
+import org.wyona.yanel.core.attributes.tracking.TrackingInformationV1;
 import org.wyona.yanel.impl.resources.BasicXMLResource;
 import org.wyona.yanel.resources.konakart.shared.SharedResource;
 
@@ -46,13 +49,15 @@
 /**
  * Show overview before buying products and also the actual order process
  */
-public class KonakartOverviewSOAPInfResource extends BasicXMLResource implements org.wyona.yanel.core.api.attributes.AnnotatableV1 {
+public class KonakartOverviewSOAPInfResource extends BasicXMLResource implements AnnotatableV1, TrackableV1 {
     
     private static Logger log = Logger.getLogger(KonakartOverviewSOAPInfResource.class);
     private static String KONAKART_NAMESPACE = "http://www.konakart.com/1.0";
 
     private BranchListHandler handler; // Info: For parsing branches xml file.
 
+    private TrackingInformationV1 trackInfo;
+
     /**
      * @see org.wyona.yanel.impl.resources.BasicXMLResource#getContentXML(String)
      */
@@ -62,6 +67,20 @@
             log.debug("requested viewId: " + viewId);
         }
 
+        if (trackInfo != null) {
+            String[] annotations = getAnnotations();
+            if (annotations != null) {
+                for (int i = 0; i < annotations.length; i++) {
+                    trackInfo.addTag(annotations[i]);
+                }
+            } else {
+                log.error("No annotations!");
+            }
+            trackInfo.setPageType("konakart-order-overview");
+        } else {
+            log.warn("Tracking information bean is null! Check life cycle of resource!");
+        }
+
         SharedResource shared = new SharedResource();
         KKEngIf kkEngine = shared.getKonakartEngineImpl();
         KKEngIf kkEngineBranch = null; // Will be initialized later (if in multi-store mode)
@@ -218,8 +237,18 @@
                 Element perrElem = (Element) rootElement.appendChild(doc.createElementNS(KONAKART_NAMESPACE, "process-error"));
                 if(e.getMessage() != null) perrElem.appendChild(doc.createTextNode(e.getMessage()));
             }
+            if (trackInfo != null) {
+                trackInfo.setRequestAction("order-processed");
+            } else {
+                log.warn("Tracking information bean is null! Check life cycle of resource!");
+            }
         } else {
             log.warn("DEBUG: Order either not submitted or processed yet. Continue ...");
+            if (trackInfo != null) {
+                trackInfo.setRequestAction("review-order");
+            } else {
+                log.warn("Tracking information bean is null! Check life cycle of resource!");
+            }
         }
 
         // Payment info
@@ -874,7 +903,8 @@
      * @see org.wyona.yanel.core.api.attributes.AnnotatableV1#getAnnotations()
      */
     public String[] getAnnotations() throws Exception {
-        if (readyToProcess()) {
+        if (true) {
+        //if (readyToProcess()) {
             SharedResource shared = new SharedResource();
             KKEngIf kkEngine = shared.getKonakartEngineImpl();
             int tmpCustomerId = shared.getTemporaryCustomerId(getEnvironment().getRequest().getSession(true));
@@ -882,7 +912,6 @@
             BasketIf[] items = kkEngine.getBasketItemsPerCustomer(null, tmpCustomerId, languageId); // TODO: It seems like the basket has already been deleted!?
 
             java.util.List<String> annotations = new java.util.ArrayList();
-            annotations.add("shop-buy-products");
             for (int i = 0; i < items.length; i++) {
                 annotations.add("" + items[i].getProductId());
                 annotations.add(items[i].getProduct().getName());
@@ -890,6 +919,7 @@
 
             return annotations.toArray(new String[annotations.size()]);
         } else {
+            log.warn("No annotations!");
             return null;
         }
     }
@@ -914,4 +944,11 @@
     public void setAnnotation(String name) throws Exception {
         log.warn("No implemented yet!");
     }
+
+    /**
+     * @see org.wyona.yanel.core.api.attributes.TrackableV1#doTrack(TrackingInformationV1)
+     */
+    public void doTrack(org.wyona.yanel.core.attributes.tracking.TrackingInformationV1 trackInfo) {
+        this.trackInfo = trackInfo;
+    }
 }



More information about the Yanel-commits mailing list