use of com.twinsoft.convertigo.beans.connectors.FullSyncConnector in project convertigo by convertigo.
the class ObjectInfoWizardPage method createControl.
public void createControl(Composite parent) {
container = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
container.setLayout(layout);
layout.numColumns = 2;
layout.verticalSpacing = 9;
Label label = new Label(container, SWT.NULL);
label.setText("&Name:");
beanName = new Text(container, SWT.BORDER | SWT.SINGLE);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
beanName.setLayoutData(gd);
beanName.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
dialogChanged(false);
}
});
if (parentObject instanceof CouchDbConnector || parentObject instanceof FullSyncConnector) {
couchVariablesComposite = new CouchVariablesComposite(container, SWT.V_SCROLL);
GridData couchVarData = new GridData(GridData.FILL_BOTH);
couchVarData.horizontalSpan = 2;
couchVariablesComposite.setLayoutData(couchVarData);
} else {
tree = new Tree(container, SWT.SINGLE | SWT.BORDER);
tree.setHeaderVisible(false);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.verticalSpan = 20;
gridData.horizontalSpan = 2;
tree.setLayoutData(gridData);
tree.addListener(SWT.Selection, new Listener() {
public void handleEvent(final Event event) {
TreeItem item = (TreeItem) event.item;
treeItemName = item.getText();
String suffix = getBeanName().endsWith(ScHandlerStatement.EVENT_ENTRY_HANDLER) ? ScHandlerStatement.EVENT_ENTRY_HANDLER : getBeanName().endsWith(ScHandlerStatement.EVENT_EXIT_HANDLER) ? ScHandlerStatement.EVENT_EXIT_HANDLER : "";
setBeanName("on" + treeItemName + suffix);
dialogChanged(true);
}
});
tree.setVisible(false);
}
initialize();
dialogChanged(true);
setControl(container);
}
use of com.twinsoft.convertigo.beans.connectors.FullSyncConnector in project convertigo by convertigo.
the class ObjectExplorerWizardPage method createBean.
private void createBean() {
BeanInfo bi = getCurrentSelectedBeanInfo();
if (bi != null) {
try {
newBean = (DatabaseObject) bi.getBeanDescriptor().getBeanClass().getConstructor().newInstance();
if (parentObject instanceof DatabaseObject) {
newBean.setParent((DatabaseObject) parentObject);
}
if (xpath != null) {
if (newBean instanceof IXPathable) {
((IXPathable) newBean).setXpath(xpath);
}
// case we create an "javascriptable" statement
if (newBean instanceof XpathableStatement) {
((XpathableStatement) newBean).setPureXpath(xpath);
}
}
// case we create a javelinConnector
if (newBean instanceof JavelinConnector) {
((JavelinConnector) newBean).setEmulatorTechnology(com.twinsoft.api.Session.AS400);
((JavelinConnector) newBean).emulatorID = ((JavelinConnector) newBean).findEmulatorId();
((JavelinConnector) newBean).setServiceCode(",DIR|localhost:23");
}
if (newBean instanceof FullSyncConnector && parentObject instanceof Project) {
newBean.setName(((Project) parentObject).getName().toLowerCase() + "_fullsync");
}
} catch (Exception e) {
newBean = null;
}
}
}
use of com.twinsoft.convertigo.beans.connectors.FullSyncConnector in project convertigo by convertigo.
the class CreateDbo method getServiceResult.
@Override
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
String qname = request.getParameter("qname");
String folderType = request.getParameter("folderType");
String beanClassNameToCreate = request.getParameter("beanClass");
DatabaseObject parentDbo = Engine.theApp.databaseObjectsManager.getDatabaseObjectByQName(qname);
Class<? extends DatabaseObject> beanClassToCreate = GenericUtils.cast(Class.forName(beanClassNameToCreate));
Class<? extends DatabaseObject> databaseObjectClass = Get.folderNameToBeanClass.get(folderType);
Element root = document.getDocumentElement();
// Before add, we musht check if we can add it
boolean canCreate = DatabaseObjectsManager.acceptDatabaseObjects(parentDbo, beanClassToCreate, databaseObjectClass);
if (canCreate) {
DatabaseObject newBean = (DatabaseObject) Class.forName(beanClassNameToCreate).getConstructor().newInstance();
try {
String beanName = newBean.getName();
// The name of the FullSyncConnector needs to in be lower case
if (newBean instanceof FullSyncConnector) {
beanName = beanName.toLowerCase();
}
// Compute new name
newBean.setName(newBean.getChildBeanName(parentDbo.getDatabaseObjectChildren(), beanName, true));
// If the new bean has to be inserted at a specific position
if (parentDbo instanceof IContainerOrdered) {
String afterPriority = request.getParameter("afterPriority");
Long after = null;
try {
after = Long.valueOf(afterPriority);
} catch (NumberFormatException e) {
after = null;
}
IContainerOrdered containerOrdered = (IContainerOrdered) parentDbo;
containerOrdered.add(newBean, after);
} else {
// Need to create more things in case of Connectors
if (newBean instanceof Connector) {
Connector.setupConnector(newBean);
}
parentDbo.add(newBean);
}
// Get new bean info
Element response = document.createElement("response");
GetChildren.getChildren(newBean.getQName(), response, 0);
response.setAttribute("state", "success");
root.appendChild(response);
} catch (EngineException e) {
throw e;
}
} else {
throw new EngineException("You cannot create a " + beanClassNameToCreate + " object here.");
}
}
use of com.twinsoft.convertigo.beans.connectors.FullSyncConnector in project convertigo by convertigo.
the class MobileSmartSource method getDatabaseObject.
public DatabaseObject getDatabaseObject(String rootDboName) {
List<String> sourceData = getSources();
String sourceInput = sourceData.size() > 0 ? sourceData.get(0) : null;
if (sourceInput != null) {
if (Filter.Action.equals(getFilter())) {
Matcher m = actionPattern.matcher(sourceInput);
if (m.find()) {
String stack = m.group(1);
try {
String p = stack.replaceFirst("stack\\[", "").replaceFirst("\\]", "");
// ignore quotes
p = p.substring(1, p.length() - 1);
long priority = Long.valueOf(p, 10);
return findDatabaseObject(rootDboName, priority);
} catch (Exception e) {
e.printStackTrace();
}
}
} else if (Filter.Shared.equals(getFilter())) {
Matcher m = sharedPattern.matcher(sourceInput);
if (m.find()) {
String shared = m.group(1);
try {
long priority = Long.valueOf(shared.replaceFirst("params", ""), 10);
return findDatabaseObject(rootDboName, priority);
} catch (Exception e) {
e.printStackTrace();
}
}
} else if (Filter.Iteration.equals(getFilter())) {
Matcher m = directivePattern.matcher(sourceInput);
if (m.find()) {
String item = m.group(1);
try {
long priority = Long.valueOf(item.replaceFirst("item", ""), 10);
return findDatabaseObject(rootDboName, priority);
} catch (Exception e) {
e.printStackTrace();
}
}
} else if (Filter.Form.equals(getFilter())) {
Matcher m = formPattern.matcher(sourceInput);
if (m.find()) {
String form = m.group(1);
try {
long priority = Long.valueOf(form.replaceFirst("form", ""), 10);
return findDatabaseObject(rootDboName, priority);
} catch (Exception e) {
e.printStackTrace();
}
}
} else if (Filter.Global.equals(getFilter())) {
Matcher m = globalPattern.matcher(sourceInput);
if (m.find()) {
try {
String projectName = getProjectName();
Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
DatabaseObject dbo = (ApplicationComponent) project.getMobileApplication().getApplicationComponent();
return dbo;
} catch (Exception e) {
e.printStackTrace();
}
}
} else if (Filter.Database.equals(getFilter())) {
Matcher m = cafPattern.matcher(sourceInput);
if (m.find()) {
try {
String name = m.group(1);
name = name.replaceFirst("fs://", "");
name = name.replaceFirst("\\.view", "");
name = name.replaceFirst("\\.get", "");
int i = name.indexOf('#');
if (i != -1) {
name = name.substring(0, i);
}
int index = name.indexOf('.');
String projectName = index != -1 ? name.substring(0, index) : getProjectName();
String dbName = index != -1 ? name.substring(index + 1) : name;
Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
FullSyncConnector connector = (FullSyncConnector) project.getConnectorByName(dbName);
String documentName = getParameters().get("ddoc");
DesignDocument ddoc = (DesignDocument) connector.getDocumentByName(documentName);
return ddoc;
} catch (Exception e) {
e.printStackTrace();
}
}
} else if (Filter.Sequence.equals(getFilter())) {
Matcher m = cafPattern.matcher(sourceInput);
if (m.find()) {
try {
String name = m.group(1);
int i = name.indexOf('#');
if (i != -1) {
name = name.substring(0, i);
}
int index = name.indexOf('.');
String projectName = index != -1 ? name.substring(0, index) : getProjectName();
projectName = projectName.isEmpty() ? getProjectName() : projectName;
String sequenceName = index != -1 ? name.substring(index + 1) : name;
Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
Sequence sequence = project.getSequenceByName(sequenceName);
return sequence;
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
return null;
}
use of com.twinsoft.convertigo.beans.connectors.FullSyncConnector in project convertigo by convertigo.
the class MobileSmartSource method getDatabaseObject.
public DatabaseObject getDatabaseObject(String rootDboName) {
List<String> sourceData = getSources();
String sourceInput = sourceData.size() > 0 ? sourceData.get(0) : null;
if (sourceInput != null) {
if (Filter.Action.equals(getFilter())) {
Matcher m = actionPattern.matcher(sourceInput);
if (m.find()) {
String stack = m.group(1);
try {
String p = stack.replaceFirst("stack\\[", "").replaceFirst("\\]", "");
// ignore quotes
p = p.substring(1, p.length() - 1);
long priority = Long.valueOf(p, 10);
return findDatabaseObject(rootDboName, priority);
} catch (Exception e) {
e.printStackTrace();
}
}
} else if (Filter.Shared.equals(getFilter())) {
Matcher m = sharedPattern.matcher(sourceInput);
if (m.find()) {
String shared = m.group(1);
try {
long priority = Long.valueOf(shared.replaceFirst("params", ""), 10);
return findDatabaseObject(rootDboName, priority);
} catch (Exception e) {
e.printStackTrace();
}
}
} else if (Filter.Iteration.equals(getFilter())) {
Matcher m = directivePattern.matcher(sourceInput);
if (m.find()) {
String item = m.group(1);
try {
long priority = Long.valueOf(item.replaceFirst("item", ""), 10);
return findDatabaseObject(rootDboName, priority);
} catch (Exception e) {
e.printStackTrace();
}
}
} else if (Filter.Form.equals(getFilter())) {
Matcher m = formPattern.matcher(sourceInput);
if (m.find()) {
String form = m.group(1);
try {
long priority = Long.valueOf(form.replaceFirst("form", ""), 10);
return findDatabaseObject(rootDboName, priority);
} catch (Exception e) {
e.printStackTrace();
}
}
} else if (Filter.Global.equals(getFilter())) {
Matcher m = globalPattern.matcher(sourceInput);
if (m.find()) {
try {
String projectName = getProjectName();
Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
DatabaseObject dbo = (ApplicationComponent) project.getMobileApplication().getApplicationComponent();
return dbo;
} catch (Exception e) {
e.printStackTrace();
}
}
} else if (Filter.Database.equals(getFilter())) {
Matcher m = cafPattern.matcher(sourceInput);
if (m.find()) {
try {
String name = m.group(1);
name = name.replaceFirst("fs://", "");
name = name.replaceFirst("\\.view", "");
name = name.replaceFirst("\\.get", "");
int i = name.indexOf('#');
if (i != -1) {
name = name.substring(0, i);
}
int index = name.indexOf('.');
String projectName = index != -1 ? name.substring(0, index) : getProjectName();
String dbName = index != -1 ? name.substring(index + 1) : name;
Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
FullSyncConnector connector = (FullSyncConnector) project.getConnectorByName(dbName);
String documentName = getParameters().get("ddoc");
DesignDocument ddoc = (DesignDocument) connector.getDocumentByName(documentName);
return ddoc;
} catch (Exception e) {
e.printStackTrace();
}
}
} else if (Filter.Sequence.equals(getFilter())) {
Matcher m = cafPattern.matcher(sourceInput);
if (m.find()) {
try {
String name = m.group(1);
int i = name.indexOf('#');
if (i != -1) {
name = name.substring(0, i);
}
int index = name.indexOf('.');
String projectName = index != -1 ? name.substring(0, index) : getProjectName();
projectName = projectName.isEmpty() ? getProjectName() : projectName;
String sequenceName = index != -1 ? name.substring(index + 1) : name;
Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
Sequence sequence = project.getSequenceByName(sequenceName);
return sequence;
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
return null;
}
Aggregations