use of com.tinkerpop.frames.modules.javahandler.JavaFrameInitializer in project org.openntf.domino by OpenNTF.
the class DFramedTransactionalGraph method frame.
@Override
@Deprecated
public <F> F frame(final Edge edge, final Direction direction, final Class<F> kind) {
DConfiguration config = (DConfiguration) this.getConfig();
Class<F> klazz = (Class<F>) (kind == null ? DEdgeFrame.class : kind);
config.getTypeManager().initElement(klazz, this, edge);
for (FrameInitializer initializer : getConfig().getFrameInitializers()) {
if (!(initializer instanceof JavaFrameInitializer)) {
initializer.initElement(klazz, this, edge);
}
}
F result = super.frame(edge, direction, klazz);
for (FrameInitializer initializer : getConfig().getFrameInitializers()) {
if (initializer instanceof JavaFrameInitializer) {
((JavaFrameInitializer) initializer).initElement(klazz, this, result);
}
}
return result;
}
use of com.tinkerpop.frames.modules.javahandler.JavaFrameInitializer in project org.openntf.domino by OpenNTF.
the class DFramedTransactionalGraph method frame.
public <F> F frame(final Vertex vertex, Class<F> kind, final boolean temporary) {
if (vertex == null) {
return null;
}
if (vertex instanceof DCategoryVertex) {
kind = (Class<F>) CategoryVertex.class;
} else {
Map map = ((DVertex) vertex).getDelegate();
if (map instanceof Document) {
if (DesignFactory.isView((Document) map)) {
kind = (Class<F>) ViewVertex.class;
}
if (DesignFactory.isIcon((Document) map) || DesignFactory.isACL((Document) map)) {
// System.out.println("TEMP DEBUG framing an icon note");
kind = (Class<F>) DbInfoVertex.class;
}
}
}
DConfiguration config = (DConfiguration) this.getConfig();
Class<F> klazz = (Class<F>) (kind == null ? config.getDefaultVertexFrameType() : kind);
if (config.getReplacementType(klazz) != null) {
klazz = (Class<F>) config.getReplacementType(klazz);
}
DTypeManager manager = config.getTypeManager();
klazz = (Class<F>) manager.initElement(klazz, this, vertex, temporary);
for (FrameInitializer initializer : getConfig().getFrameInitializers()) {
if (!(initializer instanceof JavaFrameInitializer)) {
initializer.initElement(klazz, this, vertex);
}
}
F result = null;
try {
result = super.frame(vertex, klazz);
} catch (Throwable t) {
System.out.println("Exception while attempting to frame a vertex " + vertex.getId() + " with class " + klazz.getName());
t.printStackTrace();
// DominoUtils.handleException(e);
try {
result = (F) super.frame(vertex, config.getDefaultVertexFrameType());
} catch (Exception e) {
System.out.println("Exception while attempting to frame a vertex " + vertex.getId() + " with class " + klazz.getName());
e.printStackTrace();
DominoUtils.handleException(e);
}
}
for (FrameInitializer initializer : getConfig().getFrameInitializers()) {
if (initializer instanceof JavaFrameInitializer) {
((JavaFrameInitializer) initializer).initElement(klazz, this, result);
}
}
if (vertex instanceof DProxyVertex) {
List<CaseInsensitiveString> proxied = config.getTypeRegistry().getProxied(klazz);
if (proxied != null) {
((DProxyVertex) vertex).setProxied(proxied);
}
}
if (result instanceof Eventable) {
if (((Eventable) result).isNew()) {
try {
// $NON-NLS-1$
Method crystal = result.getClass().getMethod("create");
if (crystal != null) {
((Eventable) result).create();
}
} catch (Throwable t) {
// nothing
}
} else {
// try {
// Method crystal = result.getClass().getMethod("read", null);
// if (crystal != null) {
// ((Eventable) result).read();
// }
// } catch (Throwable t) {
// //nothing
// }
}
}
return result;
}
use of com.tinkerpop.frames.modules.javahandler.JavaFrameInitializer in project org.openntf.domino by OpenNTF.
the class DFramedTransactionalGraph method frame.
@Override
@SuppressWarnings("deprecation")
public <F> F frame(final Edge edge, final Class<F> kind) {
if (edge == null) {
return null;
}
DConfiguration config = (DConfiguration) this.getConfig();
Class<F> klazz = (Class<F>) (kind == null ? config.getDefaultEdgeFrameType() : kind);
if (config.getReplacementType(klazz) != null) {
klazz = (Class<F>) config.getReplacementType(klazz);
}
DTypeManager manager = config.getTypeManager();
klazz = (Class<F>) manager.initElement(klazz, this, edge, false);
for (FrameInitializer initializer : getConfig().getFrameInitializers()) {
if (!(initializer instanceof JavaFrameInitializer)) {
initializer.initElement(klazz, this, edge);
}
}
F result = null;
try {
result = super.frame(edge, Direction.OUT, klazz);
} catch (Throwable t) {
System.out.println("Exception while attempting to frame a edge " + edge.getId() + " with class " + klazz.getName());
t.printStackTrace();
try {
result = (F) super.frame(edge, Direction.OUT, config.getDefaultEdgeFrameType());
} catch (Exception e) {
System.out.println("Exception while attempting to frame a edge " + edge.getId() + " with class " + klazz.getName());
e.printStackTrace();
DominoUtils.handleException(e);
}
}
for (FrameInitializer initializer : getConfig().getFrameInitializers()) {
if (initializer instanceof JavaFrameInitializer) {
((JavaFrameInitializer) initializer).initElement(klazz, this, result);
}
}
return result;
}
Aggregations