use of com.twinsoft.convertigo.beans.couchdb.DesignDocument 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.couchdb.DesignDocument 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