use of com.twinsoft.convertigo.beans.core.Transaction 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.Transaction 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.Transaction 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.Transaction in project convertigo by convertigo.
the class XmlSchemaBuilder method preBuildSchema.
private void preBuildSchema() throws EngineException {
try {
schema.setElementFormDefault(new XmlSchemaForm(project.getSchemaElementForm().name()));
schema.setAttributeFormDefault(new XmlSchemaForm(project.getSchemaElementForm().name()));
ConvertigoError.addXmlSchemaObjects(schema);
EngineStatistics.addXmlSchemaObjects(schema);
// static and read-only generation : references, transactions, sequences declaration
new WalkHelper() {
@Override
protected void walk(DatabaseObject databaseObject) throws Exception {
if (databaseObject instanceof ISchemaGenerator) {
// generate itself and add to the caller list
if (databaseObject instanceof ISchemaImportGenerator) {
// Import case
if (databaseObject instanceof ProjectSchemaReference) {
// done further in buildSchema
} else {
XmlSchemaImport schemaImport = ((ISchemaImportGenerator) databaseObject).getXmlSchemaObject(collection, schema);
if (schemaImport != null) {
SchemaMeta.setXmlSchemaObject(schema, databaseObject, schemaImport);
XmlSchemaUtils.add(schema, schemaImport);
}
}
} else if (databaseObject instanceof ISchemaIncludeGenerator) {
// Include case
if (databaseObject instanceof Transaction) {
XmlSchemaInclude schemaInclude = ((ISchemaIncludeGenerator) databaseObject).getXmlSchemaObject(collection, schema);
addSchemaIncludeObjects(databaseObject, schemaInclude.getSchema());
} else {
XmlSchemaInclude schemaInclude = ((ISchemaIncludeGenerator) databaseObject).getXmlSchemaObject(collection, schema);
SchemaMeta.setXmlSchemaObject(schema, databaseObject, schemaInclude);
XmlSchemaUtils.add(schema, schemaInclude);
}
} else if (databaseObject instanceof Sequence) {
// Sequence case
XmlSchemaElement element = ((Sequence) databaseObject).getXmlSchemaObject(collection, schema);
SchemaMeta.setXmlSchemaObject(schema, databaseObject, element);
XmlSchemaUtils.add(schema, element);
}
} else {
// doesn't generate schema, just deep walk
super.walk(databaseObject);
}
}
@Override
protected boolean before(DatabaseObject databaseObject, Class<? extends DatabaseObject> dboClass) {
// just walk references, transactions, sequences declaration
return Step.class.isAssignableFrom(dboClass) || Transaction.class.isAssignableFrom(dboClass) || Sequence.class.isAssignableFrom(dboClass) || Reference.class.isAssignableFrom(dboClass) || Connector.class.isAssignableFrom(dboClass);
}
protected void addSchemaIncludeObjects(DatabaseObject databaseObject, XmlSchema xmlSchema) {
if (xmlSchema != null) {
XmlSchemaObjectCollection c = xmlSchema.getItems();
Iterator<XmlSchemaObject> it = GenericUtils.cast(c.getIterator());
while (it.hasNext()) {
XmlSchemaObject xmlSchemaObject = it.next();
SchemaMeta.getReferencedDatabaseObjects(xmlSchemaObject).add(databaseObject);
if (xmlSchemaObject instanceof XmlSchemaImport) {
// ignore
} else if (xmlSchemaObject instanceof XmlSchemaInclude) {
XmlSchemaInclude schemaInclude = (XmlSchemaInclude) xmlSchemaObject;
addSchemaIncludeObjects(databaseObject, schemaInclude.getSchema());
} else if (xmlSchemaObject instanceof XmlSchemaAttribute) {
XmlSchemaAttribute attribute = (XmlSchemaAttribute) xmlSchemaObject;
if (schema.getAttributes().getItem(attribute.getQName()) == null) {
schema.getAttributes().add(attribute.getQName(), attribute);
schema.getItems().add(attribute);
}
} else if (xmlSchemaObject instanceof XmlSchemaAttributeGroup) {
XmlSchemaAttributeGroup attributeGroup = (XmlSchemaAttributeGroup) xmlSchemaObject;
if (schema.getAttributeGroups().getItem(attributeGroup.getName()) == null) {
schema.getAttributeGroups().add(attributeGroup.getName(), attributeGroup);
schema.getItems().add(attributeGroup);
}
} else if (xmlSchemaObject instanceof XmlSchemaGroup) {
XmlSchemaGroup group = (XmlSchemaGroup) xmlSchemaObject;
if (schema.getGroups().getItem(group.getName()) == null) {
schema.getGroups().add(group.getName(), group);
schema.getItems().add(group);
}
} else if (xmlSchemaObject instanceof XmlSchemaElement) {
XmlSchemaElement element = (XmlSchemaElement) xmlSchemaObject;
if (collection.getElementByQName(element.getQName()) == null && schema.getElementByName(element.getQName()) == null) {
schema.getElements().add(element.getQName(), element);
schema.getItems().add(element);
}
} else if (xmlSchemaObject instanceof XmlSchemaType) {
XmlSchemaType schemaType = (XmlSchemaType) xmlSchemaObject;
if (collection.getTypeByQName(schemaType.getQName()) == null && schema.getTypeByName(schemaType.getQName()) == null) {
schema.addType(schemaType);
schema.getItems().add(schemaType);
}
} else {
schema.getItems().add(xmlSchemaObject);
}
}
}
}
}.init(project);
} catch (Exception e) {
throw new EngineException("preBuildSchema failed", e);
}
}
use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.
the class List method getServiceResult.
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
HttpSession currentSession = request.getSession();
Element rootElement = document.getDocumentElement();
Element connectionsListElement = document.createElement("connections");
rootElement.appendChild(connectionsListElement);
Element sessionsListElement = document.createElement("sessions");
rootElement.appendChild(sessionsListElement);
Element contextsInUseElement = document.createElement("contextsInUse");
contextsInUseElement.setTextContent("" + Math.max(0, Engine.theApp.contextManager.getNumberOfContexts()));
rootElement.appendChild(contextsInUseElement);
Element contextsNumberElement = document.createElement("contextsNumber");
contextsNumberElement.setTextContent("" + EnginePropertiesManager.getProperty(PropertyName.CONVERTIGO_MAX_CONTEXTS));
rootElement.appendChild(contextsNumberElement);
Element sessionsInUseElement = document.createElement("sessionsInUse");
sessionsInUseElement.setTextContent("" + HttpSessionListener.countSessions());
rootElement.appendChild(sessionsInUseElement);
Element sessionsIsOverflowElement = document.createElement("sessionsIsOverflow");
sessionsIsOverflowElement.setTextContent(KeyManager.isOverflow(Session.EmulIDSE) ? "true" : "false");
rootElement.appendChild(sessionsIsOverflowElement);
Element sessionsNumberElement = document.createElement("sessionsNumber");
sessionsNumberElement.setTextContent("" + Math.max(0, KeyManager.getMaxCV(Session.EmulIDSE)));
rootElement.appendChild(sessionsNumberElement);
Element threadsInUseElement = document.createElement("threadsInUse");
threadsInUseElement.setTextContent("" + Math.max(0, com.twinsoft.convertigo.beans.core.RequestableObject.nbCurrentWorkerThreads));
rootElement.appendChild(threadsInUseElement);
Element threadsNumberElement = document.createElement("threadsNumber");
threadsNumberElement.setTextContent(EnginePropertiesManager.getProperty(PropertyName.DOCUMENT_THREADING_MAX_WORKER_THREADS));
rootElement.appendChild(threadsNumberElement);
Element httpTimeoutElement = document.createElement("httpTimeout");
httpTimeoutElement.setTextContent(formatTime(currentSession.getMaxInactiveInterval()));
rootElement.appendChild(httpTimeoutElement);
long now = System.currentTimeMillis();
Collection<Context> contexts = null;
String sessionToFilter = request.getParameter("session");
if (StringUtils.isNotBlank(sessionToFilter)) {
HttpSession session = HttpSessionListener.getHttpSession(sessionToFilter);
if (session != null) {
contexts = Engine.theApp.contextManager.getContexts(session);
}
}
if (contexts == null) {
contexts = Engine.theApp.contextManager.getContexts();
}
for (Context context : contexts) {
String authenticatedUser = null;
try {
authenticatedUser = context.getAuthenticatedUser();
} catch (Exception e) {
Engine.logAdmin.trace("connection.List failed to get the authenticated user: " + e);
}
com.twinsoft.api.Session apiSession = Engine.theApp.sessionManager.getSession(context.contextID);
boolean bConnected = ((apiSession != null) && apiSession.isConnected());
Element connectionElement = document.createElement("connection");
connectionElement.setAttribute("connected", Boolean.toString(bConnected));
connectionElement.setAttribute("contextName", context.contextID);
connectionElement.setAttribute("project", context.projectName);
connectionElement.setAttribute("connector", context.connectorName);
connectionElement.setAttribute("requested", (context.requestedObject instanceof Transaction) ? context.transactionName : context.sequenceName);
connectionElement.setAttribute("status", (context.requestedObject == null || context.requestedObject.runningThread == null ? "finished" : (context.requestedObject.runningThread.bContinue ? "in progress" : "finished")) + "(" + context.waitingRequests + ")");
connectionElement.setAttribute("user", authenticatedUser == null ? "" : authenticatedUser);
connectionElement.setAttribute("contextCreationDate", DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date(context.creationTime)));
connectionElement.setAttribute("lastContextAccessDate", DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date(context.lastAccessTime)));
try {
connectionElement.setAttribute("contextInactivityTime", formatTime((now - context.lastAccessTime) / 1000) + " / " + formatTime(Engine.theApp.databaseObjectsManager.getOriginalProjectByName(context.projectName).getContextTimeout()));
} catch (Exception e) {
// TODO: document = DOMUtils.handleError(e); << USELESS
}
connectionElement.setAttribute("clientComputer", context.remoteHost + " (" + context.remoteAddr + "), " + context.userAgent);
connectionsListElement.appendChild(connectionElement);
}
if (!"false".equals(request.getParameter("sessions"))) {
for (HttpSession session : HttpSessionListener.getSessions()) {
Element sessionElement = document.createElement("session");
java.util.List<Context> ctxs = Engine.theApp.contextManager.getContexts(session);
sessionElement.setAttribute("sessionID", session.getId());
sessionElement.setAttribute("authenticatedUser", SessionAttribute.authenticatedUser.string(session));
sessionElement.setAttribute("contexts", Integer.toString(ctxs == null ? 0 : ctxs.size()));
sessionElement.setAttribute("clientIP", SessionAttribute.clientIP.string(session));
sessionElement.setAttribute("deviceUUID", SessionAttribute.deviceUUID.string(session));
sessionElement.setAttribute("lastSessionAccessDate", DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date(session.getLastAccessedTime())));
sessionElement.setAttribute("sessionInactivityTime", formatTime((now - session.getLastAccessedTime()) / 1000) + " / " + formatTime(session.getMaxInactiveInterval()));
Role[] r = (Role[]) session.getAttribute(SessionKey.ADMIN_ROLES.toString());
sessionElement.setAttribute("adminRoles", Integer.toString(r == null ? 0 : r.length));
if (session == currentSession) {
sessionElement.setAttribute("isCurrentSession", "true");
}
Set<HttpServletRequest> set = SessionAttribute.fullSyncRequests.get(session);
sessionElement.setAttribute("isFullSyncActive", Boolean.toString(set != null && !set.isEmpty()));
sessionsListElement.appendChild(sessionElement);
}
}
}
Aggregations