0

Neo4j - 2.0.0.5M OS - Ubuntu 12.04LTS

有効な関係を削除する際に問題に直面しています。試してみると、「トランザクションがロールバック用にマークされました」という例外がスローされます。どこが間違っているのか..

ここにコードがあります

@Name( "acceptLogicalFilter" )
@Description( "Through this function user accepts logical filters" )
@PluginTarget( GraphDatabaseService.class )
public  String acceptLogicalFilter( @Source GraphDatabaseService graphDb , @Parameter( name = "arguments" ) String filterInsertData)
{       
    JsonObject filterInsertValues = MyUtils.getJsonObject(filterInsertData);

    // ReturnMe
    Map<Object , Object> returnMe = new HashMap<Object, Object>();

    // get graph  IT IS MY REUSABLE CLASSES
    getGraph = new GetGraph(graphDb);
    setGraph = new SetGraph(graphDb);

    long userId = filterInsertValues.get("userId").getAsLong();
    long filterId = filterInsertValues.get("filterId").getAsLong();
    String filterValue = filterInsertValues.get("filterValue").getAsString();

    Transaction txFilterInsert = graphDb.beginTx();

    try {

        // Take filter node with given filterId
        Iterator<Node> filterIterator = getGraph.getNodesInIndex(GetGraph.IndexName.indexFilter, "indexType", "filter");
        Node myFilterNode = null;
        Node myUserNode = null;

            // HERE DETERMINE FILTERNODE FOR GIVEN FILTER ID .. FILTER ID IS a Property in filterNode
        while (filterIterator.hasNext()) {

            myFilterNode = (Node) filterIterator.next();

            if ((long)myFilterNode.getProperty("filterId") == filterId) {

                break;
            }

        } // while close

        // Take userNode with given userId

        Iterator<Node> userIterator = getGraph.getNodesInIndex(GetGraph.IndexName.indexUser, "indexType", "user");

            // TAKE USERNODE FOR GIVEN USER ID 

        while (userIterator.hasNext()) {
            myUserNode = (Node) userIterator.next();

            if ((long)myUserNode.getProperty("userId") == userId) {

                break;
            }
        } // while close


        // Now filter_ref_pending relationship between myUserNode and myFilterNode

        // TODO: To identify relationship to delete between given user and filter is costly. Need to optimize
            // Done : Now instead of taking all realtionships from filterNode , taking relationships from usernode pointing toward given
            filter


  Iterable<Relationship> relationShipIterator =   
   myUserNode.getRelationships(Direction.INCOMING,   
      GetGraph.RelationshipTypes.filter_ref_user_pending);

        Iterator<Relationship> it = relationShipIterator.iterator();

        // Now find the relationship whose end node is given myUserNode

        Relationship myRelationship = null;
        while (it.hasNext()) {
            myRelationship = it.next();

            if (myRelationship.getStartNode().getProperty("filterId") == myFilterNode.getProperty("filterId")) {

                break;
            }
        } // while close

        // Now delete relationship 

   // HERE DELETE RELATIONSHIP CAUSING ME PROBLEM . YES I AM GETTING LEGITIMATE RELATIONSHIP (REL:11943) BETWEEN FILTER NODE AND USER NODE


        if (myRelationship != null) {
            myRelationship.delete(); ------------ THROWS EXCEPTION : TRANSACTION MARKED FOR ROLLBACK.
        }
4

0 に答える 0