http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/e752e97d/app/src/main/java/org/apache/taverna/mobile/tavernamobile/Workflow.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/tavernamobile/Workflow.java 
b/app/src/main/java/org/apache/taverna/mobile/tavernamobile/Workflow.java
index b4547ae..195775e 100644
--- a/app/src/main/java/org/apache/taverna/mobile/tavernamobile/Workflow.java
+++ b/app/src/main/java/org/apache/taverna/mobile/tavernamobile/Workflow.java
@@ -2,10 +2,10 @@ package org.apache.taverna.mobile.tavernamobile;
 /**
  * Apache Taverna Mobile
  * Copyright 2015 The Apache Software Foundation
-
+ *
  * This product includes software developed at
  * The Apache Software Foundation (http://www.apache.org/).
-
+ *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
@@ -24,12 +24,12 @@ package org.apache.taverna.mobile.tavernamobile;
  * under the License.
  */
 
+import org.apache.taverna.mobile.R;
+
 import android.content.Context;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 
-import org.apache.taverna.mobile.R;
-
 import java.util.ArrayList;
 import java.util.List;
 
@@ -45,48 +45,56 @@ public class Workflow {
     private String workflow_datecreated, workflow_datemodified;
     private Bitmap workflow_author_bitmap;
     private WorkflowComponent workflowComponent;
-    private String workflow_remote_url; //provides a link to download the 
workflow. Equivalent to content-uri in the xml form
-    private String workflow_web_url; //a string containing the workflow 
resource that can be loaded in  browser
-    private String workflow_details_url;//used to refer to the details of the 
workflow
+    private String workflow_remote_url; //provides a link to download the 
workflow. Equivalent to
+    // content-uri in the xml form
+    private String workflow_web_url; //a string containing the workflow 
resource that can be
+    // loaded in  browser
+    private String workflow_details_url; //used to refer to the details of the 
workflow
     private List<Runs> workflow_runs;
     private int workflow_input;
     private long id;
-    private String workflow_uploader;//indicate the user who uploaded the 
workflow
+    private String workflow_uploader; //indicate the user who uploaded the 
workflow
     private String workflow_Type; //describes whether it is a type 1 or 2 
workflow
     private String workflow_preview; //a url to a preview image of the workflow
-    private String workflow_thumb_big; //a url to a full scale image of the 
workflow. I Will usually an SVG because the it is available for most of the 
workflows
+    private String workflow_thumb_big; //a url to a full scale image of the 
workflow. I Will
+    // usually an SVG because the it is available for most of the workflows
     private String workflow_licence_type; //describes a type of licensing for 
the workflow
-    private String workflow_content_type;//specifies a content type for the 
workflow;
-    private List<String> workflow_tags;//provides a list of string tags that 
could be used to index the workflow for searches
-    private String workflow_versions;//a list of version for the workflow 
uploaded over time
-    private List<String> workflow_credits;//key contributors to the workflow
-
-    public static enum workflow_input_type{ TYPE_INT, TYPE_STRING, 
TYPE_OBJECT};
+    private String workflow_content_type; //specifies a content type for the 
workflow;
+    private List<String> workflow_tags; //provides a list of string tags that 
could be used to
+    // index the workflow for searches
+    private String workflow_versions; //a list of version for the workflow 
uploaded over time
+    private List<String> workflow_credits; //key contributors to the workflow
 
     public Workflow() {
     }
 
+    ;
+
     public Workflow(Context context) {
         this.context = context;
         this.workflow_runs = new ArrayList<Runs>();
     }
-    public Workflow(String author, String description, long id, String url){
+
+    public Workflow(String author, String description, long id, String url) {
         this.workflow_author = author;
-        this.workflow_author_bitmap = 
null;//BitmapFactory.decodeResource(getResources(), R.drawable.ic_userprofile);
-        this.workflow_description =description;
-        this.workflow_input=1;
+        this.workflow_author_bitmap = null; 
//BitmapFactory.decodeResource(getResources(), R
+        // .drawable.ic_userprofile);
+        this.workflow_description = description;
+        this.workflow_input = 1;
         this.id = id;
         this.workflow_remote_url = url;
         this.workflow_runs = new ArrayList<Runs>();
     }
 
-    public Workflow(Context ctx, String title, String author, String 
description, long id, String url){
+    public Workflow(Context ctx, String title, String author, String 
description, long id, String
+            url) {
         this.context = ctx;
         this.workflow_author = author;
-        this.workflow_author_bitmap = 
BitmapFactory.decodeResource(this.context.getResources(), 
R.drawable.ic_userprofile);
-        this.workflow_description =description;
-        this.workflow_title =title;
-        this.workflow_input=1;
+        this.workflow_author_bitmap = 
BitmapFactory.decodeResource(this.context.getResources(), R
+                .drawable.ic_userprofile);
+        this.workflow_description = description;
+        this.workflow_title = title;
+        this.workflow_input = 1;
         this.id = id;
         this.workflow_remote_url = url;
         this.workflow_runs = new ArrayList<Runs>();
@@ -104,6 +112,10 @@ public class Workflow {
         return this.workflow_datecreated;
     }
 
+    public void setWorkflow_datecreated(String workflow_datecreated) {
+        this.workflow_datecreated = workflow_datecreated;
+    }
+
     public String getWorkflow_remote_url() {
         return this.workflow_remote_url;
     }
@@ -116,6 +128,10 @@ public class Workflow {
         return this.workflow_details_url;
     }
 
+    public void setWorkflow_details_url(String workflow_details_url) {
+        this.workflow_details_url = workflow_details_url;
+    }
+
     public User getUploader() {
         return this.uploader;
     }
@@ -124,10 +140,6 @@ public class Workflow {
         this.uploader = uploader;
     }
 
-    public void setWorkflow_details_url(String workflow_details_url) {
-        this.workflow_details_url = workflow_details_url;
-    }
-
     public String getPolicy() {
         return this.policy;
     }
@@ -144,10 +156,6 @@ public class Workflow {
         this.about = about;
     }
 
-    public void setWorkflow_datecreated(String workflow_datecreated) {
-        this.workflow_datecreated = workflow_datecreated;
-    }
-
     public String getWorkflow_datemodified() {
         return this.workflow_datemodified;
     }
@@ -164,7 +172,7 @@ public class Workflow {
         this.workflow_runs = workflow_runs;
     }
 
-    public void addWorkflowRun(Runs runs){ //adds a run to this workflow
+    public void addWorkflowRun(Runs runs) { //adds a run to this workflow
         this.workflow_runs.add(runs);
     }
 
@@ -176,46 +184,46 @@ public class Workflow {
         this.workflow_input = workflow_input;
     }
 
-    public workflow_input_type getInputType(){
-        return workflow_input_type.TYPE_INT;
+    public WorkflowInputType getInputType() {
+        return WorkflowInputType.TYPE_INT;
     }
 
     public String getWorkflow_author() {
         return this.workflow_author;
     }
 
-    public String getWorkflow_description() {
-        return this.workflow_description;
-    }
-
-    public String getWorkflow_title() {
-        return this.workflow_title;
+    public void setWorkflow_author(String workflow_author) {
+        this.workflow_author = workflow_author;
     }
 
-    public Bitmap getWorkflow_author_bitmap() {
-        return this.workflow_author_bitmap;
+    public String getWorkflow_description() {
+        return this.workflow_description;
     }
 
-    public WorkflowComponent getWorkflowComponent() {
-        return this.workflowComponent;
+    public void setWorkflow_description(String workflow_description) {
+        this.workflow_description = workflow_description;
     }
 
-    public void setWorkflow_author(String workflow_author) {
-        this.workflow_author = workflow_author;
+    public String getWorkflow_title() {
+        return this.workflow_title;
     }
 
     public void setWorkflow_title(String workflow_title) {
         this.workflow_title = workflow_title;
     }
 
-    public void setWorkflow_description(String workflow_description) {
-        this.workflow_description = workflow_description;
+    public Bitmap getWorkflow_author_bitmap() {
+        return this.workflow_author_bitmap;
     }
 
     public void setWorkflow_author_bitmap(Bitmap workflow_author_bitmap) {
         this.workflow_author_bitmap = workflow_author_bitmap;
     }
 
+    public WorkflowComponent getWorkflowComponent() {
+        return this.workflowComponent;
+    }
+
     public void setWorkflowComponent(WorkflowComponent workflowComponent) {
         this.workflowComponent = workflowComponent;
     }
@@ -304,6 +312,8 @@ public class Workflow {
     public String toString() {
         return this.workflow_title;
     }
+
+    public static enum WorkflowInputType { TYPE_INT, TYPE_STRING, TYPE_OBJECT }
 }
 /* Use the sample code if it becomes necessary to pass this objects amongst 
activities
 / simple class that just has one member property as an example
@@ -324,7 +334,8 @@ public class Workflow implements Parcelable {
         out.writeInt(mData);
     }
 
-// this is used to regenerate your object. All Parcelables must have a CREATOR 
that implements these two methods
+// this is used to regenerate your object. All Parcelables must have a CREATOR 
that implements
+these two methods
 public static final Parcelable.Creator<Workflow> CREATOR = new 
Parcelable.Creator<Workflow>() {
     public Workflow createFromParcel(Parcel in) {
         return new Workflow(in);

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/e752e97d/app/src/main/java/org/apache/taverna/mobile/tavernamobile/WorkflowComponent.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/tavernamobile/WorkflowComponent.java
 
b/app/src/main/java/org/apache/taverna/mobile/tavernamobile/WorkflowComponent.java
index dab4775..514824a 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/tavernamobile/WorkflowComponent.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/tavernamobile/WorkflowComponent.java
@@ -2,10 +2,10 @@ package org.apache.taverna.mobile.tavernamobile;
 /**
  * Apache Taverna Mobile
  * Copyright 2015 The Apache Software Foundation
-
+ *
  * This product includes software developed at
  * The Apache Software Foundation (http://www.apache.org/).
-
+ *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
@@ -23,9 +23,11 @@ package org.apache.taverna.mobile.tavernamobile;
  * specific language governing permissions and limitations
  * under the License.
  */
+
 /**
  * Created by Larry Akah on 6/8/15.
- * the component elements that make up a workflow's dataflow (e.g. Taverna has 
sources, sinks, processors, links and coordinations)
+ * the component elements that make up a workflow's dataflow (e.g. Taverna has 
sources, sinks,
+ * processors, links and coordinations)
  */
 public class WorkflowComponent {
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/e752e97d/app/src/main/java/org/apache/taverna/mobile/ui/adapter/AnnouncementAdapter.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/ui/adapter/AnnouncementAdapter.java
 
b/app/src/main/java/org/apache/taverna/mobile/ui/adapter/AnnouncementAdapter.java
index c25e50d..95f3239 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/ui/adapter/AnnouncementAdapter.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/ui/adapter/AnnouncementAdapter.java
@@ -18,6 +18,9 @@
  */
 package org.apache.taverna.mobile.ui.adapter;
 
+import org.apache.taverna.mobile.R;
+import org.apache.taverna.mobile.data.model.Announcement;
+
 import android.support.v7.widget.RecyclerView;
 import android.util.Log;
 import android.view.LayoutInflater;
@@ -26,9 +29,6 @@ import android.view.ViewGroup;
 import android.widget.ProgressBar;
 import android.widget.TextView;
 
-import org.apache.taverna.mobile.R;
-import org.apache.taverna.mobile.data.model.Announcement;
-
 import java.util.List;
 
 import butterknife.BindView;
@@ -37,12 +37,12 @@ import butterknife.ButterKnife;
 
 public class AnnouncementAdapter extends 
RecyclerView.Adapter<RecyclerView.ViewHolder> {
 
-    private List<Announcement> mAnnouncementList;
     private final int VIEW_ITEM = 1;
     private final int VIEW_PROG = 0;
+    private List<Announcement> mAnnouncementList;
 
 
-    public AnnouncementAdapter( List<Announcement> announcementList) {
+    public AnnouncementAdapter(List<Announcement> announcementList) {
         mAnnouncementList = announcementList;
     }
 
@@ -50,15 +50,6 @@ public class AnnouncementAdapter extends 
RecyclerView.Adapter<RecyclerView.ViewH
         mAnnouncementList = announcementList;
     }
 
-    public static class ProgressViewHolder extends RecyclerView.ViewHolder {
-        public ProgressBar progressBar;
-        public ProgressViewHolder(View v) {
-            super(v);
-            progressBar = (ProgressBar)v.findViewById(R.id.progressBar1);
-        }
-    }
-
-
     @Override
     public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int 
viewType) {
         RecyclerView.ViewHolder vh;
@@ -78,9 +69,10 @@ public class AnnouncementAdapter extends 
RecyclerView.Adapter<RecyclerView.ViewH
 
     @Override
     public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) 
{
-        if(holder instanceof ViewHolder) {
-            ((ViewHolder) 
holder).tvAnnouncementTitle.setText(mAnnouncementList.get(position).getContent());
-            Log.e("", "onBindViewHolder: 
"+mAnnouncementList.get(1).getContent());
+        if (holder instanceof ViewHolder) {
+            ((ViewHolder) 
holder).tvAnnouncementTitle.setText(mAnnouncementList.get(position)
+                    .getContent());
+            Log.e("", "onBindViewHolder: " + 
mAnnouncementList.get(1).getContent());
         }
     }
 
@@ -91,9 +83,17 @@ public class AnnouncementAdapter extends 
RecyclerView.Adapter<RecyclerView.ViewH
 
     @Override
     public int getItemViewType(int position) {
-        return mAnnouncementList.get(position)!=null? VIEW_ITEM: VIEW_PROG;
+        return mAnnouncementList.get(position) != null ? VIEW_ITEM : VIEW_PROG;
     }
 
+    public static class ProgressViewHolder extends RecyclerView.ViewHolder {
+        public ProgressBar progressBar;
+
+        public ProgressViewHolder(View v) {
+            super(v);
+            progressBar = (ProgressBar) v.findViewById(R.id.progressBar1);
+        }
+    }
 
     class ViewHolder extends RecyclerView.ViewHolder {
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/e752e97d/app/src/main/java/org/apache/taverna/mobile/ui/adapter/EndlessRecyclerOnScrollListener.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/ui/adapter/EndlessRecyclerOnScrollListener.java
 
b/app/src/main/java/org/apache/taverna/mobile/ui/adapter/EndlessRecyclerOnScrollListener.java
index f3fb3f5..24bc319 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/ui/adapter/EndlessRecyclerOnScrollListener.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/ui/adapter/EndlessRecyclerOnScrollListener.java
@@ -24,12 +24,12 @@ import android.support.v7.widget.RecyclerView;
 
 public abstract class EndlessRecyclerOnScrollListener extends 
RecyclerView.OnScrollListener {
     public static String TAG = 
EndlessRecyclerOnScrollListener.class.getSimpleName();
-
-    private int previousTotal = 0; // The total number of items in the dataset 
after the last load
-    private boolean loading = true; // True if we are still waiting for the 
last set of data to load.
-    private int visibleThreshold = 1; // The minimum amount of items to have 
below your current scroll position before loading more.
     int firstVisibleItem, visibleItemCount, totalItemCount;
-
+    private int previousTotal = 0; // The total number of items in the dataset 
after the last load
+    private boolean loading = true; // True if we are still waiting for the 
last set of data to
+    // load.
+    private int visibleThreshold = 1; // The minimum amount of items to have 
below your current
+    // scroll position before loading more.
     private int current_page = 1;
 
     private LinearLayoutManager mLinearLayoutManager;
@@ -47,12 +47,13 @@ public abstract class EndlessRecyclerOnScrollListener 
extends RecyclerView.OnScr
         firstVisibleItem = mLinearLayoutManager.findFirstVisibleItemPosition();
 
         if (loading) {
-            if (totalItemCount > previousTotal+1) {
+            if (totalItemCount > previousTotal + 1) {
                 loading = false;
                 previousTotal = totalItemCount;
             }
         }
-        if (!loading && (totalItemCount - visibleItemCount) <= 
(firstVisibleItem + visibleThreshold)) {
+        if (!loading && (totalItemCount - visibleItemCount) <= 
(firstVisibleItem +
+                visibleThreshold)) {
             // End has been reached
             // Do something
             current_page++;

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/e752e97d/app/src/main/java/org/apache/taverna/mobile/ui/adapter/RecyclerItemClickListner.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/ui/adapter/RecyclerItemClickListner.java
 
b/app/src/main/java/org/apache/taverna/mobile/ui/adapter/RecyclerItemClickListner.java
index 5c0df16..ac17eb4 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/ui/adapter/RecyclerItemClickListner.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/ui/adapter/RecyclerItemClickListner.java
@@ -27,114 +27,114 @@ import android.view.View;
 
 
 public class RecyclerItemClickListner implements 
RecyclerView.OnItemTouchListener {
- 
+
     protected OnItemClickListener listener;
- 
+
     private GestureDetector gestureDetector;
- 
+
     @Nullable
     private View childView;
- 
+
     private int childViewPosition;
- 
+
     public RecyclerItemClickListner(Context context, OnItemClickListener 
listener) {
         this.gestureDetector = new GestureDetector(context, new 
GestureListener());
         this.listener = listener;
-    } 
- 
-    @Override 
+    }
+
+    @Override
     public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent event) 
{
         childView = view.findChildViewUnder(event.getX(), event.getY());
         childViewPosition = view.getChildAdapterPosition(childView);
- 
+
         return childView != null && gestureDetector.onTouchEvent(event);
-    } 
- 
-    @Override 
+    }
+
+    @Override
     public void onTouchEvent(RecyclerView view, MotionEvent event) {
         // Not needed. 
-    } 
- 
-    @Override 
+    }
+
+    @Override
     public void onRequestDisallowInterceptTouchEvent(boolean 
disallowIntercept) {
- 
-    } 
- 
-    /** 
-     * A click listener for items. 
-     */ 
-    public interface OnItemClickListener { 
- 
-        /** 
-         * Called when an item is clicked. 
-         * 
-         * @param childView View of the item that was clicked. 
-         * @param position  Position of the item that was clicked. 
-         */ 
+
+    }
+
+    /**
+     * A click listener for items.
+     */
+    public interface OnItemClickListener {
+
+        /**
+         * Called when an item is clicked.
+         *
+         * @param childView View of the item that was clicked.
+         * @param position  Position of the item that was clicked.
+         */
         public void onItemClick(View childView, int position);
- 
-        /** 
-         * Called when an item is long pressed. 
-         * 
-         * @param childView View of the item that was long pressed. 
-         * @param position  Position of the item that was long pressed. 
-         */ 
+
+        /**
+         * Called when an item is long pressed.
+         *
+         * @param childView View of the item that was long pressed.
+         * @param position  Position of the item that was long pressed.
+         */
         public void onItemLongPress(View childView, int position);
- 
-    } 
- 
-    /** 
-     * A simple click listener whose methods can be overridden one by one. 
-     */ 
-    public static abstract class SimpleOnItemClickListener implements 
OnItemClickListener { 
- 
-        /** 
-         * Called when an item is clicked. The default implementation is a 
no-op. 
-         * 
-         * @param childView View of the item that was clicked. 
-         * @param position  Position of the item that was clicked. 
-         */ 
+
+    }
+
+    /**
+     * A simple click listener whose methods can be overridden one by one.
+     */
+    public abstract static class SimpleOnItemClickListener implements 
OnItemClickListener {
+
+        /**
+         * Called when an item is clicked. The default implementation is a 
no-op.
+         *
+         * @param childView View of the item that was clicked.
+         * @param position  Position of the item that was clicked.
+         */
         public void onItemClick(View childView, int position) {
             // Do nothing. 
-        } 
- 
-        /** 
-         * Called when an item is long pressed. The default implementation is 
a no-op. 
-         * 
-         * @param childView View of the item that was long pressed. 
-         * @param position  Position of the item that was long pressed. 
-         */ 
+        }
+
+        /**
+         * Called when an item is long pressed. The default implementation is 
a no-op.
+         *
+         * @param childView View of the item that was long pressed.
+         * @param position  Position of the item that was long pressed.
+         */
         public void onItemLongPress(View childView, int position) {
             // Do nothing. 
-        } 
- 
-    } 
- 
+        }
+
+    }
+
     protected class GestureListener extends 
GestureDetector.SimpleOnGestureListener {
- 
-        @Override 
+
+        @Override
         public boolean onSingleTapUp(MotionEvent event) {
             if (childView != null) {
                 listener.onItemClick(childView, childViewPosition);
-            } 
- 
-            return true; 
-        } 
- 
-        @Override 
+            }
+
+            return true;
+        }
+
+        @Override
         public void onLongPress(MotionEvent event) {
             if (childView != null) {
                 listener.onItemLongPress(childView, childViewPosition);
-            } 
-        } 
- 
-        @Override 
+            }
+        }
+
+        @Override
         public boolean onDown(MotionEvent event) {
             // Best practice to always return true here. 
             // 
http://developer.android.com/training/gestures/detector.html#detect 
-            return true; 
-        } 
- 
-    } 
- 
+            return true;
+        }
+
+    }
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/e752e97d/app/src/main/java/org/apache/taverna/mobile/ui/anouncements/AnnouncementFragment.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/ui/anouncements/AnnouncementFragment.java
 
b/app/src/main/java/org/apache/taverna/mobile/ui/anouncements/AnnouncementFragment.java
index d10f802..6143df4 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/ui/anouncements/AnnouncementFragment.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/ui/anouncements/AnnouncementFragment.java
@@ -18,6 +18,16 @@
  */
 package org.apache.taverna.mobile.ui.anouncements;
 
+import org.apache.taverna.mobile.R;
+import org.apache.taverna.mobile.data.DataManager;
+import org.apache.taverna.mobile.data.model.Announcements;
+import org.apache.taverna.mobile.data.model.DetailAnnouncement;
+import org.apache.taverna.mobile.ui.adapter.AnnouncementAdapter;
+import org.apache.taverna.mobile.ui.adapter.EndlessRecyclerOnScrollListener;
+import org.apache.taverna.mobile.ui.adapter.RecyclerItemClickListner;
+import org.apache.taverna.mobile.utils.ConnectionInfo;
+import org.apache.taverna.mobile.utils.ScrollChildSwipeRefreshLayout;
+
 import android.app.ProgressDialog;
 import android.os.Bundle;
 import android.support.design.widget.Snackbar;
@@ -39,21 +49,12 @@ import android.widget.Button;
 import android.widget.ProgressBar;
 import android.widget.TextView;
 
-import org.apache.taverna.mobile.R;
-import org.apache.taverna.mobile.data.DataManager;
-import org.apache.taverna.mobile.data.model.Announcements;
-import org.apache.taverna.mobile.data.model.DetailAnnouncement;
-import org.apache.taverna.mobile.ui.adapter.AnnouncementAdapter;
-import org.apache.taverna.mobile.ui.adapter.EndlessRecyclerOnScrollListener;
-import org.apache.taverna.mobile.ui.adapter.RecyclerItemClickListner;
-import org.apache.taverna.mobile.utils.ConnectionInfo;
-import org.apache.taverna.mobile.utils.ScrollChildSwipeRefreshLayout;
-
 import butterknife.BindView;
 import butterknife.ButterKnife;
 
 
-public class AnnouncementFragment extends Fragment implements 
RecyclerItemClickListner.OnItemClickListener, AnnouncementMvpView {
+public class AnnouncementFragment extends Fragment implements 
RecyclerItemClickListner
+        .OnItemClickListener, AnnouncementMvpView {
 
     public final String LOG_TAG = getClass().getSimpleName();
 
@@ -66,7 +67,7 @@ public class AnnouncementFragment extends Fragment implements 
RecyclerItemClickL
     @BindView(R.id.progress_circular)
     ProgressBar mProgressBar;
 
-    private  AlertDialog alertDialog;
+    private AlertDialog alertDialog;
 
     private ProgressDialog dialog;
 
@@ -87,7 +88,8 @@ public class AnnouncementFragment extends Fragment implements 
RecyclerItemClickL
     @Override
     public void onItemClick(View childView, int position) {
         showWaitProgress(true);
-        
mAnnouncementPresenter.loadAnnouncementDetails(mAnnouncements.getAnnouncement().get(position).getId());
+        
mAnnouncementPresenter.loadAnnouncementDetails(mAnnouncements.getAnnouncement().get
+                (position).getId());
     }
 
     @Override
@@ -103,12 +105,13 @@ public class AnnouncementFragment extends Fragment 
implements RecyclerItemClickL
         mAnnouncements = new Announcements();
         dataManager = new DataManager();
         mAnnouncementPresenter = new AnnouncementPresenter(dataManager);
-        mConnectionInfo =new ConnectionInfo(getContext());
+        mConnectionInfo = new ConnectionInfo(getContext());
     }
 
 
     @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
Bundle savedInstanceState) {
+    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
Bundle
+            savedInstanceState) {
         View rootView = inflater.inflate(R.layout.fragment_announcement, 
container, false);
         ButterKnife.bind(this, rootView);
         mAnnouncementPresenter.attachView(this);
@@ -129,7 +132,8 @@ public class AnnouncementFragment extends Fragment 
implements RecyclerItemClickL
         mRecyclerView.setItemAnimator(new DefaultItemAnimator());
 
 
-        mSwipeRefresh.setColorSchemeResources(R.color.colorAccent, 
R.color.colorAccent, R.color.colorPrimary);
+        mSwipeRefresh.setColorSchemeResources(R.color.colorAccent, 
R.color.colorAccent, R.color
+                .colorPrimary);
         mSwipeRefresh.setOnRefreshListener(new 
SwipeRefreshLayout.OnRefreshListener() {
             @Override
             public void onRefresh() {
@@ -159,7 +163,8 @@ public class AnnouncementFragment extends Fragment 
implements RecyclerItemClickL
 
                 if (mConnectionInfo.isConnectingToInternet()) {
                     mAnnouncements.getAnnouncement().add(null);
-                    
mAnnouncementAdapter.notifyItemInserted(mAnnouncements.getAnnouncement().size());
+                    
mAnnouncementAdapter.notifyItemInserted(mAnnouncements.getAnnouncement().size
+                            ());
                     mPageNumber = ++mPageNumber;
                     mAnnouncementPresenter.loadAllAnnouncement(mPageNumber);
                     Log.i(LOG_TAG, "Loading more");
@@ -216,7 +221,7 @@ public class AnnouncementFragment extends Fragment 
implements RecyclerItemClickL
         TextView date = ButterKnife.findById(dialogView, R.id.tvDialogDate);
         TextView author = ButterKnife.findById(dialogView, 
R.id.tvDialogAuthor);
         WebView text = ButterKnife.findById(dialogView, R.id.wvDialogText);
-        Button buttonOk=ButterKnife.findById(dialogView, R.id.bDialogOK);
+        Button buttonOk = ButterKnife.findById(dialogView, R.id.bDialogOK);
         buttonOk.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
@@ -236,8 +241,9 @@ public class AnnouncementFragment extends Fragment 
implements RecyclerItemClickL
         super.onResume();
     }
 
-    public void showErrorSnackBar(){
-        final Snackbar snackbar = Snackbar.make(mRecyclerView, "No Internet 
Connection", Snackbar.LENGTH_LONG);
+    public void showErrorSnackBar() {
+        final Snackbar snackbar = Snackbar.make(mRecyclerView, "No Internet 
Connection", Snackbar
+                .LENGTH_LONG);
         snackbar.setAction("OK", new View.OnClickListener() {
             @Override
             public void onClick(View view) {
@@ -250,9 +256,9 @@ public class AnnouncementFragment extends Fragment 
implements RecyclerItemClickL
 
     @Override
     public void showWaitProgress(boolean b) {
-        if(b){
-           dialog  = ProgressDialog.show(getContext(), "Loading", "Please 
wait...", true);
-        }else{
+        if (b) {
+            dialog = ProgressDialog.show(getContext(), "Loading", "Please 
wait...", true);
+        } else {
             dialog.dismiss();
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/e752e97d/app/src/main/java/org/apache/taverna/mobile/ui/anouncements/AnnouncementMvpView.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/ui/anouncements/AnnouncementMvpView.java
 
b/app/src/main/java/org/apache/taverna/mobile/ui/anouncements/AnnouncementMvpView.java
index cfaaa57..e741d35 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/ui/anouncements/AnnouncementMvpView.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/ui/anouncements/AnnouncementMvpView.java
@@ -18,16 +18,20 @@
  */
 package org.apache.taverna.mobile.ui.anouncements;
 
-import org.apache.taverna.mobile.data.model.DetailAnnouncement;
 import org.apache.taverna.mobile.data.model.Announcements;
+import org.apache.taverna.mobile.data.model.DetailAnnouncement;
 import org.apache.taverna.mobile.ui.base.MvpView;
 
 
 public interface AnnouncementMvpView extends MvpView {
 
     void showAllAnouncement(Announcements announcements);
+
     void showProgressbar(boolean b);
+
     void showErrorSnackBar();
+
     void showWaitProgress(boolean b);
+
     void showAnnouncementDetail(DetailAnnouncement detailAnnouncement);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/e752e97d/app/src/main/java/org/apache/taverna/mobile/ui/anouncements/AnnouncementPresenter.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/ui/anouncements/AnnouncementPresenter.java
 
b/app/src/main/java/org/apache/taverna/mobile/ui/anouncements/AnnouncementPresenter.java
index d4e5cfe..c8ca5a7 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/ui/anouncements/AnnouncementPresenter.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/ui/anouncements/AnnouncementPresenter.java
@@ -18,12 +18,13 @@
  */
 package org.apache.taverna.mobile.ui.anouncements;
 
-import android.util.Log;
-
 import org.apache.taverna.mobile.data.DataManager;
-import org.apache.taverna.mobile.data.model.DetailAnnouncement;
 import org.apache.taverna.mobile.data.model.Announcements;
+import org.apache.taverna.mobile.data.model.DetailAnnouncement;
 import org.apache.taverna.mobile.ui.base.BasePresenter;
+
+import android.util.Log;
+
 import rx.Observer;
 import rx.Subscription;
 import rx.android.schedulers.AndroidSchedulers;
@@ -37,7 +38,7 @@ public class AnnouncementPresenter extends 
BasePresenter<AnnouncementMvpView> {
     private Subscription mSubscriptions;
 
 
-    public AnnouncementPresenter(DataManager dataManager){
+    public AnnouncementPresenter(DataManager dataManager) {
         mDataManager = dataManager;
     }
 
@@ -52,7 +53,7 @@ public class AnnouncementPresenter extends 
BasePresenter<AnnouncementMvpView> {
         if (mSubscriptions != null) mSubscriptions.unsubscribe();
     }
 
-    public void loadAllAnnouncement(int pageNumber){
+    public void loadAllAnnouncement(int pageNumber) {
 
         mSubscriptions = mDataManager.getAllAnnouncement(pageNumber)
                 .observeOn(AndroidSchedulers.mainThread())
@@ -73,11 +74,12 @@ public class AnnouncementPresenter extends 
BasePresenter<AnnouncementMvpView> {
                     @Override
                     public void onNext(Announcements announcement) {
                         getMvpView().showAllAnouncement(announcement);
-                        
Log.d(LOG_TAG,announcement.getAnnouncement().get(1).getResource());
+                        Log.d(LOG_TAG, 
announcement.getAnnouncement().get(1).getResource());
                     }
                 });
     }
-    public void loadAnnouncementDetails(String id){
+
+    public void loadAnnouncementDetails(String id) {
 
         mSubscriptions = mDataManager.getAnnouncementDetail(id)
                 .observeOn(AndroidSchedulers.mainThread())
@@ -90,7 +92,7 @@ public class AnnouncementPresenter extends 
BasePresenter<AnnouncementMvpView> {
 
                     @Override
                     public void onError(Throwable e) {
-                        Log.d(LOG_TAG,e.getMessage());
+                        Log.d(LOG_TAG, e.getMessage());
                         getMvpView().showWaitProgress(false);
                         getMvpView().showErrorSnackBar();
                     }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/e752e97d/app/src/main/java/org/apache/taverna/mobile/utils/AvatarLoader.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/utils/AvatarLoader.java 
b/app/src/main/java/org/apache/taverna/mobile/utils/AvatarLoader.java
index cf989fa..e724bfa 100644
--- a/app/src/main/java/org/apache/taverna/mobile/utils/AvatarLoader.java
+++ b/app/src/main/java/org/apache/taverna/mobile/utils/AvatarLoader.java
@@ -2,10 +2,10 @@ package org.apache.taverna.mobile.utils;
 /**
  * Apache Taverna Mobile
  * Copyright 2015 The Apache Software Foundation
-
+ *
  * This product includes software developed at
  * The Apache Software Foundation (http://www.apache.org/).
-
+ *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
@@ -23,7 +23,6 @@ package org.apache.taverna.mobile.utils;
  * specific language governing permissions and limitations
  * under the License.
  */
-import android.os.AsyncTask;
 
 import com.thebuzzmedia.sjxp.rule.IRule;
 
@@ -32,6 +31,8 @@ import org.apache.taverna.mobile.tavernamobile.User;
 import org.apache.taverna.mobile.utils.xmlparsers.AvatarXMLParser;
 import org.apache.taverna.mobile.utils.xmlparsers.MyExperimentXmlParserRules;
 
+import android.os.AsyncTask;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.HttpURLConnection;
@@ -39,11 +40,13 @@ import java.net.MalformedURLException;
 import java.net.URL;
 
 /**
- * initiates a process to fetch and parse uploader information so as to 
retrieve the id, name and avatar link
+ * initiates a process to fetch and parse uploader information so as to 
retrieve the id, name and
+ * avatar link
  * Created by Larry AKah on 6/29/15.
  */
 public class AvatarLoader extends AsyncTask<String, Void, Void> {
     WorkflowAdapter.ViewHolder vh;
+
     public AvatarLoader(WorkflowAdapter.ViewHolder userViewHolder) {
         this.vh = userViewHolder;
     }
@@ -59,9 +62,12 @@ public class AvatarLoader extends AsyncTask<String, Void, 
Void> {
             connection.setDoInput(true);
             connection.connect();
             InputStream input = connection.getInputStream();
-            IRule avatarRule = new 
MyExperimentXmlParserRules.AuthorRule(IRule.Type.ATTRIBUTE,"/user/avatar", 
"resource","uri","id");
-            IRule avatarName = new 
MyExperimentXmlParserRules.AuthorRule(IRule.Type.CHARACTER,"/user/name");
-            AvatarXMLParser avatarXMLParser = new AvatarXMLParser(new 
IRule[]{avatarRule, avatarName});
+            IRule avatarRule = new 
MyExperimentXmlParserRules.AuthorRule(IRule.Type.ATTRIBUTE,
+                    "/user/avatar", "resource", "uri", "id");
+            IRule avatarName = new 
MyExperimentXmlParserRules.AuthorRule(IRule.Type.CHARACTER,
+                    "/user/name");
+            AvatarXMLParser avatarXMLParser = new AvatarXMLParser(new 
IRule[]{avatarRule,
+                    avatarName});
 
             avatarXMLParser.parse(input, new User(strings[1], this.vh));
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/e752e97d/app/src/main/java/org/apache/taverna/mobile/utils/ConnectionInfo.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/utils/ConnectionInfo.java 
b/app/src/main/java/org/apache/taverna/mobile/utils/ConnectionInfo.java
index cd11e90..8704071 100644
--- a/app/src/main/java/org/apache/taverna/mobile/utils/ConnectionInfo.java
+++ b/app/src/main/java/org/apache/taverna/mobile/utils/ConnectionInfo.java
@@ -36,7 +36,8 @@ public class ConnectionInfo {
 
 
     public boolean isConnectingToInternet() {
-        ConnectivityManager connectivity = (ConnectivityManager) 
context.getSystemService(Context.CONNECTIVITY_SERVICE);
+        ConnectivityManager connectivity = (ConnectivityManager) 
context.getSystemService(Context
+                .CONNECTIVITY_SERVICE);
         if (connectivity != null) {
             NetworkInfo[] info = connectivity.getAllNetworkInfo();
             if (info != null)

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/e752e97d/app/src/main/java/org/apache/taverna/mobile/utils/DBUtility.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/taverna/mobile/utils/DBUtility.java 
b/app/src/main/java/org/apache/taverna/mobile/utils/DBUtility.java
new file mode 100644
index 0000000..df7b990
--- /dev/null
+++ b/app/src/main/java/org/apache/taverna/mobile/utils/DBUtility.java
@@ -0,0 +1,65 @@
+package org.apache.taverna.mobile.utils;
+/**
+ * Apache Taverna Mobile
+ * Copyright 2015 The Apache Software Foundation
+ *
+ * This product includes software developed at
+ * The Apache Software Foundation (http://www.apache.org/).
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.json.JSONArray;
+import org.json.JSONException;
+
+import java.util.ArrayList;
+
+/**
+ * This class contains all utility functions used by our database for basic 
functionality not
+ * directly related to the core
+ * functionality of it but that aids a core functionality to carryout its 
function efficiently.
+ * This class is designed to be a singleton class
+ *
+ * @author Larry Akah
+ */
+public class DBUtility {
+
+    /**
+     * Returns a new JSONArray of new key values to be stored ommitting the 
identified entry to be
+     * removed
+     */
+    public static JSONArray removeKey(JSONArray keys, String removeid) throws 
JSONException {
+        ArrayList<String> mkeys = new ArrayList<String>();
+        if (keys != null) {
+            for (int i = 0; i < keys.length(); i++) {
+                mkeys.add(keys.getString(i));
+            }
+            mkeys.remove(removeid);
+            JSONArray nkeyArray = new JSONArray();
+            for (String newkey : mkeys) {
+                nkeyArray.put(newkey);
+            }
+            return nkeyArray; //returns the new keys to save under the db;
+
+        } else {
+            return keys; //returns a null value indicating nothin to remove 
due to no keys available
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/e752e97d/app/src/main/java/org/apache/taverna/mobile/utils/DB_Utility.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/taverna/mobile/utils/DB_Utility.java 
b/app/src/main/java/org/apache/taverna/mobile/utils/DB_Utility.java
deleted file mode 100644
index 4ae919c..0000000
--- a/app/src/main/java/org/apache/taverna/mobile/utils/DB_Utility.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.apache.taverna.mobile.utils;
-/**
- * Apache Taverna Mobile
- * Copyright 2015 The Apache Software Foundation
-
- * This product includes software developed at
- * The Apache Software Foundation (http://www.apache.org/).
-
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-import org.json.JSONArray;
-import org.json.JSONException;
-
-import java.util.ArrayList;
-
-/**
- * This class contains all utility functions used by our database for basic 
functionality not directly related to the core
- * functionality of it but that aids a core functionality to carryout its 
function efficiently.
- * This class is designed to be a singleton class
- * @author Larry Akah
- *
- */
-public class DB_Utility {
-
-       /**
-        * Returns a new JSONArray of new key values to be stored ommitting the 
identified entry to be removed
-        * @param keys
-        * @param removeid
-        * @return
-        * @throws org.json.JSONException
-        */
-       public static JSONArray removeKey(JSONArray keys, String removeid) 
throws JSONException{
-               ArrayList<String> mkeys = new ArrayList<String>();
-               if(keys!=null){
-               for(int i=0; i<keys.length(); i++){
-                       mkeys.add(keys.getString(i));
-                       }
-               mkeys.remove(removeid);
-               JSONArray nkeyArray = new JSONArray();
-               for(String newkey: mkeys){
-                       nkeyArray.put(newkey);
-               }
-               return nkeyArray; //returns the new keys to save under the db;
-               
-               }
-               else{
-                       return keys; //returns a null value indicating nothin 
to remove due to no keys available
-               }
-               
-       }
-       
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/e752e97d/app/src/main/java/org/apache/taverna/mobile/utils/DetailsLoader.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/utils/DetailsLoader.java 
b/app/src/main/java/org/apache/taverna/mobile/utils/DetailsLoader.java
index 013e826..9152b97 100644
--- a/app/src/main/java/org/apache/taverna/mobile/utils/DetailsLoader.java
+++ b/app/src/main/java/org/apache/taverna/mobile/utils/DetailsLoader.java
@@ -2,10 +2,10 @@ package org.apache.taverna.mobile.utils;
 /**
  * Apache Taverna Mobile
  * Copyright 2015 The Apache Software Foundation
-
+ *
  * This product includes software developed at
  * The Apache Software Foundation (http://www.apache.org/).
-
+ *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
@@ -24,11 +24,6 @@ package org.apache.taverna.mobile.utils;
  * under the License.
  */
 
-import android.content.AsyncTaskLoader;
-import android.content.Context;
-import android.util.Base64;
-import android.util.Log;
-
 import com.thebuzzmedia.sjxp.rule.IRule;
 
 import org.apache.taverna.mobile.tavernamobile.Runs;
@@ -40,6 +35,11 @@ import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
 
+import android.content.AsyncTaskLoader;
+import android.content.Context;
+import android.util.Base64;
+import android.util.Log;
+
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
@@ -50,22 +50,24 @@ import java.net.MalformedURLException;
 import java.net.URL;
 
 /**
- * Loads workflow details from the myexperiment API and presents them on the 
UI .The class is generic and can be used to load the
+ * Loads workflow details from the myexperiment API and presents them on the 
UI .The class is
+ * generic and can be used to load the
  * different details sections of the app.
  * Created by Larry Akah on 6/14/15.
  */
 public class DetailsLoader extends AsyncTaskLoader<Workflow> {
 
-    public static enum LOAD_TYPE {TYPE_WORKFLOW_DETAIL, TYPE_RUN_HISTORY,  
TYPE_POLICY, TYPE_ABOUT_WORKFLOW};
-    private LOAD_TYPE lt;
+    private LoadType lt;
+
+    ;
     private String uri;
     private Workflow workflow;
     private Context context;
 
-    public DetailsLoader(Context context, LOAD_TYPE load_type, String 
dataParam) {
+    public DetailsLoader(Context context, LoadType LoadType, String dataParam) 
{
         super(context);
         this.context = context;
-        this.lt = load_type;
+        this.lt = LoadType;
         uri = dataParam;
         this.workflow = new Workflow();
     }
@@ -82,7 +84,7 @@ public class DetailsLoader extends AsyncTaskLoader<Workflow> {
             TavernaPlayerAPI tavernaPlayerAPI = new TavernaPlayerAPI();
             URL workflowurl;
 
-            switch (this.lt){
+            switch (this.lt) {
                 case TYPE_WORKFLOW_DETAIL:
                     workflowurl = new URL(uri);
                     connection = (HttpURLConnection) 
workflowurl.openConnection();
@@ -91,21 +93,23 @@ public class DetailsLoader extends 
AsyncTaskLoader<Workflow> {
                     connection.connect(); //send request
 
                     Log.i("Workflow Response Code", "" + 
connection.getResponseCode());
-                    Log.i("Workflow Response msg", 
""+connection.getResponseMessage());
+                    Log.i("Workflow Response msg", "" + 
connection.getResponseMessage());
                     dis = connection.getInputStream();
                     break;
                 case TYPE_RUN_HISTORY:
                     workflowurl = new URL(new 
TavernaPlayerAPI(this.context).PLAYER_RUN_URL);
                     connection = (HttpURLConnection) 
workflowurl.openConnection();
-                    String userpass = 
tavernaPlayerAPI.getPlayerUserName(this.context) + ":" + 
tavernaPlayerAPI.getPlayerUserPassword(this.context);
-                    String basicAuth = "Basic " + 
Base64.encodeToString(userpass.getBytes(), Base64.DEFAULT);
+                    String userpass = 
tavernaPlayerAPI.getPlayerUserName(this.context) + ":" +
+                            
tavernaPlayerAPI.getPlayerUserPassword(this.context);
+                    String basicAuth = "Basic " + 
Base64.encodeToString(userpass.getBytes(),
+                            Base64.DEFAULT);
 
-                    connection.setRequestProperty ("Authorization", basicAuth);
+                    connection.setRequestProperty("Authorization", basicAuth);
                     connection.setRequestProperty("Accept", 
"application/json");
                     connection.setRequestMethod("GET");
                     connection.connect(); //send request
                     Log.i("RESPONSE CODE", "" + connection.getResponseCode());
-                    Log.i("RESPONSE Messsage. Run", 
""+connection.getResponseMessage());
+                    Log.i("RESPONSE Messsage. Run", "" + 
connection.getResponseMessage());
                     dis = connection.getInputStream();
                     break;
                 case TYPE_POLICY:
@@ -116,46 +120,63 @@ public class DetailsLoader extends 
AsyncTaskLoader<Workflow> {
                     break;
             }
 
-            switch(this.lt) {
+            switch (this.lt) {
                 case TYPE_WORKFLOW_DETAIL: {
                     //make rules and apply the parser
-                    IRule workfl = new 
MyExperimentXmlParserRules.WorkflowDetailRule(IRule.Type.ATTRIBUTE,
-                            "/workflow", "uri","resource", "id","version");
-                    IRule title = new 
MyExperimentXmlParserRules.TitleRule(IRule.Type.CHARACTER,"/workflow/title");
-                    IRule description = new 
MyExperimentXmlParserRules.DescriptionRule(IRule.Type.CHARACTER, 
"/workflow/description");
-                    IRule type = new 
MyExperimentXmlParserRules.TypeRule(IRule.Type.CHARACTER, "/workflow/type");
-                    IRule attrType = new 
MyExperimentXmlParserRules.TypeRule(IRule.Type.ATTRIBUTE, "/workflow/type", 
"resource", "uri","id");
-                    IRule uploader = new 
MyExperimentXmlParserRules.UploaderRule(IRule.Type.CHARACTER, 
"/workflow/uploader");
-                    IRule attrUploader = new 
MyExperimentXmlParserRules.UploaderRule(IRule.Type.ATTRIBUTE, 
"/workflow/uploader",  "resource", "uri","id");
-                    IRule date = new 
MyExperimentXmlParserRules.DateRule(IRule.Type.CHARACTER, 
"/workflow/created-at");
-                    IRule preview = new 
MyExperimentXmlParserRules.PreviewRule(IRule.Type.CHARACTER, 
"/workflow/preview");
-                    IRule licetype = new 
MyExperimentXmlParserRules.LicenceTypeRule(IRule.Type.CHARACTER, 
"/workflow/licence-type");
-                    IRule attrlicetype = new 
MyExperimentXmlParserRules.LicenceTypeRule(IRule.Type.ATTRIBUTE,"/workflow/licence-type",
 "resource", "uri","id");
-                    IRule contenturi = new 
MyExperimentXmlParserRules.ContentUriRule(IRule.Type.CHARACTER, 
"/workflow/content-uri");
-                    IRule contentType = new 
MyExperimentXmlParserRules.ContentTypeRule(IRule.Type.CHARACTER, 
"/workflow/content-type");
-                    IRule tags = new 
MyExperimentXmlParserRules.TagsRule(IRule.Type.CHARACTER, "/workflow/tags/tag");
-                    IRule attrTags = new 
MyExperimentXmlParserRules.TagsRule(IRule.Type.ATTRIBUTE, "/workflow/tags/tag", 
"resource", "uri","id");
-
-                    WorkflowDetailParser parser = new WorkflowDetailParser(new 
IRule[]{workfl,title,description,type,
-                            attrlicetype,attrType, 
uploader,attrUploader,date,preview,licetype,contenturi,contentType,tags,attrTags});
-                 //   System.out.println(sb.toString());
+                    IRule workfl = new 
MyExperimentXmlParserRules.WorkflowDetailRule(IRule.Type
+                            .ATTRIBUTE,
+                            "/workflow", "uri", "resource", "id", "version");
+                    IRule title = new 
MyExperimentXmlParserRules.TitleRule(IRule.Type.CHARACTER,
+                            "/workflow/title");
+                    IRule description = new 
MyExperimentXmlParserRules.DescriptionRule(IRule.Type
+                            .CHARACTER, "/workflow/description");
+                    IRule type = new 
MyExperimentXmlParserRules.TypeRule(IRule.Type.CHARACTER,
+                            "/workflow/type");
+                    IRule attrType = new 
MyExperimentXmlParserRules.TypeRule(IRule.Type
+                            .ATTRIBUTE, "/workflow/type", "resource", "uri", 
"id");
+                    IRule uploader = new 
MyExperimentXmlParserRules.UploaderRule(IRule.Type
+                            .CHARACTER, "/workflow/uploader");
+                    IRule attrUploader = new 
MyExperimentXmlParserRules.UploaderRule(IRule.Type
+                            .ATTRIBUTE, "/workflow/uploader", "resource", 
"uri", "id");
+                    IRule date = new 
MyExperimentXmlParserRules.DateRule(IRule.Type.CHARACTER,
+                            "/workflow/created-at");
+                    IRule preview = new 
MyExperimentXmlParserRules.PreviewRule(IRule.Type
+                            .CHARACTER, "/workflow/preview");
+                    IRule licetype = new 
MyExperimentXmlParserRules.LicenceTypeRule(IRule.Type
+                            .CHARACTER, "/workflow/licence-type");
+                    IRule attrlicetype = new 
MyExperimentXmlParserRules.LicenceTypeRule(IRule
+                            .Type.ATTRIBUTE, "/workflow/licence-type", 
"resource", "uri", "id");
+                    IRule contenturi = new 
MyExperimentXmlParserRules.ContentUriRule(IRule.Type
+                            .CHARACTER, "/workflow/content-uri");
+                    IRule contentType = new 
MyExperimentXmlParserRules.ContentTypeRule(IRule.Type
+                            .CHARACTER, "/workflow/content-type");
+                    IRule tags = new 
MyExperimentXmlParserRules.TagsRule(IRule.Type.CHARACTER,
+                            "/workflow/tags/tag");
+                    IRule attrTags = new 
MyExperimentXmlParserRules.TagsRule(IRule.Type
+                            .ATTRIBUTE, "/workflow/tags/tag", "resource", 
"uri", "id");
+
+                    WorkflowDetailParser parser = new WorkflowDetailParser(new 
IRule[]{workfl,
+                            title, description, type,
+                            attrlicetype, attrType, uploader, attrUploader, 
date, preview,
+                            licetype, contenturi, contentType, tags, 
attrTags});
+                    //   System.out.println(sb.toString());
                     parser.parse(dis, this.workflow);
                 }
-                dis.close();
+                    dis.close();
                 //br.close();
-                    return workflow;
-                case TYPE_RUN_HISTORY:{
+                return workflow;
+                case TYPE_RUN_HISTORY: {
                     System.out.println("Downloading run history");
                     BufferedReader br = new BufferedReader(new 
InputStreamReader(dis));
                     StringBuffer sb = new StringBuffer();
                     String jsonData = "";
-                    while((jsonData = br.readLine()) != null){
+                    while ((jsonData = br.readLine()) != null) {
                         sb.append(jsonData);
                     }
                     workflow = new Workflow(this.context);
                     JSONArray jsonArray = new JSONArray(sb.toString());
                     Log.i("RUN JSON ", jsonArray.toString(2));
-                    for(int j=0; j< jsonArray.length();j++){
+                    for (int j = 0; j < jsonArray.length(); j++) {
                         JSONObject jsonObject = jsonArray.getJSONObject(j);
                         long id = jsonObject.getLong("id");
                         long workflow_id = jsonObject.getLong("workflow_id");
@@ -166,13 +187,13 @@ public class DetailsLoader extends 
AsyncTaskLoader<Workflow> {
                         JSONObject userobj = jsonObject.getJSONObject("user");
                         String username = userobj.getString("name");
                         StringBuffer nm = new StringBuffer(), ur = new 
StringBuffer();
-                        for(String n: name.toLowerCase().split(" "))
+                        for (String n : name.toLowerCase().split(" "))
                             nm.append(n);
-                        for (String p: uri.toLowerCase().split(" "))
+                        for (String p : uri.toLowerCase().split(" "))
                             ur.append(p);
 
-                        if(nm.toString().equals(ur.toString())) {
-                            Runs mrun = new Runs(name,started,ended,state);
+                        if (nm.toString().equals(ur.toString())) {
+                            Runs mrun = new Runs(name, started, ended, state);
                             mrun.setRun_id(id);
                             mrun.setRun_workflow_id(workflow_id);
                             mrun.setRun_author(username);
@@ -181,16 +202,16 @@ public class DetailsLoader extends 
AsyncTaskLoader<Workflow> {
                         }
                     }
                 }
-                    return workflow;
-                case TYPE_POLICY:{
+                return workflow;
+                case TYPE_POLICY: {
 
                 }
-                    return workflow;
+                return workflow;
                 default:
                     BufferedReader br = new BufferedReader(new 
InputStreamReader(dis));
                     StringBuffer sb = new StringBuffer();
                     String jsonData = "";
-                    while((jsonData = br.readLine()) != null){
+                    while ((jsonData = br.readLine()) != null) {
                         sb.append(jsonData);
                     }
                     dis.close();
@@ -221,32 +242,37 @@ public class DetailsLoader extends 
AsyncTaskLoader<Workflow> {
             forceLoad();
         }*/
         forceLoad();
-        Log.i("Loading State","loading started");
+        Log.i("Loading State", "loading started");
     }
 
     @Override
     protected void onStopLoading() {
-        Log.i("Loading detailComponent","loading stopped");
+        Log.i("Loading detailComponent", "loading stopped");
     }
 
     @Override
     public void deliverResult(Workflow data) {
-        if(isStarted()){
+        if (isStarted()) {
             super.deliverResult(data);
         }
     }
+
+    public static enum LoadType {
+        TYPE_WORKFLOW_DETAIL, TYPE_RUN_HISTORY, TYPE_POLICY,
+        TYPE_ABOUT_WORKFLOW
+    }
 }
 /**
  * JSONObject js = new JSONObject(sb.toString());
- Log.i("JSON ", js.toString(2));
- String created_at = js.getString("created_at");
- String updated_at = js.getString("updated_at");
- JSONObject user = js.getJSONObject("user");
- workflow = new Workflow(this.context, js.getString("title"),
- user.getString("name"),
- js.getString("description"),
- js.getInt("id"),
- js.getString("url"));
- workflow.setWorkflow_datecreated(created_at);
- workflow.setWorkflow_datemodified(updated_at);
+ * Log.i("JSON ", js.toString(2));
+ * String created_at = js.getString("created_at");
+ * String updated_at = js.getString("updated_at");
+ * JSONObject user = js.getJSONObject("user");
+ * workflow = new Workflow(this.context, js.getString("title"),
+ * user.getString("name"),
+ * js.getString("description"),
+ * js.getInt("id"),
+ * js.getString("url"));
+ * workflow.setWorkflow_datecreated(created_at);
+ * workflow.setWorkflow_datemodified(updated_at);
  **/
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/e752e97d/app/src/main/java/org/apache/taverna/mobile/utils/HttpUtil.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/taverna/mobile/utils/HttpUtil.java 
b/app/src/main/java/org/apache/taverna/mobile/utils/HttpUtil.java
index 21d92af..5c995a5 100644
--- a/app/src/main/java/org/apache/taverna/mobile/utils/HttpUtil.java
+++ b/app/src/main/java/org/apache/taverna/mobile/utils/HttpUtil.java
@@ -12,18 +12,16 @@ import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.util.EntityUtils;
 import org.apache.taverna.mobile.tavernamobile.User;
 
-import java.io.DataInputStream;
 import java.io.IOException;
-import java.io.ObjectInputStream;
 import java.net.CookieStore;
 import java.net.HttpURLConnection;
 /**
  * Apache Taverna Mobile
  * Copyright 2015 The Apache Software Foundation
-
+ *
  * This product includes software developed at
  * The Apache Software Foundation (http://www.apache.org/).
-
+ *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
@@ -41,31 +39,35 @@ import java.net.HttpURLConnection;
  * specific language governing permissions and limitations
  * under the License.
  */
+
 /**
  * Created by Larry Akah on 6/18/15.
  */
 public class HttpUtil {
 
-    public <T> Object doPostAuthenticate(){
-        User muser = new User("",null);
+    public <T> Object doPostAuthenticate() {
+        User muser = new User("", null);
 
         return muser;
     }
 
-    public <T> Object doGetRequestResponse(String uri, Class<T> classType, 
String username, String password){
+    public <T> Object doGetRequestResponse(String uri, Class<T> classType, 
String username,
+                                           String password) {
         Object dataObject = null;
 
         HttpClient httpClient = new DefaultHttpClient();
         HttpGet httpGet = new HttpGet(uri);
         HttpResponse httpResponse = null;
         try {
-            ((AbstractHttpClient) 
httpClient).setCookieStore((org.apache.http.client.CookieStore) 
CookieStore.class.newInstance());
-            httpGet.addHeader(BasicScheme.authenticate(new 
UsernamePasswordCredentials(username,password), "UTF-8", false));
+            ((AbstractHttpClient) 
httpClient).setCookieStore((org.apache.http.client.CookieStore)
+                    CookieStore.class.newInstance());
+            httpGet.addHeader(BasicScheme.authenticate(new 
UsernamePasswordCredentials(username,
+                    password), "UTF-8", false));
             httpResponse = httpClient.execute(httpGet);
 
-            if(isSuccess(httpResponse, HttpURLConnection.HTTP_OK)){
+            if (isSuccess(httpResponse, HttpURLConnection.HTTP_OK)) {
                 HttpEntity entity = httpResponse.getEntity();
-                if(entity != null){
+                if (entity != null) {
                     String responseString = EntityUtils.toString(entity);
                     dataObject = this.deSerialize(classType, responseString);
                 }
@@ -91,7 +93,7 @@ public class HttpUtil {
     //de-serializes xml data to target class
     private <T> Object deSerialize(Class<T> classType, String responseString) {
         //TODO deserialize data and return the appropriate object
-       // ObjectInputStream ori = new ObjectInputStream(new 
DataInputStream(responseString)) ;
+        // ObjectInputStream ori = new ObjectInputStream(new 
DataInputStream(responseString)) ;
 
         return null;
     }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/e752e97d/app/src/main/java/org/apache/taverna/mobile/utils/RunTask.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/taverna/mobile/utils/RunTask.java 
b/app/src/main/java/org/apache/taverna/mobile/utils/RunTask.java
index d0710a5..e73bda0 100644
--- a/app/src/main/java/org/apache/taverna/mobile/utils/RunTask.java
+++ b/app/src/main/java/org/apache/taverna/mobile/utils/RunTask.java
@@ -1,5 +1,8 @@
 package org.apache.taverna.mobile.utils;
 
+import org.apache.taverna.mobile.activities.RunResult;
+import org.apache.taverna.mobile.tavernamobile.TavernaPlayerAPI;
+
 import android.app.ProgressDialog;
 import android.content.Context;
 import android.content.Intent;
@@ -7,9 +10,6 @@ import android.os.AsyncTask;
 import android.util.Base64;
 import android.util.Log;
 
-import org.apache.taverna.mobile.activities.RunResult;
-import org.apache.taverna.mobile.tavernamobile.TavernaPlayerAPI;
-
 import java.io.BufferedReader;
 import java.io.DataOutputStream;
 import java.io.IOException;
@@ -34,8 +34,8 @@ public class RunTask extends AsyncTask<String, Void, String> {
     @Override
     protected void onPreExecute() {
         super.onPreExecute();
-            progressDialog.setMessage("Creating new run for the workflow");
-            progressDialog.show();
+        progressDialog.setMessage("Creating new run for the workflow");
+        progressDialog.show();
     }
 
     @Override
@@ -45,8 +45,10 @@ public class RunTask extends AsyncTask<String, Void, String> 
{
             TavernaPlayerAPI tavernaPlayerAPI = new TavernaPlayerAPI();
             URL workflowurl = new URL(new 
TavernaPlayerAPI(this.context).PLAYER_RUN_URL);
             HttpURLConnection connection = (HttpURLConnection) 
workflowurl.openConnection();
-            String userpass = tavernaPlayerAPI.getPlayerUserName(this.context) 
+ ":" + tavernaPlayerAPI.getPlayerUserPassword(this.context);
-            String basicAuth = "Basic " + 
Base64.encodeToString(userpass.getBytes(), Base64.DEFAULT);
+            String userpass = tavernaPlayerAPI.getPlayerUserName(this.context) 
+ ":" +
+                    tavernaPlayerAPI.getPlayerUserPassword(this.context);
+            String basicAuth = "Basic " + 
Base64.encodeToString(userpass.getBytes(), Base64
+                    .DEFAULT);
 
             connection.setRequestProperty("Authorization", basicAuth);
             connection.setRequestProperty("Accept", "application/json");
@@ -57,7 +59,8 @@ public class RunTask extends AsyncTask<String, Void, String> {
             connection.connect(); //send request
 
             DataOutputStream dos = new 
DataOutputStream(connection.getOutputStream());
-            dos.writeBytes(params[0]);//write post data which is a formatted 
json data representing inputs to a run
+            dos.writeBytes(params[0]); //write post data which is a formatted 
json data
+            // representing inputs to a run
 
             dos.flush();
             dos.close();
@@ -75,7 +78,7 @@ public class RunTask extends AsyncTask<String, Void, String> {
 
             return sb.toString();
 
-        }catch (IOException ex){
+        } catch (IOException ex) {
             ex.printStackTrace();
         }
         return sb.toString();
@@ -84,7 +87,7 @@ public class RunTask extends AsyncTask<String, Void, String> {
     @Override
     protected void onPostExecute(String s) {
         Log.i("RUN OutPut", s);
-            progressDialog.dismiss();
+        progressDialog.dismiss();
         Intent runIntent = new Intent();
         runIntent.setClass(this.context, RunResult.class);
         runIntent.putExtra("runresult", s);

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/e752e97d/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowDB.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowDB.java 
b/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowDB.java
new file mode 100644
index 0000000..d9db76c
--- /dev/null
+++ b/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowDB.java
@@ -0,0 +1,329 @@
+package org.apache.taverna.mobile.utils;
+/**
+ * Apache Taverna Mobile
+ * Copyright 2015 The Apache Software Foundation
+ *
+ * This product includes software developed at
+ * The Apache Software Foundation (http://www.apache.org/).
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * @author Larry Akah
+ * @version 1.0.0
+ *          This class is developed as a means to simplify the code base of 
the initial json_db
+ *          implementation.
+ *          It aims at using fully the java JSON API available to implement 
the CRUD functionality
+ *          of the json_db library.
+ *          This class is much more scalable and light-weight than the first 
implementation
+ */
+public class WorkflowDB {
+
+    private final String LIBTAG = getClass().getName();
+    private String ENTITY_KEY;
+    private Context context;
+    private SharedPreferences msharedpreference;
+    private ArrayList<String> ITEM_IDS;
+    private JSONObject DBJSON;
+    private JSONObject dataobj; //hold all entries for a given ENTITY_KEY
+
+    /**
+     * Constructor initializes a basic data store environment
+     *
+     * @param ctx       a reference to the application's context or sand box
+     * @param entityKey The main data store key for each entity space/schema
+     */
+    public WorkflowDB(Context ctx, String entityKey) {
+        context = ctx;
+        ENTITY_KEY = entityKey;
+        DBJSON = new JSONObject();
+        ITEM_IDS = new ArrayList<String>();
+        dataobj = DBJSON;
+    }
+
+    /**
+     * Inserts an entity set('row') into the data store
+     *
+     * @param items values for each 'column' in the entity
+     * @return the same instance for chaining multiple calls to this method.
+     */
+    public WorkflowDB put(ArrayList<Object> items) throws JSONException {
+
+        String item_id = this.generateRandomId();
+        ITEM_IDS.add(item_id);
+        JSONArray jarray = new JSONArray();
+        for (Object item : items) {
+            jarray.put(item);
+        }
+        dataobj.put(item_id, jarray);
+        return this;
+    }
+
+    /**
+     * Returns all entity entries from the data store. Each item of an entity 
is accompanied with
+     * the key or unique id of the items.
+     *
+     * @throws org.json.JSONException for errors during construction of a JSON 
data string.
+     * @throws NullPointerException   for any null accessed variable
+     * @author Larry Akah
+     */
+    public List<ArrayList<Object>> get() throws JSONException, 
NullPointerException {
+        msharedpreference = 
PreferenceManager.getDefaultSharedPreferences(context);
+        //read key and get existing data
+        List<ArrayList<Object>> results = new ArrayList<ArrayList<Object>>();
+        JSONObject mainJson = new 
JSONObject(msharedpreference.getString(ENTITY_KEY, "{" +
+                ENTITY_KEY + ":{}}"));
+
+        Log.i(ENTITY_KEY, mainJson.toString(2));
+
+        JSONArray keysJson = mainJson.getJSONArray("ids"); //retrieve a json 
array of ids for
+        // every entity entry
+        Log.i(ENTITY_KEY, keysJson.toString(2));
+
+        if (null != keysJson)
+            for (int i = 0; i < keysJson.length(); i++) {
+                //for each key, get the associated data
+                try {
+                    JSONArray resultArray = 
mainJson.getJSONArray(keysJson.getString(i));
+                    ArrayList<Object> mlist = new ArrayList<Object>();
+                    if (null != resultArray)
+                        for (int j = 0; j < resultArray.length(); j++) {
+                            mlist.add(resultArray.getString(j));
+
+                        }
+                    mlist.add(keysJson.getString(i)); // adds the entry key as 
last value of the
+                    // data returned
+                    results.add(mlist);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    continue;
+                }
+            }
+        return results;
+    }
+
+    /**
+     * updates a single item entry of an entity
+     *
+     * @param itemId  provides the id of the item to be updated
+     * @param newItem the new set of data to be used to update the entry
+     * @return boolean indicating whether the item was successfully updated or 
not. True means item
+     * was updated, false means otherwise.
+     */
+    public boolean update(String itemId, ArrayList<Object> newItem) {
+        boolean operationSucceeded = false;
+
+        JSONArray jarray = new JSONArray();
+        for (Object item : newItem) {
+            jarray.put(item);
+        }
+        try {
+            dataobj.put(itemId, jarray); //replace the current entry at the 
given ID.
+            Log.d(LIBTAG, "" + dataobj.toString(2));
+            operationSucceeded = true;
+        } catch (JSONException e) {
+            e.printStackTrace();
+            operationSucceeded = false;
+        } finally {
+            return operationSucceeded;
+        }
+    }
+
+    /**
+     * Updates all the items of a given entity
+     *
+     * @return the number of items successfully updated.
+     */
+    public int updateAll(List<ArrayList<String>> items) {
+        return 0;
+    }
+
+    /**
+     * Gets an entry of an entity from the data store
+     *
+     * @param id The id of the item('row') in question to return
+     * @throws org.json.JSONException for errors during construction of a JSON 
data string.
+     * @throws NullPointerException   for any null accessed variable
+     * @author Larry Akah
+     */
+    public ArrayList<Object> get(String id) throws JSONException, 
NullPointerException {
+        msharedpreference = 
PreferenceManager.getDefaultSharedPreferences(context);
+        //read key and get existing data
+        ArrayList<Object> results = new ArrayList<Object>();
+        JSONObject mainJson = new 
JSONObject(msharedpreference.getString(ENTITY_KEY, ENTITY_KEY +
+                ":{}"));
+
+        Log.i(ENTITY_KEY, mainJson.toString(2));
+
+        JSONArray keysJson = mainJson.getJSONArray("ids"); //retrieve a json 
array of ids for
+        // every entity entry
+        Log.i(ENTITY_KEY, keysJson.toString(2));
+
+        if (null != keysJson)
+            for (int i = 0; i < keysJson.length(); i++) {
+                //for each key, get the associated data
+                try {
+                    JSONArray resultArray = 
mainJson.getJSONArray(keysJson.getString(i));
+                    if (null != resultArray)
+                        for (int j = 0; j < resultArray.length(); j++) {
+                            results.add(resultArray.getString(j));
+                        }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    continue;
+                }
+            }
+        return results;
+    }
+
+    /**
+     * Persists all data by making the data permanent in the preference file 
on the fileSystem
+     * Save all id's in a different preference
+     *
+     * @return true or false indicating whether the save was successful or not
+     * @author Larry Akah
+     */
+    public boolean save() {
+        msharedpreference = 
PreferenceManager.getDefaultSharedPreferences(context);
+        boolean saved = false;
+        if (dataobj != null)
+            try {
+                saved = saveid(ITEM_IDS);
+                if (saved)
+                    msharedpreference.edit().putString(ENTITY_KEY, 
dataobj.toString()).apply();
+                return saved;
+            } catch (JSONException e) {
+                e.printStackTrace();
+                return false;
+            }
+        else
+            return false;
+    }
+
+    /**
+     * @return the number of entities inserted
+     */
+    public int insert(ArrayList<Object> item) {
+        long start = System.currentTimeMillis();
+        msharedpreference = 
PreferenceManager.getDefaultSharedPreferences(context);
+        try {
+            JSONObject jsonObject = new 
JSONObject(msharedpreference.getString(ENTITY_KEY, "{" +
+                    ENTITY_KEY + ":{}}")); //main json db
+            System.out.println(jsonObject.toString(1));
+
+            JSONArray jsonArray;
+            if (jsonObject.has("ids"))
+                jsonArray = jsonObject.optJSONArray("ids");
+            else
+                jsonArray = new JSONArray();
+
+            String newItemId = item.get(0).toString(); //use the workflow id 
as an entity key for
+            // the new entity
+
+            //verify if this workflow item has already been marked as favorite
+            for (int k = 0; k < jsonArray.length(); k++) {
+                if (jsonArray.get(k).toString().equalsIgnoreCase(newItemId))
+                    return -1;
+            }
+
+            jsonArray.put(jsonArray.length(), newItemId); //add new entity id
+            JSONArray newEntity = new JSONArray();
+            for (Object entity : item) {
+                newEntity.put(entity);
+            }
+            jsonObject.put("ids", jsonArray);
+            jsonObject.put(newItemId, newEntity);
+            msharedpreference.edit().putString(ENTITY_KEY, 
jsonObject.toString()).commit();
+            long end = System.currentTimeMillis();
+            System.out.println("Insert benchmark length = " + (end - start));
+            return 1;
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+        return 0;
+    }
+
+    /**
+     * save the ids of all entity entries
+     *
+     * @param ids A list of auto-generated ids that point to each set of 
entity data in the data
+     *            store
+     * @author Larry Akah
+     */
+    private boolean saveid(ArrayList<String> ids) throws JSONException {
+        JSONArray jarray = new JSONArray();
+        for (Object item : ids) {
+            jarray.put(item);
+        }
+        dataobj.put("ids", jarray);
+
+        return jarray.length() == ids.size() ? true : false;
+    }
+
+    /**
+     * Removes an item from an entity entry
+     *
+     * @author Larry Akah
+     */
+    public WorkflowDB delete(String itemID) throws JSONException {
+        SharedPreferences sp = 
PreferenceManager.getDefaultSharedPreferences(context);
+        JSONObject dbjson = new JSONObject(sp.getString(ENTITY_KEY, ENTITY_KEY 
+ ":{}"));
+
+        JSONArray currentkeys = dbjson.getJSONArray("ids");
+        JSONArray newKeys = DBUtility.removeKey(currentkeys, itemID);
+
+        dbjson.put("ids", newKeys);
+        sp.edit().putString(ENTITY_KEY, dbjson.toString()).apply();
+
+        return this;
+    }
+
+    /**
+     * Removes all items from an entity
+     *
+     * @author Larry Akah
+     */
+    public int bulkDelete(String entity_key) {
+
+        return 0;
+    }
+
+    /**
+     * Generates a random hexadecimal string to be used as ids for identifying 
each entry of an
+     * entity item. Proven to be collision resistant enough accross API KEYS
+     *
+     * @author Larry Akah
+     */
+    private String generateRandomId() {
+        return UUID.randomUUID().toString();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/e752e97d/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowDownloadManager.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowDownloadManager.java
 
b/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowDownloadManager.java
index 3c645ce..b4b5c53 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowDownloadManager.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowDownloadManager.java
@@ -2,10 +2,10 @@ package org.apache.taverna.mobile.utils;
 /**
  * Apache Taverna Mobile
  * Copyright 2015 The Apache Software Foundation
-
+ *
  * This product includes software developed at
  * The Apache Software Foundation (http://www.apache.org/).
-
+ *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
@@ -23,6 +23,9 @@ package org.apache.taverna.mobile.utils;
  * specific language governing permissions and limitations
  * under the License.
  */
+
+import org.apache.taverna.mobile.R;
+
 import android.app.DownloadManager;
 import android.app.Notification;
 import android.app.NotificationManager;
@@ -32,8 +35,6 @@ import android.media.RingtoneManager;
 import android.net.Uri;
 import android.support.v4.app.NotificationCompat;
 
-import org.apache.taverna.mobile.R;
-
 import java.io.File;
 
 /**
@@ -58,44 +59,50 @@ public class WorkflowDownloadManager {
 
     /**
      * Download the given workflow
+     *
      * @param destination The destination file in which to save the downloaded 
file
      */
-    public void downloadWorkflow(File destination, String sourceurl) throws 
Exception{
+    public void downloadWorkflow(File destination, String sourceurl) throws 
Exception {
 
         DownloadManager.Query query = new DownloadManager.Query();
-        query.setFilterByStatus(DownloadManager.STATUS_PAUSED|
-                DownloadManager.STATUS_PENDING|
-                DownloadManager.STATUS_RUNNING|DownloadManager.STATUS_FAILED|
+        query.setFilterByStatus(DownloadManager.STATUS_PAUSED |
+                DownloadManager.STATUS_PENDING |
+                DownloadManager.STATUS_RUNNING | DownloadManager.STATUS_FAILED 
|
                 DownloadManager.STATUS_SUCCESSFUL);
         Cursor cur = this.downloadManager.query(query);
         int col = cur.getColumnIndex(DownloadManager.COLUMN_LOCAL_FILENAME);
 
-        for(cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()) {
-            this.isDownloading = this.isDownloading || (destination.getName() 
== cur.getString(col));
+        for (cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()) {
+            this.isDownloading = this.isDownloading || (destination.getName() 
== cur.getString
+                    (col));
         }
-       // cur.close();
+        // cur.close();
         if (!this.isDownloading) {
             Uri source = Uri.parse(sourceurl);
-            //extract the file name from the source url and append it to the 
workflow storage directory to be used to download the file into.
-            Uri destinationurl = 
Uri.withAppendedPath(Uri.fromFile(destination), 
Uri.parse(sourceurl).getLastPathSegment());
+            //extract the file name from the source url and append it to the 
workflow storage
+            // directory to be used to download the file into.
+            Uri destinationurl = 
Uri.withAppendedPath(Uri.fromFile(destination), Uri.parse
+                    (sourceurl).getLastPathSegment());
 
             DownloadManager.Request request = new 
DownloadManager.Request(source);
             request.setTitle("Workflow");
             request.setDescription("Downloading workflow");
             request.setDestinationUri(destinationurl);
-            
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED
 |
+            request.setNotificationVisibility(DownloadManager.Request
+                    .VISIBILITY_VISIBLE_NOTIFY_COMPLETED |
                     DownloadManager.Request.VISIBILITY_VISIBLE);
 
             long id = this.downloadManager.enqueue(request);
 
-            if(id != 0)
+            if (id != 0)
                 
sendNotification(this.context.getResources().getString(R.string.downloadprogress));
             cur.close();
         }
     }
 
-    public void sendNotification(String message){
-        NotificationCompat.Builder notificationBuilder = new 
NotificationCompat.Builder(this.context);
+    public void sendNotification(String message) {
+        NotificationCompat.Builder notificationBuilder = new 
NotificationCompat.Builder(this
+                .context);
         notificationBuilder.setContentText(message)
                 .setContentTitle("Workflow Download")
                 .setSmallIcon(R.mipmap.ic_launcher)
@@ -103,8 +110,9 @@ public class WorkflowDownloadManager {
                 .setVisibility(Notification.VISIBILITY_PUBLIC)
                 .setWhen(0)
                 
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
-        Notification nf  = notificationBuilder.build();
-        NotificationManager notificationManager = (NotificationManager) 
context.getSystemService(Context.NOTIFICATION_SERVICE);
+        Notification nf = notificationBuilder.build();
+        NotificationManager notificationManager = (NotificationManager) 
context.getSystemService
+                (Context.NOTIFICATION_SERVICE);
         notificationManager.notify(1, nf);
     }
 }

Reply via email to