Search in sources :

Example 6 with SourceData

use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData in project convertigo by convertigo.

the class NgxPickerContentProvider method addLocals.

private void addLocals(TVObject tvi, Object object) {
    if (object != null) {
        Map<String, UIDynamicAction> locals = null;
        if (object instanceof ApplicationComponent) {
            locals = new HashMap<>();
            getLocalActions(object, locals);
        }
        if (locals != null) {
            try {
                JSONObject jsonInfos = new JSONObject();
                for (String key : locals.keySet()) {
                    jsonInfos.put(key, "");
                }
                SourceData sd = null;
                try {
                    sd = Filter.Local.toSourceData(new JSONObject());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                tvi.add(new TVObject("localObject", object, sd, jsonInfos));
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : UIDynamicAction(com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction) JSONObject(org.codehaus.jettison.json.JSONObject) ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) JSONException(org.codehaus.jettison.json.JSONException) SourceData(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData) JSONException(org.codehaus.jettison.json.JSONException)

Example 7 with SourceData

use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData in project convertigo by convertigo.

the class NgxPickerContentProvider method addFsObjects.

private void addFsObjects(Map<String, Set<String>> map, TVObject tvd, Object object, boolean isReferenced) {
    if (object != null) {
        if (object instanceof Project) {
            Project project = (Project) object;
            for (Connector c : project.getConnectorsList()) {
                if (c instanceof FullSyncConnector) {
                    String label = isReferenced ? c.getQName() : c.getName();
                    TVObject tvc = tvd.add(new TVObject(label));
                    for (Document d : c.getDocumentsList()) {
                        if (d instanceof DesignDocument) {
                            TVObject tdd = tvc.add(new TVObject(d.getName()));
                            JSONObject views = CouchKey.views.JSONObject(((DesignDocument) d).getJSONObject());
                            if (views != null) {
                                for (Iterator<String> it = GenericUtils.cast(views.keys()); it.hasNext(); ) {
                                    try {
                                        Set<String> infos = null;
                                        String view = it.next();
                                        String key = c.getQName() + "." + d.getName() + "." + view;
                                        TVObject tvv = tdd.add(new TVObject(view));
                                        SourceData sd = null;
                                        try {
                                            sd = Filter.Database.toSourceData(new JSONObject().put("connector", c.getQName()).put("document", d.getQName()).put("queryview", view).put("verb", "get"));
                                        } catch (JSONException e) {
                                            e.printStackTrace();
                                        }
                                        tvv.add(new TVObject("get", d, sd));
                                        infos = map.get(key + ".get");
                                        if (infos == null) {
                                            infos = map.get(c.getQName() + ".get");
                                        }
                                        if (infos != null) {
                                            for (String info : infos) {
                                                try {
                                                    JSONObject jsonInfo = new JSONObject(info);
                                                    boolean includeDocs = false;
                                                    if (jsonInfo.has("include_docs")) {
                                                        includeDocs = Boolean.valueOf(jsonInfo.getString("include_docs")).booleanValue();
                                                    }
                                                    if (jsonInfo.has("marker")) {
                                                        String marker = jsonInfo.getString("marker");
                                                        if (!marker.isEmpty()) {
                                                            String name = "get" + "#" + marker;
                                                            sd = Filter.Database.toSourceData(new JSONObject().put("connector", c.getQName()).put("document", d.getQName()).put("queryview", view).put("verb", "get").put("marker", marker).put("includeDocs", includeDocs));
                                                            tvv.add(new TVObject(name, d, sd, jsonInfo));
                                                        }
                                                    }
                                                } catch (JSONException e) {
                                                    e.printStackTrace();
                                                }
                                            }
                                        }
                                        try {
                                            sd = Filter.Database.toSourceData(new JSONObject().put("connector", c.getQName()).put("document", d.getQName()).put("queryview", view).put("verb", "view"));
                                        } catch (JSONException e) {
                                            e.printStackTrace();
                                        }
                                        tvv.add(new TVObject("view", d, sd));
                                        infos = map.get(key + ".view");
                                        if (infos != null) {
                                            for (String info : infos) {
                                                try {
                                                    JSONObject jsonInfo = new JSONObject(info);
                                                    boolean includeDocs = false;
                                                    if (jsonInfo.has("include_docs")) {
                                                        includeDocs = Boolean.valueOf(jsonInfo.getString("include_docs")).booleanValue();
                                                    }
                                                    if (jsonInfo.has("marker")) {
                                                        String marker = jsonInfo.getString("marker");
                                                        if (!marker.isEmpty()) {
                                                            String name = "view" + "#" + marker;
                                                            sd = Filter.Database.toSourceData(new JSONObject().put("connector", c.getQName()).put("document", d.getQName()).put("queryview", view).put("verb", "view").put("marker", marker).put("includeDocs", includeDocs));
                                                            tvv.add(new TVObject(name, d, sd, jsonInfo));
                                                        }
                                                    }
                                                } catch (JSONException e) {
                                                    e.printStackTrace();
                                                }
                                            }
                                        }
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : Connector(com.twinsoft.convertigo.beans.core.Connector) FullSyncConnector(com.twinsoft.convertigo.beans.connectors.FullSyncConnector) JSONException(org.codehaus.jettison.json.JSONException) FullSyncConnector(com.twinsoft.convertigo.beans.connectors.FullSyncConnector) DesignDocument(com.twinsoft.convertigo.beans.couchdb.DesignDocument) Document(com.twinsoft.convertigo.beans.core.Document) SourceData(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData) JSONException(org.codehaus.jettison.json.JSONException) Project(com.twinsoft.convertigo.beans.core.Project) JSONObject(org.codehaus.jettison.json.JSONObject) DesignDocument(com.twinsoft.convertigo.beans.couchdb.DesignDocument)

Example 8 with SourceData

use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData in project convertigo by convertigo.

the class NgxPickerContentProvider method addGlobals.

private void addGlobals(TVObject tvi, Object object) {
    if (object != null) {
        Map<String, UIDynamicAction> globals = null;
        if (object instanceof ApplicationComponent) {
            globals = new HashMap<>();
            getGlobalActions(object, globals);
        }
        if (globals != null) {
            try {
                JSONObject jsonFSSA = new JSONObject().put("FullSyncSyncAction", new JSONObject().put("progress", new JSONObject().put("changed", "").put("continuous", "").put("finished", "").put("pull", "").put("current", "").put("total", "").put("status", "").put("taskInfo", "").put("raw", "")));
                JSONObject jsonInfos = new JSONObject();
                for (String key : globals.keySet()) {
                    if ("FullSyncSyncAction".equals(key)) {
                        jsonInfos.put(key, jsonFSSA.get(key));
                    } else {
                        jsonInfos.put(key, "");
                    }
                }
                SourceData sd = null;
                try {
                    sd = Filter.Global.toSourceData(new JSONObject());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                tvi.add(new TVObject("sharedObject", object, sd, jsonInfos));
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : UIDynamicAction(com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction) JSONObject(org.codehaus.jettison.json.JSONObject) ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) JSONException(org.codehaus.jettison.json.JSONException) SourceData(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData) JSONException(org.codehaus.jettison.json.JSONException)

Example 9 with SourceData

use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData in project convertigo by convertigo.

the class NgxPickerComposite method getModelData.

// private List<String> getSourceList() {
// TVObject tvoSelected = null;
// Object selected = checkboxTreeViewer.getStructuredSelection().getFirstElement();
// if (selected != null && selected instanceof TVObject) {
// tvoSelected = (TVObject)selected;
// }
// 
// List<String> sourceList =  new ArrayList<String>();
// List<TVObject> tvoList = GenericUtils.cast(Arrays.asList(checkboxTreeViewer.getCheckedElements()));
// for (TVObject tvo : tvoList) {
// if (tvo.equals(tvoSelected)) {
// sourceList.add(0, tvo.getSource());
// }
// else {
// sourceList.add(tvo.getSource());
// }
// }
// return sourceList;
// }
private List<SourceData> getModelData() {
    TVObject tvoSelected = null;
    Object selected = checkboxTreeViewer.getStructuredSelection().getFirstElement();
    if (selected != null && selected instanceof TVObject) {
        tvoSelected = (TVObject) selected;
    }
    List<SourceData> sourceList = new ArrayList<SourceData>();
    List<TVObject> tvoList = GenericUtils.cast(Arrays.asList(checkboxTreeViewer.getCheckedElements()));
    for (TVObject tvo : tvoList) {
        SourceData sd = tvo.getSourceData();
        if (sd != null) {
            if (tvo.equals(tvoSelected)) {
                sourceList.add(0, sd);
            } else {
                sourceList.add(sd);
            }
        }
    }
    return sourceList;
}
Also used : TVObject(com.twinsoft.convertigo.eclipse.views.mobile.NgxPickerContentProvider.TVObject) ArrayList(java.util.ArrayList) NgxComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) JSONObject(org.codehaus.jettison.json.JSONObject) NgxUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) TVObject(com.twinsoft.convertigo.eclipse.views.mobile.NgxPickerContentProvider.TVObject) NgxPageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxPageComponentTreeObject) MobileObject(com.twinsoft.convertigo.beans.core.MobileObject) SourceData(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData)

Aggregations

SourceData (com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData)9 JSONObject (org.codehaus.jettison.json.JSONObject)9 JSONException (org.codehaus.jettison.json.JSONException)8 ApplicationComponent (com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent)4 UIComponent (com.twinsoft.convertigo.beans.ngx.components.UIComponent)4 PageComponent (com.twinsoft.convertigo.beans.ngx.components.PageComponent)3 ArrayList (java.util.ArrayList)3 Project (com.twinsoft.convertigo.beans.core.Project)2 UIDynamicAction (com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction)2 UISharedComponent (com.twinsoft.convertigo.beans.ngx.components.UISharedComponent)2 FullSyncConnector (com.twinsoft.convertigo.beans.connectors.FullSyncConnector)1 Connector (com.twinsoft.convertigo.beans.core.Connector)1 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)1 Document (com.twinsoft.convertigo.beans.core.Document)1 MobileObject (com.twinsoft.convertigo.beans.core.MobileObject)1 RequestableObject (com.twinsoft.convertigo.beans.core.RequestableObject)1 Sequence (com.twinsoft.convertigo.beans.core.Sequence)1 DesignDocument (com.twinsoft.convertigo.beans.couchdb.DesignDocument)1 IAction (com.twinsoft.convertigo.beans.ngx.components.IAction)1 UIActionEvent (com.twinsoft.convertigo.beans.ngx.components.UIActionEvent)1