Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/DescribePackageIndication.java')
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/DescribePackageIndication.java110
1 files changed, 110 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/DescribePackageIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/DescribePackageIndication.java
new file mode 100644
index 0000000000..7764255db4
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/DescribePackageIndication.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.cdo.server.protocol;
+
+
+import org.eclipse.net4j.core.impl.AbstractIndicationWithResponse;
+
+import org.eclipse.emf.cdo.core.CdoProtocol;
+import org.eclipse.emf.cdo.server.AttributeInfo;
+import org.eclipse.emf.cdo.server.CdoServerProtocol;
+import org.eclipse.emf.cdo.server.ClassInfo;
+import org.eclipse.emf.cdo.server.Mapper;
+import org.eclipse.emf.cdo.server.PackageInfo;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+
+public class DescribePackageIndication extends AbstractIndicationWithResponse
+{
+ private List infos;
+
+ public short getSignalId()
+ {
+ return CdoProtocol.DESCRIBE_PACKAGE;
+ }
+
+ public void indicate()
+ {
+ int pid = getMapper().getNextPid();
+ String packageName = receiveString();
+ if (isDebugEnabled()) debug("Described package " + packageName);
+
+ PackageInfo packageInfo = getMapper().getPackageManager().addPackage(pid, packageName);
+ getMapper().insertPackage(packageInfo);
+
+ infos = receiveClasses(packageInfo);
+ getMapper().createAttributeTables(packageInfo);
+ }
+
+ public void respond()
+ {
+ transmitInt(infos.size());
+
+ for (Iterator iter = infos.iterator(); iter.hasNext();)
+ {
+ ClassInfo classInfo = (ClassInfo) iter.next();
+ if (isDebugEnabled())
+ debug("Responding class " + classInfo.getName() + " = " + classInfo.getCid());
+
+ transmitInt(classInfo.getCid());
+ transmitString(classInfo.getName());
+ }
+ }
+
+ private List receiveClasses(PackageInfo packageInfo)
+ {
+ List result = new ArrayList();
+ int count = receiveInt();
+
+ for (int i = 0; i < count; i++)
+ {
+ int cid = getMapper().getNextCid();
+ String name = receiveString();
+ String parentName = receiveString();
+ String tableName = receiveString();
+ if (isDebugEnabled()) debug("Described class " + name);
+
+ ClassInfo classInfo = packageInfo.addClass(cid, name, parentName, tableName);
+ getMapper().insertClass(classInfo);
+ receiveAttributes(classInfo);
+
+ result.add(classInfo);
+ }
+
+ return result;
+ }
+
+ private void receiveAttributes(ClassInfo classInfo)
+ {
+ int count = receiveInt();
+ for (int i = 0; i < count; i++)
+ {
+ String name = receiveString();
+ int featureId = receiveInt();
+ int dataType = receiveInt();
+ String columnName = receiveString();
+ int columnType = receiveInt();
+ if (isDebugEnabled()) debug("Described attribute " + name);
+
+ AttributeInfo attributeInfo = classInfo.addAttribute(name, featureId, dataType, columnName,
+ columnType);
+ getMapper().insertAttribute(attributeInfo, classInfo.getCid());
+ }
+ }
+
+ private Mapper getMapper()
+ {
+ return ((CdoServerProtocol) getProtocol()).getMapper();
+ }
+}

Back to the top