http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/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 deleted file mode 100644 index 5b376b2..0000000 --- a/app/src/main/java/org/apache/taverna/mobile/utils/RunTask.java +++ /dev/null @@ -1,124 +0,0 @@ -/* -* 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. -*/ - -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; -import android.os.AsyncTask; -import android.util.Base64; -import android.util.Log; - -import java.io.BufferedReader; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.URL; -import java.nio.charset.Charset; - -/** - * Created by root on 7/11/15. - */ -public class RunTask extends AsyncTask<String, Void, String> { - - private static final String TAG = "RunTask"; - private Context context; - private ProgressDialog progressDialog; - - public RunTask(Context ctx) { - this.context = ctx; - progressDialog = new ProgressDialog(this.context); - } - - @Override - protected void onPreExecute() { - super.onPreExecute(); - progressDialog.setMessage("Creating new run for the workflow"); - progressDialog.show(); - } - - @Override - protected String doInBackground(String... params) { - StringBuffer sb = new StringBuffer(); - try { - TavernaPlayerAPI tavernaPlayerAPI = new TavernaPlayerAPI(); - URL workflowurl = new URL(new TavernaPlayerAPI(this.context).mPlayerRunUrl); - HttpURLConnection connection = (HttpURLConnection) workflowurl.openConnection(); - String userpass = tavernaPlayerAPI.getPlayerUserName(this.context) + ":" + - tavernaPlayerAPI.getPlayerUserPassword(this.context); - String basicAuth = "Basic " + Base64.encodeToString(userpass.getBytes(Charset.forName - ("UTF-8")), Base64 - .DEFAULT); - - connection.setRequestProperty("Authorization", basicAuth); - connection.setRequestProperty("Accept", "application/json"); - connection.setRequestProperty("Content-Type", "application/json"); - connection.setRequestMethod("POST"); - // connection.setDoInput(true); - // connection.setDoOutput(true); - 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.flush(); - dos.close(); - - InputStream dis = connection.getInputStream(); - BufferedReader br = new BufferedReader(new InputStreamReader(dis, "UTF-8")); - - String jsonData = ""; - while ((jsonData = br.readLine()) != null) { - sb.append(jsonData); - // - } - dis.close(); - br.close(); - - return sb.toString(); - - } catch (IOException ex) { - Log.e(TAG, "doInBackground: ", ex); - } - return sb.toString(); - } - - @Override - protected void onPostExecute(String s) { - Log.i("RUN OutPut", s); - progressDialog.dismiss(); - Intent runIntent = new Intent(); - runIntent.setClass(this.context, RunResult.class); - runIntent.putExtra("runresult", s); - this.context.startActivity(runIntent); - } -}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/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 deleted file mode 100644 index f953ee9..0000000 --- a/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowDB.java +++ /dev/null @@ -1,328 +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 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 static final String TAG = "WorkflowDB"; - private final String ENTITY_KEY; - private final ArrayList<String> ITEM_IDS; - private Context context; - private SharedPreferences msharedpreference; - 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; - ITEM_IDS = new ArrayList<String>(); - dataobj = new JSONObject(); - } - - /** - * 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) { - Log.e(TAG, "get: ", e); - 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(TAG, "" + dataobj.toString(2)); - operationSucceeded = true; - } catch (JSONException e) { - Log.e(TAG, "update: ", e); - operationSucceeded = false; - } - 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) { - Log.e(TAG, "get: ", e); - 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) { - Log.e(TAG, "save: ", e); - 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 - Log.d(TAG, 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(); - Log.d(TAG, "Insert benchmark length = " + (end - start)); - return 1; - } catch (JSONException e) { - Log.e(TAG, "insert: ", e); - } - 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/b93d871c/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowDataCallback.java ---------------------------------------------------------------------- diff --git a/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowDataCallback.java b/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowDataCallback.java deleted file mode 100644 index 6b6a41d..0000000 --- a/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowDataCallback.java +++ /dev/null @@ -1,39 +0,0 @@ -/* -* 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. -*/ - -package org.apache.taverna.mobile.utils; - -import org.apache.taverna.mobile.tavernamobile.Workflow; - -import java.util.List; - -/** - * Callback for when data is ready to be put into the workflow adapter - * Created by root on 6/24/15. - */ -public interface WorkflowDataCallback { - - public void onWorkflowDataReady(List<Workflow> data); -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/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 deleted file mode 100644 index b4b5c53..0000000 --- a/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowDownloadManager.java +++ /dev/null @@ -1,118 +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.apache.taverna.mobile.R; - -import android.app.DownloadManager; -import android.app.Notification; -import android.app.NotificationManager; -import android.content.Context; -import android.database.Cursor; -import android.media.RingtoneManager; -import android.net.Uri; -import android.support.v4.app.NotificationCompat; - -import java.io.File; - -/** - * Created by root on 6/11/15. - */ -public class WorkflowDownloadManager { - private DownloadManager downloadManager; - private Context context; - private boolean isDownloading; - - public WorkflowDownloadManager(Context ctx, DownloadManager downloadManager) { - this.context = ctx; - this.downloadManager = downloadManager; - this.isDownloading = false; - } - - public WorkflowDownloadManager(Context context) { - this.context = context; - this.downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); - this.isDownloading = false; - } - - /** - * 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 { - - DownloadManager.Query query = new DownloadManager.Query(); - 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)); - } - // 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()); - - 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 | - DownloadManager.Request.VISIBILITY_VISIBLE); - - long id = this.downloadManager.enqueue(request); - - 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); - notificationBuilder.setContentText(message) - .setContentTitle("Workflow Download") - .setSmallIcon(R.mipmap.ic_launcher) - .setAutoCancel(true) - .setVisibility(Notification.VISIBILITY_PUBLIC) - .setWhen(0) - .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); - Notification nf = notificationBuilder.build(); - NotificationManager notificationManager = (NotificationManager) context.getSystemService - (Context.NOTIFICATION_SERVICE); - notificationManager.notify(1, nf); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowLoader.java ---------------------------------------------------------------------- diff --git a/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowLoader.java b/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowLoader.java deleted file mode 100644 index 64fee15..0000000 --- a/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowLoader.java +++ /dev/null @@ -1,106 +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 com.thebuzzmedia.sjxp.rule.IRule; - -import org.apache.taverna.mobile.tavernamobile.Workflow; -import org.apache.taverna.mobile.utils.xmlparsers.MyExperimentXmlParserRules; -import org.apache.taverna.mobile.utils.xmlparsers.WorkflowParser; - -import android.content.Context; -import android.os.AsyncTask; -import android.support.v4.widget.SwipeRefreshLayout; -import android.util.Log; - -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.ProtocolException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - -/** - * Created by Larry Akah on 6/13/15. - */ -public class WorkflowLoader extends AsyncTask<String, Object, Object> { //WorkflowLoaderMain { - - private static final String TAG = "WorkflowLoader"; - private Context ctx; - private List<Workflow> userWorkflows; - private SwipeRefreshLayout refreshLayout; - - public WorkflowLoader(Context context, SwipeRefreshLayout sw) { - this.ctx = context; - this.refreshLayout = sw; - this.userWorkflows = new ArrayList<Workflow>(); - } - - @Override - protected void onPreExecute() { - super.onPreExecute(); - refreshLayout.setRefreshing(true); - } - - @Override - public List<Workflow> doInBackground(String[] pages) { - //start a network request to fetch user's workflows - - IRule wkflowRule = new MyExperimentXmlParserRules.WorkflowRule(IRule.Type.ATTRIBUTE, - "/workflows/workflow", "resource", "uri", "id", "version"); - IRule workflowNameRule = new MyExperimentXmlParserRules.WorkflowRule(IRule.Type - .CHARACTER, "/workflows/workflow"); - WorkflowParser xmlParser = new WorkflowParser(new IRule[]{wkflowRule, workflowNameRule}); - try { - URL workflowurl = new URL("http://www.myexperiment.org/workflows.xml?page=" + Integer - .parseInt((pages[0]))); - HttpURLConnection connection = (HttpURLConnection) workflowurl.openConnection(); - connection.setRequestMethod("GET"); - connection.connect(); //send request - Log.i("WorkflowLoader", "Loading workflows page = " + pages[0]); - - InputStream dis = connection.getInputStream(); - xmlParser.parse(dis, this.userWorkflows); - - } catch (MalformedURLException e) { - Log.e(TAG, "doInBackground: ", e); - } catch (ProtocolException e) { - Log.e(TAG, "doInBackground: ", e); - } catch (IOException e) { - Log.e(TAG, "doInBackground: ", e); - } catch (Exception ex) { - Log.e(TAG, "doInBackground: ", ex); - } - return this.userWorkflows; - } - - @Override - protected void onPostExecute(Object o) { - refreshLayout.setRefreshing(false); - Log.i(TAG, "Workflow Count: " + this.userWorkflows.size()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowLoaderMain.java ---------------------------------------------------------------------- diff --git a/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowLoaderMain.java b/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowLoaderMain.java deleted file mode 100644 index bb56ec9..0000000 --- a/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowLoaderMain.java +++ /dev/null @@ -1,45 +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.apache.taverna.mobile.tavernamobile.Workflow; - -import android.content.AsyncTaskLoader; -import android.content.Context; - -import java.util.List; - -/** - * Created by root on 6/23/15. - */ -public abstract class WorkflowLoaderMain extends AsyncTaskLoader<List<Workflow>> { - - public WorkflowLoaderMain(Context context) { - super(context); - } - - public abstract List<Workflow> loadInBackground(); - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowOpen.java ---------------------------------------------------------------------- diff --git a/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowOpen.java b/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowOpen.java deleted file mode 100644 index bde240d..0000000 --- a/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowOpen.java +++ /dev/null @@ -1,339 +0,0 @@ -/* -* 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. -*/ - -package org.apache.taverna.mobile.utils; - -/** - * Created by Larry Akah on 7/11/15. - */ - -import org.apache.taverna.mobile.R; -import org.apache.taverna.mobile.tavernamobile.TavernaPlayerAPI; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import android.app.AlertDialog; -import android.app.ProgressDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.os.AsyncTask; -import android.util.Base64; -import android.util.Log; -import android.widget.EditText; -import android.widget.LinearLayout; -import android.widget.ScrollView; -import android.widget.TextView; - -import java.io.BufferedReader; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.URL; -import java.nio.charset.Charset; - -/** - * Read the selected xml file from storage and upload to player to generate workflowRun - */ -public class WorkflowOpen extends AsyncTask<String, Void, String> { - - private static final String TAG = "WorkflowOpen"; - TavernaPlayerAPI tavernaPlayerAPI = new TavernaPlayerAPI(); - private Context context; - private ProgressDialog progressDialog; - - public WorkflowOpen(Context context) { - this.context = context; - progressDialog = new ProgressDialog(this.context); - } - - @Override - protected void onPreExecute() { - - progressDialog.setMessage("Uploading Workflow ... "); - progressDialog.show(); - } - - /** - * @param params path to workflow file to upload to player - * @return run framework used to create a new workflow run - */ - @Override - protected String doInBackground(String... params) { - StringBuffer sb = new StringBuffer(55); - String str = ""; - try { - - //prepare connection requests - File objectFile = new File(params[0]); //the resource xml file representing the - // workflow to be uploaded to the player - String playerurl = new TavernaPlayerAPI(this.context).getplayerBaseUrl() + "workflows" + - ".json"; - URL posturl = new URL(playerurl); - HttpURLConnection connection = (HttpURLConnection) posturl.openConnection(); - - String user = tavernaPlayerAPI.getPlayerUserName(this.context) + ":" + - tavernaPlayerAPI.getPlayerUserPassword(this.context); - String basicAuth = "Basic " + Base64.encodeToString(user.getBytes(Charset.forName - ("UTF-8")), Base64.DEFAULT); - //read the file from remote resource and encode the stream with a base64 algorithm - - try { - BufferedReader br = new BufferedReader(new FileReader(objectFile)); - - while ((str = br.readLine()) != null) { - sb.append(str); - sb.append('\n'); - } - br.close(); - } catch (IOException e) { - Log.e(TAG, "doInBackground: ", e); - } - - String data = "{\"document\":\"data:application/octet-stream;base64," + - Base64.encodeToString(sb.toString().getBytes(Charset.forName("UTF-8")), - Base64.URL_SAFE | - Base64.NO_WRAP).replace('-', '+') + "\"}"; - String post = "{\"workflow\":" + data + "}"; - //clear sb so that we can use it again to fetch results from this post request - sb.delete(0, sb.length() - 1); - Log.i(TAG, "BODY=>" + post); - connection.setRequestMethod("POST"); - connection.setRequestProperty("Authorization", basicAuth); - connection.setRequestProperty("Accept", "*/*"); - connection.setRequestProperty("Content-Type", "application/json"); - connection.setRequestProperty("Content-Encoding", "UTF-8"); - connection.setUseCaches(false); - connection.setDoOutput(true); - connection.connect(); //send request - - DataOutputStream dos = new DataOutputStream(connection.getOutputStream()); - - dos.writeBytes(post); //write post data which is a formatted json data representing - // body of workflow - - dos.flush(); - dos.close(); - - InputStream dis = connection.getInputStream(); - BufferedReader br = new BufferedReader(new InputStreamReader(dis, "UTF-8")); - while ((str = br.readLine()) != null) { - sb.append(str); - } - Log.i(TAG, "Post Response Code: " + connection.getResponseCode()); - Log.i(TAG, "Post response message: " + connection.getResponseMessage()); - connection.disconnect(); - } catch (IOException e) { - Log.e(TAG, "doInBackground: ", e); - sb.append("Error reading remote workflow. Please try again later"); - } - - return sb.toString(); - } - - /** - * Receives a result from the player as a json describing the workflow that has just been - * uploaded along with key components that - * can be used to generate a run from thw workflow. A run is started that would fetch and build - * a sample UI for a workflow run to be executed - * - * @param s the json result that describes the uploaded workflow - */ - @Override - protected void onPostExecute(String s) { - progressDialog.dismiss(); - Log.i(TAG, s); - s = s.substring(1, s.length()); - try { - JSONObject workflowJson = new JSONObject(s); - new WorkflowRunTask(this.context).execute(workflowJson.getString("id")); - - } catch (JSONException e) { - Log.e(TAG, "onPostExecute: ", e); - } - - } - - //create and return a new TextView - public TextView createTextView(Context mcontext, String placeholder) { - TextView tv = new TextView(mcontext); - tv.setText(placeholder); - tv.setMinLines(2); - - return tv; - } - - //create and return a new EdiText view - public EditText createEditText(Context ctx, int i) { - EditText edt; - edt = new EditText(ctx); - edt.setHint("Enter Value"); - edt.setMinLines(1); - edt.setId(i); - return edt; - } - - private class WorkflowRunTask extends AsyncTask<String, Void, String> { - - private Context context; - private AlertDialog.Builder alertDialogBuilder; - private AlertDialog runDialog; - - private WorkflowRunTask(Context context) { - this.context = context; - } - - @Override - protected void onPreExecute() { - super.onPreExecute(); - progressDialog.setMessage(this.context.getResources().getString(R.string.fetchrun)); - progressDialog.show(); - } - - @Override - protected String doInBackground(String... params) { - StringBuffer sb = new StringBuffer(); - try { - - URL workflowurl = new URL(new TavernaPlayerAPI(this.context) - .mPlayerRunFrameworkUrl + params[0]); - HttpURLConnection connection = (HttpURLConnection) workflowurl.openConnection(); - String userpass = tavernaPlayerAPI.getPlayerUserName(this.context) + ":" + - tavernaPlayerAPI.getPlayerUserPassword(this.context); - String basicAuth = "Basic " + Base64.encodeToString(userpass.getBytes(Charset - .forName("UTF-8")), Base64 - .DEFAULT); - - 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 Message", "" + connection.getResponseMessage()); - Log.i("Authorization ", "" + connection.getRequestProperty("Authorization")); - - InputStream dis = connection.getInputStream(); - BufferedReader br = new BufferedReader(new InputStreamReader(dis, "UTF-8")); - - String jsonData = ""; - while ((jsonData = br.readLine()) != null) { - sb.append(jsonData); - } - dis.close(); - br.close(); - return sb.toString(); - - } catch (IOException ex) { - Log.e(TAG, "doInBackground: ", ex); - } - return sb.toString(); - } - - @Override - protected void onPostExecute(String result) { - //show the skeleton to the user in a dialog box - final Context ctx = this.context; - final LinearLayout ll = new LinearLayout(ctx); - ScrollView sv = new ScrollView(ctx); - ll.setOrientation(LinearLayout.VERTICAL); - sv.addView(ll); - - try { - final JSONObject json = new JSONObject(result); //main server response json - JSONObject mjson = json.getJSONObject("run"); //main framework response json - String name = mjson.getString("name"); //a name that can be configured or edited - // for the new run to be created - ll.addView(createTextView(ctx, name)); - final JSONArray attr_array = mjson.getJSONArray("inputs_attributes"); - for (int i = 0; i < attr_array.length(); i++) { - JSONObject obj = attr_array.getJSONObject(i); - ll.addView(createTextView(ctx, obj.getString("name"))); - ll.addView(createEditText(ctx, i)); - } - - alertDialogBuilder = new AlertDialog.Builder(ctx); - alertDialogBuilder.setView(sv); - // alertDialogBuilder.setMessage(result); - alertDialogBuilder.setIcon(ctx.getResources().getDrawable(R.mipmap.ic_launcher)); - alertDialogBuilder.setTitle("New Workflow Run"); - alertDialogBuilder.setPositiveButton("Execute", new DialogInterface - .OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - int n = attr_array.length(); - for (int j = 0; j < n; j++) { - try { - EditText inputText = (EditText) ll.findViewById(j); - String value = inputText.getText().toString(); //get input entry - // entered by the user - JSONObject jojb = attr_array.getJSONObject(j); //get the input - // attributes provided by the skeleton - jojb.put("value", value); //replace value field in object with - // the entry provided by the user - attr_array.put(j, jojb); //replace the input entry with the new - // name/input json object - - } catch (JSONException e) { - Log.e(TAG, "onClick: ", e); - } - - } - try { - json.put("inputs_attributes", attr_array); - Log.i("RUN FRAMEWORK", json.toString(2)); - //start a run task to execute the run. - new RunTask(ctx).execute(json.toString()); - } catch (JSONException e) { - Log.e(TAG, "onClick: ", e); - } - - } - }); - alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface - .OnClickListener() { - - @Override - public void onClick(DialogInterface dialogInterface, int i) { - dialogInterface.dismiss(); - } - }); - - runDialog = alertDialogBuilder.create(); - - } catch (JSONException e) { - Log.e(TAG, "onPostExecute: ", e); - } - progressDialog.dismiss(); - runDialog.show(); - } - } -} - - - http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/src/main/java/org/apache/taverna/mobile/utils/xmlparsers/AvatarXMLParser.java ---------------------------------------------------------------------- diff --git a/app/src/main/java/org/apache/taverna/mobile/utils/xmlparsers/AvatarXMLParser.java b/app/src/main/java/org/apache/taverna/mobile/utils/xmlparsers/AvatarXMLParser.java deleted file mode 100644 index 047b282..0000000 --- a/app/src/main/java/org/apache/taverna/mobile/utils/xmlparsers/AvatarXMLParser.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.apache.taverna.mobile.utils.xmlparsers; -/** - * 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 com.thebuzzmedia.sjxp.XMLParser; -import com.thebuzzmedia.sjxp.XMLParserException; -import com.thebuzzmedia.sjxp.rule.IRule; - -import org.apache.taverna.mobile.fragments.WorkflowItemFragment; -import org.apache.taverna.mobile.tavernamobile.User; - -/** - * Created by Larry Akah on 6/29/15. - */ -public class AvatarXMLParser extends XMLParser { - - public AvatarXMLParser(IRule[] rules) throws IllegalArgumentException, XMLParserException { - super(rules); - } - - @Override - protected void doEndDocument(Object userObject) { - WorkflowItemFragment.updateAvatar((User) userObject); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/src/main/java/org/apache/taverna/mobile/utils/xmlparsers/MyExperimentXmlParserRules.java ---------------------------------------------------------------------- diff --git a/app/src/main/java/org/apache/taverna/mobile/utils/xmlparsers/MyExperimentXmlParserRules.java b/app/src/main/java/org/apache/taverna/mobile/utils/xmlparsers/MyExperimentXmlParserRules.java deleted file mode 100644 index 638e96c..0000000 --- a/app/src/main/java/org/apache/taverna/mobile/utils/xmlparsers/MyExperimentXmlParserRules.java +++ /dev/null @@ -1,380 +0,0 @@ -package org.apache.taverna.mobile.utils.xmlparsers; -/** - * 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 com.thebuzzmedia.sjxp.XMLParser; -import com.thebuzzmedia.sjxp.rule.DefaultRule; - -import org.apache.taverna.mobile.tavernamobile.User; -import org.apache.taverna.mobile.tavernamobile.Workflow; - -import android.text.Html; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by Larry Akah on 6/23/15. - */ -public class MyExperimentXmlParserRules { - - public static final Workflow mWorkflow = new Workflow(); - - public MyExperimentXmlParserRules() { - } - - public Workflow getWorkflowHere() { - return mWorkflow; - } - - //parse a single workflow from myexperiment - public static final class WorkflowDetailRule extends DefaultRule { - - public WorkflowDetailRule(Type type, String locationPath, String... attributeNames) - throws IllegalArgumentException { - super(type, locationPath, attributeNames); - } - - @Override - public void handleParsedAttribute(XMLParser parser, int index, String value, Object - userObject) { - switch (index) { - case 0: //uri - mWorkflow.setWorkflowDetailsUrl(value); - ((Workflow) userObject).setWorkflowDetailsUrl(value); - break; - case 1: //resource - mWorkflow.setWorkflowWebUrl(value); - ((Workflow) userObject).setWorkflowWebUrl(value); - break; - case 2: //id - mWorkflow.setId(Integer.parseInt(value)); - ((Workflow) userObject).setId(Integer.parseInt(value)); - break; - case 3://version - mWorkflow.setWorkflowVersions(value); - ((Workflow) userObject).setWorkflowVersions(value); - break; - } - } - } - - public static class TitleRule extends DefaultRule { - - public TitleRule(Type type, String locationPath, String... attributeNames) throws - IllegalArgumentException { - super(type, locationPath, attributeNames); - } - - @Override - public void handleParsedCharacters(XMLParser parser, String text, Object userObject) { - mWorkflow.setWorkflowTitle(text); - ((Workflow) userObject).setWorkflowTitle(text); - } - } - - public static class DescriptionRule extends DefaultRule { - - public DescriptionRule(Type type, String locationPath, String... attributeNames) throws - IllegalArgumentException { - super(type, locationPath, attributeNames); - } - - @Override - public void handleParsedCharacters(XMLParser parser, String text, Object userObject) { - - mWorkflow.setWorkflowDescription(String.valueOf(Html.fromHtml(text))); - ((Workflow) userObject).setWorkflowDescription(String.valueOf(Html.fromHtml(text))); - } - } - - public static class TypeRule extends DefaultRule { - - public TypeRule(Type type, String locationPath, String... attributeNames) throws - IllegalArgumentException { - super(type, locationPath, attributeNames); - } - - @Override - public void handleParsedAttribute(XMLParser parser, int index, String value, Object - userObject) { - switch (index) { - case 0: - break; - case 1: - break; - case 2: - break; - - } - } - - @Override - public void handleParsedCharacters(XMLParser parser, String text, Object userObject) { - mWorkflow.setWorkflowType(text); - ((Workflow) userObject).setWorkflowType(text); - } - } - - public static class UploaderRule extends DefaultRule { - - User muser; - - public UploaderRule(Type type, String locationPath, String... attributeNames) throws - IllegalArgumentException { - super(type, locationPath, attributeNames); - muser = new User("", null); - } - - @Override - public void handleParsedAttribute(XMLParser parser, int index, String value, Object - userObject) { - switch (index) { - case 0: - muser.setWebsite(value); - if ((userObject instanceof User)) { - ((User) userObject).setWebsite(value); - } - break; - case 1: - muser.setDetailsUri(value); - if ((userObject instanceof User)) { - ((User) userObject).setDetailsUri(value); - } - break; - case 2: - muser.setId(value); - if ((userObject instanceof User)) { - ((User) userObject).setId(value); - } - break; - } - } - - @Override - public void handleParsedCharacters(XMLParser parser, String text, Object userObject) { - muser.setName(text); - mWorkflow.setUploader(muser); - - if ((userObject instanceof User)) { - ((User) userObject).setName(text); - } else { - ((Workflow) userObject).setUploader(muser); - } - } - } - - //rule used to parse author from main page - public static class AuthorRule extends DefaultRule { - - public AuthorRule(Type type, String locationPath, String... attributeNames) throws - IllegalArgumentException { - super(type, locationPath, attributeNames); - } - - @Override - public void handleParsedAttribute(XMLParser parser, int index, String value, Object - userObject) { - switch (index) { - case 0: - ((User) userObject).setAvatarUrl(value); - break; - case 1: - ((User) userObject).setDetailsUri(value); - break; - case 2: - ((User) userObject).setId(value); - break; - } - } - - @Override - public void handleParsedCharacters(XMLParser parser, String text, Object userObject) { - ((User) userObject).setName(text); - //((Workflow)userObject).setUploader(muser); - //System.out.println("Author Name: "+text); - } - } - - //rule for the date the workflow was created/uploaded - public static class DateRule extends DefaultRule { - - public DateRule(Type type, String locationPath, String... attributeNames) throws - IllegalArgumentException { - super(type, locationPath, attributeNames); - } - - @Override - public void handleParsedCharacters(XMLParser parser, String text, Object userObject) { - mWorkflow.setWorkflowDatecreated(text); - ((Workflow) userObject).setWorkflowDatecreated(text); - - } - } - - public static class PreviewRule extends DefaultRule { - - public PreviewRule(Type type, String locationPath, String... attributeNames) throws - IllegalArgumentException { - super(type, locationPath, attributeNames); - } - - @Override - public void handleParsedCharacters(XMLParser parser, String text, Object userObject) { - mWorkflow.setWorkflowPreview(text); - ((Workflow) userObject).setWorkflowPreview(text); - } - } - - public static class LicenceTypeRule extends DefaultRule { - - public LicenceTypeRule(Type type, String locationPath, String... attributeNames) throws - IllegalArgumentException { - super(type, locationPath, attributeNames); - } - - @Override - public void handleParsedAttribute(XMLParser parser, int index, String value, Object - userObject) { - super.handleParsedAttribute(parser, index, value, userObject); - } - - @Override - public void handleParsedCharacters(XMLParser parser, String text, Object userObject) { - mWorkflow.setWorkflowLicenceType("Licence By " + text); - ((Workflow) userObject).setWorkflowLicenceType("Licence By " + text); - } - } - - //set download link for the workflow - public static class ContentUriRule extends DefaultRule { - - public ContentUriRule(Type type, String locationPath, String... attributeNames) throws - IllegalArgumentException { - super(type, locationPath, attributeNames); - } - - @Override - public void handleParsedCharacters(XMLParser parser, String text, Object userObject) { - mWorkflow.setWorkflowRemoteUrl(text); - ((Workflow) userObject).setWorkflowRemoteUrl(text); - } - } - - public static class ContentTypeRule extends DefaultRule { - - public ContentTypeRule(Type type, String locationPath, String... attributeNames) throws - IllegalArgumentException { - super(type, locationPath, attributeNames); - } - - @Override - public void handleParsedCharacters(XMLParser parser, String text, Object userObject) { - mWorkflow.setWorkflowContentType(text); - ((Workflow) userObject).setWorkflowContentType(text); - } - } - - public static class TagsRule extends DefaultRule { - - public TagsRule(Type type, String locationPath, String... attributeNames) throws - IllegalArgumentException { - super(type, locationPath, attributeNames); - } - - @Override - public void handleParsedAttribute(XMLParser parser, int index, String value, Object - userObject) { - super.handleParsedAttribute(parser, index, value, userObject); - } - - @Override - public void handleParsedCharacters(XMLParser parser, String text, Object userObject) { - mWorkflow.setWorkflowTags(new ArrayList<String>() { - }); - ((Workflow) userObject).setWorkflowTags(new ArrayList<String>() { - }); - - } - } - - /** - * parse workflows from myExperiment - */ - public static final class WorkflowRule extends DefaultRule { - static String uri, version, desc; - static String url = uri = version = desc = ""; - static long id = 0; - Workflow workflow; - List<Workflow> wlist; - - public WorkflowRule(Type type, String locationPath, String... attributeNames) throws - IllegalArgumentException { - super(type, locationPath, attributeNames); - this.workflow = new Workflow(); - wlist = new ArrayList<>(); - } - - //instantiated to parse xml data for a given workflow - public WorkflowRule(Type type, String path, int id, String attributenames) { - super(type, path, attributenames); - } - - @Override - public void handleParsedAttribute(XMLParser parser, int index, String value, Object - userObject) { - - switch (index) { - case 0: - desc = "To view workflow on the web, click " + value; - break; - case 1: - uri = value; - break; - case 2: - id = Integer.parseInt(value); - break; - case 3: - version = value; - break; - } - } - - @Override - public void handleParsedCharacters(XMLParser parser, String text, Object - workflowListObject) { - //add the workflow to the workflow list - this.workflow = new Workflow("", desc, id, url); - this.workflow.setWorkflowDetailsUrl(uri); - this.workflow.setWorkflowTitle(text); - this.workflow.setWorkflowAuthor(""); - wlist.add(this.workflow); - //WorkflowLoader.loadedWorkflows.add(this.workflow); - ((List<Workflow>) workflowListObject).add(this.workflow); - this.workflow = null; - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/src/main/java/org/apache/taverna/mobile/utils/xmlparsers/WorkflowDetailParser.java ---------------------------------------------------------------------- diff --git a/app/src/main/java/org/apache/taverna/mobile/utils/xmlparsers/WorkflowDetailParser.java b/app/src/main/java/org/apache/taverna/mobile/utils/xmlparsers/WorkflowDetailParser.java deleted file mode 100644 index 9ec0bcd..0000000 --- a/app/src/main/java/org/apache/taverna/mobile/utils/xmlparsers/WorkflowDetailParser.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.apache.taverna.mobile.utils.xmlparsers; - -import com.thebuzzmedia.sjxp.XMLParser; -import com.thebuzzmedia.sjxp.XMLParserException; -import com.thebuzzmedia.sjxp.rule.IRule; - -import org.apache.taverna.mobile.fragments.WorkflowItemFragment; -import org.apache.taverna.mobile.fragments.workflowdetails.WorkflowdetailFragment; -import org.apache.taverna.mobile.tavernamobile.User; -import org.apache.taverna.mobile.tavernamobile.Workflow; - -/** - * 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. - */ - -/** - * Parse details from the xml output of myexperiment API - * Created by Larry Akah on 6/24/15. - */ -public class WorkflowDetailParser extends XMLParser { - - public WorkflowDetailParser(IRule[] rules) throws IllegalArgumentException, XMLParserException { - super(rules); - } - - //deliver results when parsing has completed and all the information required has been retrieved - @Override - protected void doEndDocument(Object userObject) { - if (userObject instanceof User) { - WorkflowItemFragment.startLoadingAvatar((User) userObject); - } else { - WorkflowdetailFragment.setWorkflowDetails((Workflow) userObject); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/src/main/java/org/apache/taverna/mobile/utils/xmlparsers/WorkflowParser.java ---------------------------------------------------------------------- diff --git a/app/src/main/java/org/apache/taverna/mobile/utils/xmlparsers/WorkflowParser.java b/app/src/main/java/org/apache/taverna/mobile/utils/xmlparsers/WorkflowParser.java deleted file mode 100644 index c73037a..0000000 --- a/app/src/main/java/org/apache/taverna/mobile/utils/xmlparsers/WorkflowParser.java +++ /dev/null @@ -1,52 +0,0 @@ -/* -* 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. -*/ - -package org.apache.taverna.mobile.utils.xmlparsers; - -import com.thebuzzmedia.sjxp.XMLParser; -import com.thebuzzmedia.sjxp.XMLParserException; -import com.thebuzzmedia.sjxp.rule.IRule; - -import org.apache.taverna.mobile.fragments.WorkflowItemFragment; -import org.apache.taverna.mobile.tavernamobile.Workflow; - -import java.util.List; - -/** - * Workflow end document class for detecting when the complete list of workflows have been read out - * Created by Larry Akah on 6/24/15. - */ - -public class WorkflowParser extends XMLParser { - - public WorkflowParser(IRule[] rules) throws IllegalArgumentException, XMLParserException { - super(rules); - } - - @Override - protected void doEndDocument(Object userObject) { - WorkflowItemFragment.updateWorkflowUI((List<Workflow>) userObject); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/src/main/res/layout/activity_run_result.xml ---------------------------------------------------------------------- diff --git a/app/src/main/res/layout/activity_run_result.xml b/app/src/main/res/layout/activity_run_result.xml deleted file mode 100644 index 77026cf..0000000 --- a/app/src/main/res/layout/activity_run_result.xml +++ /dev/null @@ -1,28 +0,0 @@ -<!-- - Apache Taverna Mobile - Copyright 2016 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. ---> -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container" - android:layout_width="match_parent" android:layout_height="match_parent" - tools:context="org.apache.taverna.mobile.activities.RunResult" tools:ignore="MergeRootFrame" /> http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/src/main/res/layout/activity_workflow_detail.xml ---------------------------------------------------------------------- diff --git a/app/src/main/res/layout/activity_workflow_detail.xml b/app/src/main/res/layout/activity_workflow_detail.xml deleted file mode 100644 index 56edf11..0000000 --- a/app/src/main/res/layout/activity_workflow_detail.xml +++ /dev/null @@ -1,39 +0,0 @@ -<!-- -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. ---> -<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/pager" - android:layout_width="match_parent" - android:layout_height="match_parent" - tools:context="org.apache.taverna.mobile.activities.WorkflowDetailActivity" > - <android.support.v4.view.PagerTitleStrip - android:id="@+id/pager_title_strip" - android:layout_width="match_parent" - android:layout_height="50sp" - android:layout_gravity="top" - android:background="#33b5e5" - android:textColor="#fff" - android:paddingTop="1dp" - android:paddingBottom="1dp" - android:animateLayoutChanges="true" - android:elevation="@dimen/abc_text_size_menu_material" - /> - -</android.support.v4.view.ViewPager> http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/src/main/res/layout/favorite_item_layout.xml ---------------------------------------------------------------------- diff --git a/app/src/main/res/layout/favorite_item_layout.xml b/app/src/main/res/layout/favorite_item_layout.xml deleted file mode 100644 index 0c9cf3e..0000000 --- a/app/src/main/res/layout/favorite_item_layout.xml +++ /dev/null @@ -1,138 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -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. ---> -<android.support.v7.widget.CardView - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:card_view="http://schemas.android.com/apk/res-auto" - xmlns:app="http://schemas.android.com/apk/res-auto" - android:layout_width="match_parent" - android:layout_height="wrap_content" - card_view:cardElevation="@dimen/abc_text_size_menu_material" - card_view:cardBackgroundColor="@color/background_floating_material_light" - android:layout_marginBottom="@dimen/cardMarginVertical" - android:layout_marginLeft="@dimen/cardMarginHorizontal" - android:layout_marginRight="@dimen/cardMarginHorizontal" - android:layout_marginTop="@dimen/cardMarginVertical" - card_view:cardCornerRadius="2dp" - card_view:paddingEnd="2dp" - card_view:paddingStart="2dp"> - - <LinearLayout - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <LinearLayout - android:orientation="horizontal" - android:layout_width="match_parent" - android:layout_height="wrap_content" - > - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceLarge" - android:id="@+id/author" - android:textSize="25sp" - android:elevation="5dp" - android:layout_weight="1" /> - - <ImageButton - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:id="@+id/favoriteButonDelete" - android:src="@android:drawable/ic_menu_delete" - android:background="#eee" - android:layout_gravity="right" - android:visibility="gone" /> -<!-- @drawable/ic_delete_favorite --> - - <android.support.design.widget.FloatingActionButton - android:id="@+id/favoriteButtonDelete" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - app:layout_anchorGravity="bottom|right|end" - android:layout_margin="5dp" - android:src="@android:drawable/ic_menu_delete" /> - </LinearLayout> - - <LinearLayout - android:id="@+id/linearlayout_workflow_info" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="horizontal"> - - <LinearLayout - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginLeft="5dp"> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/wktitle" - android:id="@+id/textView9" - android:layout_marginTop="5dp" /> - - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceLarge" - android:id="@+id/favorite_title" - android:hint="@string/title_favorite" /> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/marked" - android:id="@+id/textView10" - android:layout_gravity="center_horizontal" /> - - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceLarge" - android:hint="Date workflow was marked" - android:id="@+id/date_set" - android:typeface="serif" - android:textColor="@color/material_deep_teal_200" - android:textSize="15dp" - android:focusableInTouchMode="false" - android:layout_gravity="center_horizontal" - android:gravity="center_horizontal" /> - - <Button - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:text="@string/workflow_read" - android:id="@+id/buttonOpenFavorite" - android:layout_gravity="center_horizontal" - android:layout_margin="10dp" - android:background="#33b5e5" - android:elevation="5dp" /> - - </LinearLayout> - - </LinearLayout> - - </LinearLayout> - -</android.support.v7.widget.CardView> http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/src/main/res/layout/fragment_dashboard_main.xml ---------------------------------------------------------------------- diff --git a/app/src/main/res/layout/fragment_dashboard_main.xml b/app/src/main/res/layout/fragment_dashboard_main.xml deleted file mode 100644 index 32081e6..0000000 --- a/app/src/main/res/layout/fragment_dashboard_main.xml +++ /dev/null @@ -1,39 +0,0 @@ -<!-- -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. - ---> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="match_parent" - tools:context="org.apache.taverna.mobile.fragments.FavoriteFragment" - android:orientation="vertical" - android:padding="2dp"> - - <android.support.v7.widget.RecyclerView - xmlns:recycler_view="http://schemas.android.com/apk/res-auto" - android:id="@+id/favoriteList" - android:theme="@style/Theme.AppCompat.Light" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="@color/button_material_light"> - - </android.support.v7.widget.RecyclerView> - - <TextView android:id="@android:id/empty" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:gravity="center" - android:visibility="gone" - android:text="@string/favorite_empty"/> -</LinearLayout> http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/src/main/res/layout/fragment_item_grid.xml ---------------------------------------------------------------------- diff --git a/app/src/main/res/layout/fragment_item_grid.xml b/app/src/main/res/layout/fragment_item_grid.xml deleted file mode 100644 index 6ba0ef0..0000000 --- a/app/src/main/res/layout/fragment_item_grid.xml +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -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. ---> -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:layout_width="match_parent" - android:layout_height="match_parent" - tools:context="org.apache.taverna.mobile.fragments.WorkflowItemFragment"> - - <!-- <GridView android:id="@+id/gridlist" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:numColumns="2">--> - <android.support.v4.widget.SwipeRefreshLayout - android:id="@+id/refresh" - android:layout_height="match_parent" - android:layout_width="match_parent"> - <android.support.v7.widget.RecyclerView - xmlns:recycler_view="http://schemas.android.com/apk/res-auto" - android:id="@android:id/list" - android:theme="@style/Theme.AppCompat.Light" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="@color/button_material_light" - android:scrollbars="vertical" - android:scrollbarStyle="insideOverlay" - android:fadeScrollbars="true" - ></android.support.v7.widget.RecyclerView> - <!-- </GridView>--> -</android.support.v4.widget.SwipeRefreshLayout> - <TextView android:id="@android:id/empty" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:visibility="gone" - android:background="@drawable/ic_viewworkflow" - android:gravity="center" - android:text="@string/workflow_empty"/> - -</FrameLayout> http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/src/main/res/layout/fragment_item_list.xml ---------------------------------------------------------------------- diff --git a/app/src/main/res/layout/fragment_item_list.xml b/app/src/main/res/layout/fragment_item_list.xml deleted file mode 100644 index 0acec8c..0000000 --- a/app/src/main/res/layout/fragment_item_list.xml +++ /dev/null @@ -1,50 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -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. ---> -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:layout_width="match_parent" - android:layout_height="match_parent" - tools:context="org.apache.taverna.mobile.fragments.WorkflowItemFragment"> - - <!--<ListView android:id="@android:id/list" android:layout_width="match_parent"--> - <!--android:layout_height="match_parent" />--> - <android.support.v4.widget.SwipeRefreshLayout - android:id="@+id/refresh" - android:layout_height="match_parent" - android:layout_width="match_parent"> - <android.support.v7.widget.RecyclerView - xmlns:recycler_view="http://schemas.android.com/apk/res-auto" - android:id="@android:id/list" - android:theme="@style/Theme.AppCompat.Light" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="@color/button_material_light" - android:scrollbars="vertical" - android:scrollbarStyle="insideOverlay" - android:fadeScrollbars="true"> - - </android.support.v7.widget.RecyclerView> -</android.support.v4.widget.SwipeRefreshLayout> - <TextView - android:id="@android:id/empty" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:gravity="center" - android:visibility="gone" - android:background="@drawable/ic_viewworkflow" - android:text="@string/workflow_empty"/> - -</FrameLayout>
