Search in sources :

Example 6 with NoteCoordinate

use of org.openntf.domino.big.NoteCoordinate in project org.openntf.domino by OpenNTF.

the class DElementStore method getElement.

@Override
public Element getElement(final Object id) throws IllegalStateException {
    try {
        // if (isProxied()) {
        // System.out.println("Getting a proxied element for id: " + String.valueOf(id));
        // }
        NoteCoordinate nc = normalizeId((Serializable) id);
        Element result = null;
        // if (nc.getReplicaId().equalsIgnoreCase("852582F7007073B5")) {
        // System.out.println("Getting a demo document " + nc + " from the element cache");
        // result = getElementCache().get(nc);
        // if (result != null) {
        // System.out.println(
        // "Result was loaded from cache with id " + nc + " and cache now has " + getElementCache().size() + " elements");
        // 
        // }
        // } else {
        result = getElementCache().get(nc);
        // + System.identityHashCode(result));
        return result;
    } catch (InvalidCacheLoadException icle) {
        // "TEMP DEBUG invalidCacheLoad for id " + String.valueOf(id) + " from element store " + System.identityHashCode(this));
        return null;
    } catch (UncheckedExecutionException uee) {
        Throwable cause = uee.getCause();
        if (cause != null && cause instanceof UserAccessException) {
            throw new UserAccessException(cause.getMessage(), cause);
        } else {
            throw uee;
        }
    } catch (UserAccessException uae) {
        throw uae;
    } catch (Throwable t) {
        throw new IllegalStateException("Unable to retrieve id " + String.valueOf(id), t);
    }
}
Also used : NoteCoordinate(org.openntf.domino.big.NoteCoordinate) InvalidCacheLoadException(com.google.common.cache.CacheLoader.InvalidCacheLoadException) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) Element(com.tinkerpop.blueprints.Element) UserAccessException(org.openntf.domino.exceptions.UserAccessException)

Example 7 with NoteCoordinate

use of org.openntf.domino.big.NoteCoordinate in project org.openntf.domino by OpenNTF.

the class DElementStore method flushCache.

@Override
public void flushCache(final String id) {
    // }
    try {
        if (keyMap_ != null && keyMap_.containsKey(id)) {
            keyMap_.remove(id);
        }
    } catch (Throwable t) {
        t.printStackTrace();
    }
    try {
        if (this.getElementCache() != null) {
            NoteCoordinate nc = NoteCoordinate.Utils.getNoteCoordinate(id);
            Object chk = getElementCache().getIfPresent(nc);
            if (chk != null) {
                // getElementCache().refresh(nc);
                getElementCache().invalidate(nc);
            // System.out.println("TEMP DEBUG Invalidated id " + nc + " in Element Store");
            } else {
            // if (id.startsWith("852582F7007073B5".toLowerCase())) {
            // System.out.println("TEMP DEBUG id " + nc + " not found in cache");
            // System.out.println("TEMP DEBUG cache has " + getElementCache().size() + " elements");
            // if (getElementCache().size() < 6) {
            // //							getElementCache().asMap()
            // }
            // }
            }
        } else {
            System.out.println("Element Cache not available!");
        }
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
Also used : NoteCoordinate(org.openntf.domino.big.NoteCoordinate)

Example 8 with NoteCoordinate

use of org.openntf.domino.big.NoteCoordinate in project org.openntf.domino by OpenNTF.

the class DElementStore method getVertexIds.

protected List<NoteCoordinate> getVertexIds(final String formulaFilter) {
    FastTable<NoteCoordinate> result = new FastTable<NoteCoordinate>();
    Object raw = getStoreDelegate();
    if (raw instanceof Database) {
        Database db = (Database) raw;
        NoteCollection nc = db.createNoteCollection(false);
        nc.setSelectDocuments(true);
        nc.setSelectionFormula(formulaFilter);
        nc.buildCollection();
        for (String noteid : nc) {
            result.add(NoteCoordinate.Utils.getNoteCoordinate(nc, noteid));
        }
    } else {
        // TODO NTF implement alternative
        throw new IllegalStateException("Non-Domino implementations not yet available");
    }
    return result;
}
Also used : NoteCoordinate(org.openntf.domino.big.NoteCoordinate) NoteCollection(org.openntf.domino.NoteCollection) FastTable(javolution.util.FastTable) Database(org.openntf.domino.Database)

Example 9 with NoteCoordinate

use of org.openntf.domino.big.NoteCoordinate in project org.openntf.domino by OpenNTF.

the class DFastEdgeList method findEdge.

@SuppressWarnings("unlikely-arg-type")
@Override
public Edge findEdge(final Vertex toVertex) {
    Edge result = null;
    Object toId = toVertex.getId();
    Object fromId = sourceVertex_.getId();
    if (isUnique() && !isEmpty()) {
        if (toId instanceof NoteCoordinate && fromId instanceof NoteCoordinate) {
            String toString = ((NoteCoordinate) toId).toString();
            String fromString = ((NoteCoordinate) fromId).toString();
            String testString1 = DominoUtils.toUnid(toString + getLabel() + fromString);
            String testString2 = DominoUtils.toUnid(toString + getLabel() + fromString);
            NoteCoordinate nc1 = NoteCoordinate.Utils.getNoteCoordinate(storeid_, testString1);
            NoteCoordinate nc2 = NoteCoordinate.Utils.getNoteCoordinate(storeid_, testString2);
            if (contains(nc1)) {
                result = parentGraph_.getEdge(nc1);
            } else if (contains(nc2)) {
                result = parentGraph_.getEdge(nc2);
            }
        } else {
        // NTF then we go back to the old way...
        }
    }
    if (result == null && this.size() > 0 && !isUnique()) {
        for (Edge edge : this) {
            if (edge instanceof DEdge) {
                DEdge dedge = (DEdge) edge;
                if (toId.equals(dedge.getOtherVertexId(sourceVertex_))) {
                    result = dedge;
                    break;
                }
            } else {
                if (edge != null) {
                    Vertex inVertex = edge.getVertex(Direction.IN);
                    if (fromId.equals(inVertex.getId())) {
                        if (toId.equals(edge.getVertex(Direction.OUT))) {
                            result = edge;
                            break;
                        }
                    } else if (toId.equals(inVertex.getId())) {
                        result = edge;
                        break;
                    }
                }
            }
        }
    } else {
    // System.out.println("DEBUG: No edges defined in EdgeList");
    }
    return result;
}
Also used : NoteCoordinate(org.openntf.domino.big.NoteCoordinate) Vertex(com.tinkerpop.blueprints.Vertex) Edge(com.tinkerpop.blueprints.Edge)

Example 10 with NoteCoordinate

use of org.openntf.domino.big.NoteCoordinate in project org.openntf.domino by OpenNTF.

the class DFastEdgeList method add.

@Override
public void add(final int arg0, final Edge arg1) {
    NoteCoordinate nc = getNC(arg1);
    if (storeid_ == null) {
        storeid_ = nc.getReplicaId();
    }
    delegate_.add(arg0, nc);
}
Also used : NoteCoordinate(org.openntf.domino.big.NoteCoordinate)

Aggregations

NoteCoordinate (org.openntf.domino.big.NoteCoordinate)31 CaseInsensitiveString (org.openntf.domino.types.CaseInsensitiveString)9 Database (org.openntf.domino.Database)8 ArrayList (java.util.ArrayList)7 LinkedHashMap (java.util.LinkedHashMap)7 UserAccessException (org.openntf.domino.exceptions.UserAccessException)7 JsonJavaObject (com.ibm.commons.util.io.json.JsonJavaObject)6 Element (com.tinkerpop.blueprints.Element)6 VertexFrame (com.tinkerpop.frames.VertexFrame)6 HashMap (java.util.HashMap)6 NoteCollection (org.openntf.domino.NoteCollection)6 JsonException (com.ibm.commons.util.io.json.JsonException)5 Edge (com.tinkerpop.blueprints.Edge)5 EdgeFrame (com.tinkerpop.frames.EdgeFrame)5 IOException (java.io.IOException)5 WebApplicationException (javax.ws.rs.WebApplicationException)5 DVertexFrame (org.openntf.domino.graph2.builtin.DVertexFrame)5 List (java.util.List)4 FastTable (javolution.util.FastTable)4 Document (org.openntf.domino.Document)4