public static void DeleteBrandDescriptionNode(BrandDescription objNode) { Logger.WriteToLogFile(DBInteractor.Common.Utilities.GetCurrentMethod()); Neo4jController.m_graphClient.Cypher .Match("(C:" + objNode.getLabel() + "{ id : { Nodeid }})") .Match("(C)-[R]-()") .OptionalMatch("(D)-[:" + Rel_Brand.brand_brandDescription + "]->(C)") .Delete("C,R") .With("D") .Match("(D)-[R]-()") .OptionalMatch("(D)-[:" + Rel_Brand.brand_item + "]->(E)") .Delete("D,R") .With("E") .Match("(E)-[R]-()") .OptionalMatch("(F)-[:" + Rel_Item.item_itemDescription + "]->(E)") .Delete("E,R") .With("F") .Match("(F)-[R]-()") .Delete("F,R") .WithParams(new { Nodeid = objNode.id }) .ExecuteWithoutResults(); }
public static void CreateBrandNode(BrandWrapper objWrap) { Logger.WriteToLogFile(DBInteractor.Common.Utilities.GetCurrentMethod()); Logger.WriteObjectToLogFile <Brand>(objWrap.objBrand); Brand objBrand = objWrap.objBrand; SubCategory objSubCategory = objWrap.objSubCategory; BrandDescription objbrandDesc = new BrandDescription(); objbrandDesc.Name = objBrand.Name; objBrand.Name = null; if (objSubCategory == null) { Logger.WriteToLogFile("Sub Category not found"); throw new Exception("Sub Category is null"); } var result = Neo4jController.m_graphClient.Cypher .Match("(A:" + objSubCategory.getLabel() + " { id : { id }})") .Match("(B:" + objbrandDesc.getLabel() + " { Name : { Name }})") .Merge("(A)-[R:" + Rel_SubCategory.subCategory_brand + "]->(C:" + objBrand.getLabel() + "{ Name : { Name }})") .OnCreate() .Set("C = { objBrand }") .OnMatch() .Set("B = { objBrand }") .Merge("(C)-[R2:" + Rel_Brand.brand_brandDescription + "]->(B)") .WithParams(new { id = objSubCategory.id, objBrand = objBrand, Name = objbrandDesc.Name }) .Return((B, R) => new { Count = B.Count(), RelationCount = R.Count() }) .Results .Single(); if (result.Count == 1) { Logger.WriteToLogFile("Successfully created brand"); } else { Logger.WriteToLogFile("unable to create brand"); } }
/* * This created a brandroot-[has_brand]->brand relation and nodes * */ public static BrandDescription CreateBrandDescriptionNode(BrandDescription objBrand) { Logger.WriteToLogFile(DBInteractor.Common.Utilities.GetCurrentMethod()); Logger.WriteObjectToLogFile <BrandDescription>(objBrand); BrandRoot objRoot = new BrandRoot(); var result = Neo4jController.m_graphClient.Cypher .Merge("(A:" + objRoot.getLabel() + " { Name : { Rootname}} )") .OnCreate() .Set("A = { objRoot}") .Merge("(A)-[R:" + Rel_BrandRoot.brandroot_brand + "]->(B:" + objBrand.getLabel() + "{ Name : { Name }})") .OnCreate() .Set("B = { objBrand }") .WithParams(new { Rootname = objRoot.Name, objRoot = objRoot, objBrand = objBrand, Name = objBrand.Name }) .Return((B, R) => new { BrandCount = B.Count(), RelationCount = R.Count(), retObj = B.As <BrandDescription>() }) .Results .Single(); if (result.BrandCount == 1) { Logger.WriteToLogFile("Successfully created Brand"); objBrand = result.retObj; } else { Logger.WriteToLogFile("unable to create Brand"); objBrand = null; } return(objBrand); }