Skip to content
This repository has been archived by the owner on Feb 22, 2019. It is now read-only.

Commit

Permalink
Commit all changes before repo transfer.
Browse files Browse the repository at this point in the history
  • Loading branch information
pvlasov committed May 18, 2014
1 parent 5c40833 commit 29c0f85
Show file tree
Hide file tree
Showing 90 changed files with 2,323 additions and 239 deletions.
2 changes: 1 addition & 1 deletion org.nasdanika.cdo.h2/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Nasdanika CDO H2 Repository Provider
Bundle-SymbolicName: org.nasdanika.cdo.h2
Bundle-Version: 1.0.0.qualifier
Bundle-Version: 0.1.0.qualifier
Bundle-Vendor: Nasdanika
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Require-Bundle: org.eclipse.net4j.db.h2;bundle-version="4.0.100",
Expand Down
2 changes: 1 addition & 1 deletion org.nasdanika.cdo.h2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.nasdanika</groupId>
<artifactId>org.nasdanika.parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.1.0-SNAPSHOT</version>
<relativePath>../org.nasdanika.parent</relativePath>
</parent>
</project>
5 changes: 3 additions & 2 deletions org.nasdanika.cdo/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Nasdanika CDO components
Bundle-SymbolicName: org.nasdanika.cdo;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Version: 0.1.0.qualifier
Bundle-Vendor: Nasdanika
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Require-Bundle: org.eclipse.emf.cdo.server;bundle-version="4.1.1",
Expand All @@ -13,7 +13,8 @@ Require-Bundle: org.eclipse.emf.cdo.server;bundle-version="4.1.1",
org.eclipse.emf.cdo.net4j;bundle-version="4.1.0",
org.eclipse.emf.cdo,
org.json;bundle-version="1.0.0",
org.nasdanika.web;bundle-version="1.0.0";visibility:=reexport
org.nasdanika.web;bundle-version="0.1.0";visibility:=reexport,
org.nasdanika.thirdparty;bundle-version="1.0.0"
Export-Package: org.nasdanika.cdo,
org.nasdanika.cdo.convert,
org.nasdanika.cdo.web,
Expand Down
83 changes: 81 additions & 2 deletions org.nasdanika.cdo/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,31 @@
target="org.eclipse.emf.cdo.view.CDOView">
</extension_route>
<extension_route
class="org.nasdanika.cdo.web.routes.CDOViewHtmlExtensionRoute"
class="org.nasdanika.cdo.web.routes.HtmlExtensionGetRoute"
extension="html"
method="GET"
target="org.eclipse.emf.cdo.view.CDOView">
target="java.lang.Object">
</extension_route>
<object_route
class="org.nasdanika.cdo.web.routes.EObjectRoute"
method="*"
target="org.eclipse.emf.ecore.EObject">
</object_route>
<object_route
class="org.nasdanika.cdo.web.routes.EReferenceClosureRoute"
method="*"
target="org.nasdanika.cdo.EReferenceClosure">
</object_route>
<object_route
class="org.nasdanika.cdo.web.routes.EAttributeClosureRoute"
method="*"
target="org.nasdanika.cdo.EAttributeClosure">
</object_route>
<extension_route
class="org.nasdanika.cdo.web.routes.EObjectXMIExportRoute"
extension="xml"
method="GET"
target="org.eclipse.emf.ecore.EObject">
</extension_route>

</extension>
Expand All @@ -59,6 +80,64 @@
source="org.eclipse.emf.cdo.view.CDOView"
target="org.nasdanika.web.html.HTMLRenderer">
</converter>
<converter
class="org.nasdanika.cdo.web.html.CDOResourceToHTMLRendererConverter"
source="org.eclipse.emf.cdo.eresource.CDOResource"
target="org.nasdanika.web.html.HTMLRenderer">
</converter>
<converter
class="org.nasdanika.cdo.web.html.CDOResourceFolderToHTMLRendererConverter"
source="org.eclipse.emf.cdo.eresource.CDOResourceFolder"
target="org.nasdanika.web.html.HTMLRenderer">
</converter>
<converter
class="org.nasdanika.cdo.web.html.EObjectToHTMLRendererConverter"
source="org.eclipse.emf.ecore.EObject"
target="org.nasdanika.web.html.HTMLRenderer">
</converter>
<converter
class="org.nasdanika.cdo.web.html.EPackageToHTMLRendererConverter"
source="org.eclipse.emf.ecore.EPackage"
target="org.nasdanika.web.html.HTMLRenderer">
</converter>
<converter
class="org.nasdanika.cdo.web.html.ENamedElementToHTMLRendererConverter"
source="org.eclipse.emf.ecore.ENamedElement"
target="org.nasdanika.web.html.HTMLRenderer">
</converter>
<converter
class="org.nasdanika.cdo.web.html.EStructuralFeatureToHTMLRendererConverter"
source="org.eclipse.emf.ecore.EStructuralFeature"
target="org.nasdanika.web.html.HTMLRenderer">
</converter>
<converter
class="org.nasdanika.cdo.web.html.EReferenceClosureToHTMLRendererConverter"
source="org.nasdanika.cdo.EReferenceClosure"
target="org.nasdanika.web.html.HTMLRenderer">
</converter>
</extension>
<extension
point="org.nasdanika.web.object_path_resolver">
<resolver
class="org.nasdanika.cdo.web.objectpathresolvers.EObjectPathResolver"
target="org.eclipse.emf.ecore.EObject">
</resolver>
<resolver
class="org.nasdanika.cdo.web.objectpathresolvers.CDOResourcePathResolver"
target="org.eclipse.emf.cdo.eresource.CDOResource">
</resolver>
<resolver
class="org.nasdanika.cdo.web.objectpathresolvers.EPackagePathResolver"
target="org.eclipse.emf.ecore.EPackage">
</resolver>
<resolver
class="org.nasdanika.cdo.web.objectpathresolvers.EClassifierPathResolver"
target="org.eclipse.emf.ecore.EClassifier">
</resolver>
<resolver
class="org.nasdanika.cdo.web.objectpathresolvers.EStructuralFeatureClosurePathResolver"
target="org.nasdanika.cdo.EStructuralFeatureClosure">
</resolver>
</extension>

</plugin>
2 changes: 1 addition & 1 deletion org.nasdanika.cdo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.nasdanika</groupId>
<artifactId>org.nasdanika.parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.1.0-SNAPSHOT</version>
<relativePath>../org.nasdanika.parent</relativePath>
</parent>
</project>
12 changes: 8 additions & 4 deletions org.nasdanika.cdo/src/org/nasdanika/cdo/EAttributeClosure.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;

public class EAttributeClosure implements EStructuralFeatureClosure<EObject, EAttribute> {
public class EAttributeClosure<O extends EObject> implements EStructuralFeatureClosure<O, EAttribute> {

private EAttribute attr;
private EObject obj;
private O obj;

public EAttributeClosure(EObject obj, EAttribute attr) {
public EAttributeClosure(O obj, EAttribute attr) {
super();
this.obj = obj;
this.attr = attr;
}

@Override
public EObject getObject() {
public O getObject() {
return obj;
}

Expand All @@ -24,5 +24,9 @@ public EAttribute getFeature() {
return attr;
}

@Override
public Object getValue() {
return obj.eGet(attr);
}

}
14 changes: 9 additions & 5 deletions org.nasdanika.cdo/src/org/nasdanika/cdo/EReferenceClosure.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;

public class EReferenceClosure implements EStructuralFeatureClosure<EObject, EReference> {
public class EReferenceClosure<O extends EObject> implements EStructuralFeatureClosure<O, EReference> {

private EReference ref;
private EObject obj;
private O obj;

public EReferenceClosure(EObject obj, EReference ref) {
public EReferenceClosure(O obj, EReference ref) {
super();
this.obj = obj;
this.ref = ref;
}

@Override
public EObject getObject() {
public O getObject() {
return obj;
}

Expand All @@ -24,5 +24,9 @@ public EReference getFeature() {
return ref;
}


@Override
public Object getValue() {
return obj.eGet(ref);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ public interface EStructuralFeatureClosure<O extends EObject, F extends EStructu
O getObject();

F getFeature();

Object getValue();

}
57 changes: 57 additions & 0 deletions org.nasdanika.cdo/src/org/nasdanika/cdo/util/NasdanikaCDOUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package org.nasdanika.cdo.util;

import org.apache.commons.lang3.StringEscapeUtils;
import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.ecore.util.EcoreUtil;

public class NasdanikaCDOUtil {

private static final String HTML_CLOSE_TAG = "</html>";
private static final String HTML_OPEN_TAG = "<html>";

private NasdanikaCDOUtil() {
// Singleton
}


public static String stripExtension(String str) {
int idx = str.lastIndexOf('.');
return idx==-1 ? str : str.substring(0, idx);
}

public static String getDocumentation(EModelElement modelElement) {
String doc = EcoreUtil.getDocumentation(modelElement);
if (doc==null) {
return "&nbsp;";
}
String trimmedDoc = doc.trim();
if (trimmedDoc.startsWith(HTML_OPEN_TAG) && trimmedDoc.endsWith(HTML_CLOSE_TAG)) {
return trimmedDoc.substring(HTML_OPEN_TAG.length(), trimmedDoc.length()-HTML_CLOSE_TAG.length());
}

return "<pre>"+StringEscapeUtils.escapeHtml4(doc)+"</pre>";
}

/**
* Returns first sentence (till first dot) of the documentation.
* @param modelElement
* @return
*/
public static String getSummary(EModelElement modelElement) {
String doc = EcoreUtil.getDocumentation(modelElement);
if (doc==null) {
return "&nbsp;";
}
String trimmedDoc = doc.trim();
if (trimmedDoc.startsWith(HTML_OPEN_TAG) && trimmedDoc.endsWith(HTML_CLOSE_TAG)) {
String htmlDoc = trimmedDoc.substring(HTML_OPEN_TAG.length(), trimmedDoc.length()-HTML_CLOSE_TAG.length());
int idx = htmlDoc.indexOf(".");
return idx==-1 ? htmlDoc : htmlDoc.substring(0, idx+1);
}

String escapedDoc = StringEscapeUtils.escapeHtml4(doc);
int idx = escapedDoc.indexOf(".");
return idx==-1 ? "<pre>"+escapedDoc+"</pre>" : escapedDoc.substring(0, idx+1);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public Action execute(WebContext context) throws Exception {
httpContext.getPath(),
httpContext.getTarget(),
httpContext.getExtensionManager(),
null,
httpContext.getRequest(),
httpContext.getResponse(),
httpContext.getContextURL(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package org.nasdanika.cdo.web;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.nasdanika.cdo.CDOTransactionContext;
import org.nasdanika.web.ExtensionManager;
import org.nasdanika.web.HttpContextImpl;
import org.nasdanika.web.TraceEntry;
import org.nasdanika.web.WebContext;

public class CDOTransactionHttpContextImpl extends HttpContextImpl implements CDOTransactionHttpContext {
Expand All @@ -18,12 +21,13 @@ public CDOTransactionHttpContextImpl(
String[] path,
Object target,
ExtensionManager extensionManager,
List<TraceEntry> pathTrace,
HttpServletRequest req,
HttpServletResponse resp,
String contextURL,
CDOTransactionContext transactionContext) throws Exception {

super(principal, path, target, extensionManager, req, resp, contextURL);
super(principal, path, target, extensionManager, pathTrace, req, resp, contextURL);
this.transactionContext = transactionContext;
}

Expand All @@ -34,6 +38,7 @@ protected WebContext createSubContext(String[] subPath, Object target) throws Ex
subPath,
target,
getExtensionManager(),
getPathTrace(),
getRequest(),
getResponse(),
subContextURL(subPath, true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,26 @@ public Object execute() throws Exception {
protected CDOViewHttpContextImpl mergeContexts(WebContext webContext, CDOViewContext context) throws Exception {
if (webContext instanceof HttpContextImpl) {
HttpContextImpl httpContext = (HttpContextImpl) webContext;
return new CDOViewHttpContextImpl(
CDOViewHttpContextImpl mergedContext = new CDOViewHttpContextImpl(
httpContext.getPrincipal(),
httpContext.getPath(),
httpContext.getTarget(),
httpContext.getExtensionManager(),
null,
httpContext.getRequest(),
httpContext.getResponse(),
httpContext.getContextURL(),
context);

String viewPath = httpContext.getPath()[0];
int idx = viewPath.lastIndexOf('.');
if (idx!=-1) {
viewPath = viewPath.substring(0, idx);
}

mergedContext.getRootObjectsPaths().put(context.getView(), httpContext.getContextURL()+"/"+viewPath);

return mergedContext;
}
throw new IllegalArgumentException("Unsupported context type: "+context);
}
Expand Down
Loading

0 comments on commit 29c0f85

Please sign in to comment.