use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.
the class Set method getServiceResult.
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
Element root = document.getDocumentElement();
Document post = null;
Element response = document.createElement("response");
try {
Map<String, DatabaseObject> map = com.twinsoft.convertigo.engine.admin.services.projects.Get.getDatabaseObjectByQName(request);
xpath = new TwsCachedXPathAPI();
post = XMLUtils.parseDOM(request.getInputStream());
postElt = document.importNode(post.getFirstChild(), true);
String objectQName = xpath.selectSingleNode(postElt, "./@qname").getNodeValue();
DatabaseObject object = map.get(objectQName);
if (object instanceof Project) {
Project project = (Project) object;
String objectNewName = getPropertyValue(object, "name").toString();
Engine.theApp.databaseObjectsManager.renameProject(project, objectNewName);
map.remove(objectQName);
map.put(project.getQName(), project);
}
BeanInfo bi = CachedIntrospector.getBeanInfo(object.getClass());
PropertyDescriptor[] propertyDescriptors = bi.getPropertyDescriptors();
for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
String propertyName = propertyDescriptor.getName();
Method setter = propertyDescriptor.getWriteMethod();
Class<?> propertyTypeClass = propertyDescriptor.getReadMethod().getReturnType();
if (propertyTypeClass.isPrimitive()) {
propertyTypeClass = ClassUtils.primitiveToWrapper(propertyTypeClass);
}
try {
String propertyValue = getPropertyValue(object, propertyName).toString();
Object oPropertyValue = createObject(propertyTypeClass, propertyValue);
if (object.isCipheredProperty(propertyName)) {
Method getter = propertyDescriptor.getReadMethod();
String initialValue = (String) getter.invoke(object, (Object[]) null);
if (oPropertyValue.equals(initialValue) || DatabaseObject.encryptPropertyValue(initialValue).equals(oPropertyValue)) {
oPropertyValue = initialValue;
} else {
object.hasChanged = true;
}
}
if (oPropertyValue != null) {
Object[] args = { oPropertyValue };
setter.invoke(object, args);
}
} catch (IllegalArgumentException e) {
}
}
Engine.theApp.databaseObjectsManager.exportProject(object.getProject());
response.setAttribute("state", "success");
response.setAttribute("message", "Project have been successfully updated!");
} catch (Exception e) {
Engine.logAdmin.error("Error during saving the properties!\n" + e.getMessage());
response.setAttribute("state", "error");
response.setAttribute("message", "Error during saving the properties!");
Element stackTrace = document.createElement("stackTrace");
stackTrace.setTextContent(e.getMessage());
root.appendChild(stackTrace);
} finally {
xpath.resetCache();
}
root.appendChild(response);
}
use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.
the class Get method getServiceResult.
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
String projectName = request.getParameter("projectName");
Element root = document.getDocumentElement();
root.setAttribute("name", projectName);
ProjectUtils.getFullProjectDOM(document, projectName, new StreamSource(getClass().getResourceAsStream("cleanDOM.xsl")));
final Map<String, DatabaseObject> map = getDatabaseObjectByQName(request);
map.clear();
Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
new WalkHelper() {
@Override
protected void walk(DatabaseObject databaseObject) throws Exception {
map.put(databaseObject.getQName(), databaseObject);
super.walk(databaseObject);
}
}.init(project);
}
use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.
the class DisableMobilePageComponentAction method selectionChanged.
public void selectionChanged(IAction action, ISelection selection) {
super.selectionChanged(action, selection);
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
if (treeObject instanceof MobilePageComponentTreeObject) {
DatabaseObject dbo = (DatabaseObject) treeObject.getObject();
ActionModel actionModel = DatabaseObjectsAction.selectionChanged(getClass().getName(), dbo);
action.setEnabled(actionModel.isEnabled);
}
}
use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.
the class DatabaseObjectCreateAction method run.
public void run() {
Display display = Display.getDefault();
Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
Shell shell = getParentShell();
shell.setCursor(waitCursor);
try {
TreeObject parentTreeObject = null;
DatabaseObject databaseObject = null;
ProjectExplorerView explorerView = getProjectExplorerView();
if (explorerView != null) {
parentTreeObject = explorerView.getFirstSelectedTreeObject();
if (parentTreeObject instanceof ObjectsFolderTreeObject) {
parentTreeObject = ((ObjectsFolderTreeObject) parentTreeObject).getParent();
databaseObject = (DatabaseObject) parentTreeObject.getObject();
} else {
databaseObject = (DatabaseObject) parentTreeObject.getObject();
}
NewObjectWizard newObjectWizard = new NewObjectWizard(databaseObject, databaseObjectClassName);
WizardDialog wzdlg = new WizardDialog(shell, newObjectWizard);
wzdlg.setPageSize(850, 650);
wzdlg.open();
int result = wzdlg.getReturnCode();
if ((result != Window.CANCEL) && (newObjectWizard.newBean != null)) {
postCreate(parentTreeObject, newObjectWizard.newBean);
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to create a new database object '" + databaseObjectClassName + "'!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.
the class DatabaseObjectIncreasePriorityAction method increasePriority.
private void increasePriority(TreeObject treeObject) throws EngineException {
int count = counter;
if (treeObject instanceof DatabaseObjectTreeObject) {
DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
DatabaseObject parent = databaseObject.getParent();
if (parent != null && parent instanceof IContainerOrdered) {
IContainerOrdered containerOrdered = (IContainerOrdered) parent;
while (count-- > 0) {
containerOrdered.increasePriority(databaseObject);
}
if (parent.hasChanged) {
TreeParent parentTreeObject = null;
TreeParent treeParent = treeObject.getParent();
if (treeParent instanceof FolderTreeObject) {
parentTreeObject = treeObject.getParent().getParent();
} else {
parentTreeObject = treeParent;
}
if (!treeNodesToUpdate.contains(parentTreeObject)) {
treeNodesToUpdate.add(parentTreeObject);
}
}
}
} else {
DatabaseObjectTreeObject databaseObjectTreeObject = null;
if (treeObject instanceof PropertyTableRowTreeObject) {
PropertyTableTreeObject propertyTableTreeObject = (PropertyTableTreeObject) treeObject.getParent();
while (count-- > 0) {
if ((treeObject = propertyTableTreeObject.moveRow((PropertyTableRowTreeObject) treeObject, true)) != null) {
databaseObjectTreeObject = (DatabaseObjectTreeObject) propertyTableTreeObject.getParent();
}
}
} else if (treeObject instanceof PropertyTableColumnTreeObject) {
PropertyTableRowTreeObject propertyTableRowTreeObject = (PropertyTableRowTreeObject) treeObject.getParent();
PropertyTableTreeObject propertyTableTreeObject = (PropertyTableTreeObject) propertyTableRowTreeObject.getParent();
while (count-- > 0) {
if ((treeObject = propertyTableRowTreeObject.moveColumn((PropertyTableColumnTreeObject) treeObject, true)) != null) {
databaseObjectTreeObject = (DatabaseObjectTreeObject) propertyTableTreeObject.getParent();
}
}
}
if (databaseObjectTreeObject != null) {
if (databaseObjectTreeObject.hasChanged()) {
DatabaseObjectTreeObject parentTreeObject = null;
TreeParent treeParent = databaseObjectTreeObject.getParent();
if (treeParent instanceof FolderTreeObject)
parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
else
parentTreeObject = (DatabaseObjectTreeObject) treeParent;
if (!treeNodesToUpdate.contains(parentTreeObject)) {
treeNodesToUpdate.add(parentTreeObject);
}
}
}
}
}
Aggregations