use of com.twinsoft.convertigo.beans.core.Connector in project convertigo by convertigo.
the class ReferencesView method handleConnectorSelection.
private void handleConnectorSelection(Object firstElement) {
ConnectorTreeObject connectorTreeObject = (ConnectorTreeObject) firstElement;
Connector connectorSelected = connectorTreeObject.getObject();
String connectorSelectedName = connectorSelected.getName();
Project projectConnectorSelected = connectorSelected.getProject();
String connectorProjectName = connectorSelected.getProject().getName();
List<Transaction> transactions = connectorSelected.getTransactionsList();
try {
Project project = null;
List<String> projectNames = Engine.theApp.databaseObjectsManager.getAllProjectNamesList();
ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
treeViewer.setInput(null);
RootNode root = new RootNode();
ConnectorNode connectorNode = null;
connectorNode = getConnectorNode(root, connectorSelected);
root.addChild(connectorNode);
IsUsedByNode isUsedByNode = new IsUsedByNode(connectorNode, "Is used by");
RequiresNode requiresNode = new RequiresNode(connectorNode, "Requires");
ProjectNode projectFolder = null;
// Search handlers are that referenced by the selected connector for continue with site Clipper
if (connectorSelected instanceof HtmlConnector) {
ProjectNode projectNode = new ProjectNode(requiresNode, connectorProjectName, projectConnectorSelected);
for (Transaction transaction : transactions) {
List<Statement> statements = ((HtmlTransaction) transaction).getStatements();
List<String> siteClipperConnectorNames = new ArrayList<String>();
for (Statement statement : statements) {
List<Statement> statementList = ((FunctionStatement) statement).getStatements();
for (Statement st : statementList) {
if (st instanceof ContinueWithSiteClipperStatement) {
ContinueWithSiteClipperStatement continueWithSiteClipperStatement = (ContinueWithSiteClipperStatement) st;
String siteClipperconnectorName = continueWithSiteClipperStatement.getSiteClipperConnectorName();
if (!siteClipperConnectorNames.contains(siteClipperconnectorName)) {
siteClipperConnectorNames.add(siteClipperconnectorName);
Connector siteClipperConnector = projectConnectorSelected.getConnectorByName(siteClipperconnectorName);
ConnectorNode connectorSiteClipperNode = new SiteClipperConnectorNode(projectNode, siteClipperconnectorName, siteClipperConnector);
projectNode.addChild(connectorSiteClipperNode);
}
}
}
}
}
if (projectNode.hasChildren()) {
requiresNode.addChild(projectNode);
}
} else if (connectorSelected instanceof SiteClipperConnector) {
List<Connector> connectors = projectConnectorSelected.getConnectorsList();
ProjectNode projectNode = new ProjectNode(isUsedByNode, connectorProjectName, projectConnectorSelected);
for (Connector connector : connectors) {
if (connector instanceof HtmlConnector) {
List<Transaction> transactionList = ((HtmlConnector) connector).getTransactionsList();
for (Transaction transaction : transactionList) {
List<Statement> statements = ((HtmlTransaction) transaction).getStatements();
for (Statement statement : statements) {
List<Statement> statementList = ((FunctionStatement) statement).getStatements();
for (Statement st : statementList) {
if (st instanceof ContinueWithSiteClipperStatement) {
String sourceSiteClipperConnectorName = ((ContinueWithSiteClipperStatement) st).getSiteClipperConnectorName();
if (sourceSiteClipperConnectorName.equals(connectorSelectedName)) {
ContinueWithSiteClipperStatement continueWithSiteClipperStatement = (ContinueWithSiteClipperStatement) st;
HtmlConnectorNode htmlConnectorNode = new HtmlConnectorNode(projectNode, connector.getName(), connector);
projectNode.addChild(htmlConnectorNode);
TransactionNode transactionNode = new TransactionNode(htmlConnectorNode, transaction.getName(), continueWithSiteClipperStatement);
htmlConnectorNode.addChild(transactionNode);
}
}
}
}
}
}
}
if (projectNode.hasChildren()) {
isUsedByNode.addChild(projectNode);
}
}
// Searching all objects that are referenced by the selected connector
for (String projectName : projectNames) {
project = getProject(projectName, projectExplorerView);
if (project != null) {
projectFolder = new ProjectNode(isUsedByNode, projectName, project);
UrlMapper urlMapper = project.getUrlMapper();
if (urlMapper != null) {
MapperNode mapperNode = new MapperNode(projectFolder, urlMapper.getName(), urlMapper);
List<UrlMapping> mappings = urlMapper.getMappingList();
for (UrlMapping mapping : mappings) {
MappingPathNode pathNode = new MappingPathNode(mapperNode, mapping.getPath(), mapping);
List<UrlMappingOperation> operations = mapping.getOperationList();
for (UrlMappingOperation operation : operations) {
String targetRequestable = operation.getTargetRequestable();
if (targetRequestable.startsWith(projectConnectorSelected + "." + connectorSelectedName + ".")) {
MappingOperationNode operationNode = new MappingOperationNode(pathNode, operation.getName(), operation);
pathNode.addChild(operationNode);
}
}
if (pathNode.hasChildren()) {
mapperNode.addChild(pathNode);
}
}
if (mapperNode.hasChildren()) {
projectFolder.addChild(mapperNode);
}
}
List<Sequence> sequences = project.getSequencesList();
for (Sequence sequence : sequences) {
List<Step> steps = sequence.getSteps();
SequenceNode sequenceNode = new SequenceNode(projectFolder, sequence.getName(), sequence);
for (Step step : steps) {
getConnectorReferencingIsUsedBy(step, projectExplorerView, sequenceNode, transactions, connectorProjectName, connectorSelectedName);
}
if (sequenceNode.hasChildren()) {
projectFolder.addChild(sequenceNode);
}
}
if (projectFolder.hasChildren()) {
isUsedByNode.addChild(projectFolder);
}
}
}
if (requiresNode.hasChildren()) {
connectorNode.addChild(requiresNode);
}
if (isUsedByNode.hasChildren()) {
connectorNode.addChild(isUsedByNode);
}
if (!connectorNode.hasChildren()) {
connectorNode.addChild(new InformationNode(connectorNode, "This connector is not used by any other objects"));
}
treeViewer.setInput(root);
treeViewer.expandAll();
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Error while analyzing the projects hierarchy", true);
}
}
use of com.twinsoft.convertigo.beans.core.Connector in project convertigo by convertigo.
the class ReferencesView method handleCallStepselection.
private void handleCallStepselection(Object firstElement) {
try {
ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
StepTreeObject stepTreeObject = (StepTreeObject) firstElement;
Step step = stepTreeObject.getObject();
RootNode root = new RootNode();
if (step instanceof TransactionStep) {
TransactionStep transactionStep = (TransactionStep) step;
String transactionStepName = transactionStep.getName();
TransactionStepNode transactionStepNode = new TransactionStepNode(root, transactionStepName, transactionStep);
RequiresNode requiresNode = new RequiresNode(transactionStepNode, "Requires");
String transactionName = transactionStep.getTransactionName();
String connectorName = transactionStep.getConnectorName();
String projectName = transactionStep.getProjectName();
Project project = getProject(projectName, projectExplorerView);
ProjectNode projectNode = new ProjectNode(requiresNode, projectName, project);
Connector connector = null;
Transaction transaction = null;
try {
if (project != null) {
connector = project.getConnectorByName(connectorName);
if (connector != null) {
transaction = connector.getTransactionByName(transactionName);
}
}
} catch (EngineException e) {
connector = null;
transaction = null;
}
ConnectorNode connectorNode = getConnectorNode(projectNode, connector);
if (connectorNode == null)
connectorNode = new ConnectorNode(projectNode, connectorName, connector);
projectNode.addChild(connectorNode);
TransactionNode transactionNode = new TransactionNode(projectNode, transactionName, transaction);
connectorNode.addChild(transactionNode);
requiresNode.addChild(projectNode);
transactionStepNode.addChild(requiresNode);
root.addChild(transactionStepNode);
} else if (step instanceof SequenceStep) {
SequenceStep sequenceStep = (SequenceStep) step;
String sequenceStepName = sequenceStep.getName();
SequenceStepNode sequenceStepNode = new SequenceStepNode(root, sequenceStepName, sequenceStep);
RequiresNode requiresNode = new RequiresNode(sequenceStepNode, "Requires");
String sequenceName = sequenceStep.getSequenceName();
String projectName = sequenceStep.getProjectName();
Project project = getProject(projectName, projectExplorerView);
ProjectNode projectNode = new ProjectNode(requiresNode, projectName, project);
Sequence sequence = null;
try {
if (project != null)
sequence = project.getSequenceByName(sequenceName);
} catch (EngineException e) {
sequence = null;
}
projectNode.addChild(new SequenceNode(projectNode, sequenceName, sequence));
requiresNode.addChild(projectNode);
sequenceStepNode.addChild(requiresNode);
root.addChild(sequenceStepNode);
} else {
root.addChild(new InformationNode(root, "References are not handled for this object"));
treeViewer.setInput(root);
}
treeViewer.setInput(root);
treeViewer.expandAll();
} catch (Exception e) {
ConvertigoPlugin.logException(e, "Error while analyzing the projects hierarchy", true);
}
}
use of com.twinsoft.convertigo.beans.core.Connector in project convertigo by convertigo.
the class ReferencesView method getUsedRequestables.
private void getUsedRequestables(Step step, Project projectSelected, AbstractParentNode parentNode) {
try {
if (step instanceof SequenceStep) {
SequenceStep sequenceStep = (SequenceStep) step;
String sourceProjectName = sequenceStep.getProjectName();
if (sourceProjectName.equals(projectSelected.getName())) {
Sequence sourceSequence = null;
String sourceSequenceName = sequenceStep.getSequenceName();
try {
if (projectSelected != null)
sourceSequence = projectSelected.getSequenceByName(sourceSequenceName);
} catch (EngineException e) {
sourceSequence = null;
}
SequenceStepNode sequenceStepNode = new SequenceStepNode(parentNode, step.getName() + " -> " + sequenceStep.getSourceSequence(), sourceSequence);
parentNode.addChild(sequenceStepNode);
}
} else if (step instanceof TransactionStep) {
TransactionStep transactionStep = (TransactionStep) step;
String sourceProjectName = transactionStep.getProjectName();
if (sourceProjectName.equals(projectSelected.getName())) {
Transaction sourceTransaction = null;
Connector connectorSelected = projectSelected.getConnectorByName(transactionStep.getConnectorName());
try {
if (connectorSelected != null)
sourceTransaction = connectorSelected.getTransactionByName(transactionStep.getTransactionName());
} catch (Exception e) {
sourceTransaction = null;
}
TransactionStepNode transactionStepNode = new TransactionStepNode(parentNode, step.getName() + " -> " + ((TransactionStep) step).getSourceTransaction(), sourceTransaction);
parentNode.addChild(transactionStepNode);
}
} else if (isStepContainer(step)) {
List<Step> steps = getStepList(step);
if (steps != null) {
for (Step s : steps) {
getUsedRequestables(s, projectSelected, parentNode);
}
}
}
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Unable to load the project", true);
}
}
use of com.twinsoft.convertigo.beans.core.Connector in project convertigo by convertigo.
the class ReferencesView method handleTargetRequestable.
private void handleTargetRequestable(String targetRequestableName, ProjectExplorerView projectExplorerView, RequiresNode requiresNode) throws EngineException {
StringTokenizer st = new StringTokenizer(targetRequestableName, ".");
int count = st.countTokens();
String projectName = st.nextToken();
Project project = getProject(projectName, projectExplorerView);
if (project != null) {
ProjectNode requiresProjectNode = new ProjectNode(requiresNode, projectName, project);
if (count == 2) {
String sequenceName = count == 2 ? st.nextToken() : "";
Sequence sequence = project.getSequenceByName(sequenceName);
SequenceNode sequenceNode = new SequenceNode(requiresProjectNode, sequenceName, sequence);
requiresProjectNode.addChild(sequenceNode);
} else if (count == 3) {
String connectorName = count == 3 ? st.nextToken() : "";
Connector connector = project.getConnectorByName(connectorName);
ConnectorNode connectorNode = new ConnectorNode(requiresProjectNode, connectorName, connector);
requiresProjectNode.addChild(connectorNode);
String transactionName = count == 3 ? st.nextToken() : "";
Transaction transaction = connector.getTransactionByName(transactionName);
TransactionNode transactionNode = new TransactionNode(connectorNode, transactionName, transaction);
connectorNode.addChild(transactionNode);
}
if (requiresProjectNode.hasChildren()) {
requiresNode.addChild(requiresProjectNode);
}
}
}
use of com.twinsoft.convertigo.beans.core.Connector in project convertigo by convertigo.
the class MobilePickerContentProvider 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();
}
}
}
}
}
}
}
}
}
}
Aggregations