Last active
June 14, 2016 09:45
-
-
Save Miguel000/b02cfd9f0238195a68e0 to your computer and use it in GitHub Desktop.
Revisions
-
Miguel000 revised this gist
Nov 30, 2015 . 1 changed file with 4 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -59,24 +59,16 @@ def userprocess(self): typeRelation = "" crearRelation=True item = self.listEntities[i] try: if item.keys()[0].endswith("default"): typeRelation = item.values()[1] idStart = str(self.getField(item.keys()[1])) idEnd = str(self.getField(item.values()[0])) else: typeRelation = item.values()[0] idStart = str(self.getField(item.keys()[0])) idEnd = str(self.getField(item.values()[1])) endUrlnode = "index/node/"+self.index+"?uniqueness=get_or_create" finalUrl = self.url + endUrlnode -
Miguel000 revised this gist
Nov 26, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -112,7 +112,7 @@ def userprocess(self): finalUrlrelation = self.url + endUrlnode payload = '{"to": "'+idnodeend+'" , "type" : "'+typeRelation+'"}' response = requests.post(finalUrlrelation, headers=headers, data=payload) self.log("CREATE RELATION: " + str(response.json())) except Exception, ex: self.log("Una Entidad no tiene ningun valor : " + str(ex)) -
Miguel000 revised this gist
Nov 26, 2015 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -82,15 +82,15 @@ def userprocess(self): finalUrl = self.url + endUrlnode payload = '{"key" : "'+self.key+'" , "value" : "'+idStart+'" }' response = requests.post(finalUrl, headers=headers, data=payload) self.log("DEFAULT ENTITY: " + str(response.json())) idnodestart = str(response.json().get('metadata').get('id')) payload = '{"key" : "'+self.key+'" , "value" : "'+idEnd+'" }' response = requests.post(finalUrl, headers=headers, data=payload) self.log("EXIST 2 ENTITY: " + str(response.json())) idnodeend = str(response.json().get('metadata').get('id')) urlrelations = str(response.json().get('incoming_relationships')) response = requests.get(urlrelations, headers=headers) self.log("EXIST RELATION: " + str(response.json())) if response.text == "[ ]": self.log("CREO RELACION") crearRelation = True -
Miguel000 revised this gist
Nov 26, 2015 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import json import base64 import urllib import traceback class Neo4jRelationshipsUniqueId(basesinfonierdrain.BaseSinfonierDrain): @@ -115,6 +116,7 @@ def userprocess(self): except Exception, ex: self.log("Una Entidad no tiene ningun valor : " + str(ex)) self.log(str(traceback.format_exc())) pass except Exception, ex: -
Miguel000 revised this gist
Nov 25, 2015 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -68,14 +68,14 @@ def userprocess(self): self.log(str("VALOR ENTIDAD END : " + item.values()[1])) try: if item.keys()[0].endswith("default"): typeRelation = item.values()[1] idStart = self.getField(item.keys()[1]) idEnd = self.getField(item.values()[0]) else: typeRelation = item.values()[0] idStart = self.getField(item.keys()[0]) idEnd = self.getField(item.values()[1]) endUrlnode = "index/node/"+self.index+"?uniqueness=get_or_create" finalUrl = self.url + endUrlnode -
Miguel000 revised this gist
Nov 25, 2015 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -60,12 +60,12 @@ def userprocess(self): item = self.listEntities[i] if item.keys()[0].endswith("default"): self.log(str("VALOR ENTIDAD START : " + item.keys()[1])) self.log(str("VALOR RELACION : " + item.values()[1] )) self.log(str("VALOR ENTIDAD END : " + item.values()[0])) else: self.log(str("VALOR ENTIDAD START : " + item.keys()[0])) self.log(str("VALOR RELACION : " + item.values()[0])) self.log(str("VALOR ENTIDAD END : " + item.values()[1])) try: if item.keys()[0].endswith("default"): typeRelation = item.values()[0] -
Miguel000 revised this gist
Nov 25, 2015 . 1 changed file with 8 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -58,6 +58,14 @@ def userprocess(self): typeRelation = "" crearRelation=True item = self.listEntities[i] if item.keys()[0].endswith("default"): self.log(str("VALOR ENTIDAD START : " + item.keys()[1])) self.log(str("VALOR RELACION : " + item.values()[0] )) self.log(str("VALOR ENTIDAD END : " + item.values()[1])) else: self.log(str("VALOR ENTIDAD START : " + item.keys()[0])) self.log(str("VALOR RELACION : " + item.values()[1] )) self.log(str("VALOR ENTIDAD END : " + item.values()[0])) try: if item.keys()[0].endswith("default"): typeRelation = item.values()[0] @@ -69,9 +77,6 @@ def userprocess(self): idStart = self.getField(item.keys()[0]) idEnd = self.getField(item.values()[0]) endUrlnode = "index/node/"+self.index+"?uniqueness=get_or_create" finalUrl = self.url + endUrlnode payload = '{"key" : "'+self.key+'" , "value" : "'+idStart+'" }' -
Miguel000 revised this gist
Nov 25, 2015 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -69,6 +69,9 @@ def userprocess(self): idStart = self.getField(item.keys()[0]) idEnd = self.getField(item.values()[0]) self.log(str("VALOR ENTIDAD START : " + idStart)) self.log(str("VALOR RELACION : " + typeRelation )) self.log(str("VALOR ENTIDAD END : " + idEnd)) endUrlnode = "index/node/"+self.index+"?uniqueness=get_or_create" finalUrl = self.url + endUrlnode payload = '{"key" : "'+self.key+'" , "value" : "'+idStart+'" }' -
Miguel000 revised this gist
Nov 25, 2015 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -106,12 +106,13 @@ def userprocess(self): self.log("CREATE RELATION: " + str(response.text)) except Exception, ex: self.log("Una Entidad no tiene ningun valor : " + str(ex)) pass except Exception, ex: self.log("ERROR antes de empezar el bucle : t" + str(ex)) except Exception, ex: self.log("Error al inicio : "+str(ex)) Neo4jRelationshipsUniqueId().run() -
Miguel000 revised this gist
Nov 25, 2015 . 1 changed file with 6 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -56,20 +56,18 @@ def userprocess(self): idStart = "" idEnd = "" typeRelation = "" crearRelation=True item = self.listEntities[i] try: if item.keys()[0].endswith("default"): typeRelation = item.values()[0] idStart = self.getField(item.keys()[1]) idEnd = self.getField(item.values()[1]) else: typeRelation = item.values()[1] idStart = self.getField(item.keys()[0]) idEnd = self.getField(item.values()[0]) endUrlnode = "index/node/"+self.index+"?uniqueness=get_or_create" finalUrl = self.url + endUrlnode -
Miguel000 revised this gist
Nov 25, 2015 . 1 changed file with 48 additions and 43 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -60,50 +60,55 @@ def userprocess(self): keysend="" crearRelation=True item = self.listEntities[i] try: if item.keys()[0].endswith("default"): valueLabel = item.values()[0] keyNode = item.keys()[1] valueNode = self.getField(item.values()[1]) else: valueLabel = item.values()[1] keyNode = item.keys()[0] valueNode = self.getField(item.values()[0]) endUrlnode = "index/node/"+self.index+"?uniqueness=get_or_create" finalUrl = self.url + endUrlnode payload = '{"key" : "'+self.key+'" , "value" : "'+idStart+'" }' response = requests.post(finalUrl, headers=headers, data=payload) self.log("DEFAULT ENTITY: " + str(response.text)) idnodestart = str(response.json().get('metadata').get('id')) payload = '{"key" : "'+self.key+'" , "value" : "'+idEnd+'" }' response = requests.post(finalUrl, headers=headers, data=payload) self.log("EXIST 2 ENTITY: " + str(response.text)) idnodeend = str(response.json().get('metadata').get('id')) urlrelations = str(response.json().get('incoming_relationships')) response = requests.get(urlrelations, headers=headers) self.log("EXIST RELATION: " + str(response.text)) if response.text == "[ ]": self.log("CREO RELACION") crearRelation = True else: self.log("ENTRO SI EXISTER RELACIONES") for j in response.json(): self.log(str(j)) existrelation = str(j['start']) idstart = existrelation.split("/") self.log(str(idstart)) idfin = idstart[-1] if idfin == idnodestart: if j['metadata']['type'] == typeRelation: self.log("TODO ES IGUAL, RELACION EXISTENTE") crearRelation = False if crearRelation: self.log("ENTRO, nodo inicial: ") endUrlnode = "node/"+idnodestart+"/relationships" finalUrlrelation = self.url + endUrlnode payload = '{"to": "'+idnodeend+'" , "type" : "'+typeRelation+'"}' response = requests.post(finalUrlrelation, headers=headers, data=payload) self.log("CREATE RELATION: " + str(response.text)) except Exception, ex: continue except Exception, ex: self.log("Values is not a proper list element" + str(ex)) -
Miguel000 revised this gist
Nov 25, 2015 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -60,7 +60,6 @@ def userprocess(self): keysend="" crearRelation=True item = self.listEntities[i] for key in item.keys(): if not key.endswith("default"): self.log("CLAVE NO DEFAULT " + str(key)) -
Miguel000 renamed this gist
Nov 25, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,7 +28,7 @@ import base64 import urllib class Neo4jRelationshipsUniqueId(basesinfonierdrain.BaseSinfonierDrain): def __init__(self): @@ -112,4 +112,4 @@ def userprocess(self): except Exception, ex: self.log("Error in check"+str(ex)) Neo4jRelationshipsUniqueId().run() -
Miguel000 created this gist
Nov 25, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,115 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- """ The MIT License (MIT) Copyright (c) 2014 sinfonier-project Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ import basesinfonierdrain import requests import json import base64 import urllib class Neo4jRelationships2(basesinfonierdrain.BaseSinfonierDrain): def __init__(self): basesinfonierdrain.BaseSinfonierDrain().__init__() def userprepare(self): # Get Param (get value of "param_name" from input box) self.url = self.getParam("urlDatabase") self.index = self.getParam("index") self.param = self.getParam("param") self.key = self.getParam("key") self.listEntities = self.getParam("listEntities") def userprocess(self): try: auth = base64.b64encode(self.param) headers = {"Accept" : "application/json; charset=UTF-8","Content-Type": "application/json", "Authorization" : "Basic " + auth} endUrlnode = "index/node/"+self.index+"?uniqueness=get_or_create" self.log(str(self.config)) try: for i in range(len(self.listEntities)): idStart = "" idEnd = "" typeRelation = "" keystart="" keysend="" crearRelation=True item = self.listEntities[i] lkeys = self.listkeys[i] for key in item.keys(): if not key.endswith("default"): self.log("CLAVE NO DEFAULT " + str(key)) idStart = self.getField(key) typeRelation = item[key] self.log("VALUE NO DEFAULT " + str(item[key])) else: idEnd = self.getField(item[key]) self.log("VALUE DEFAULT " + str(item[key])) endUrlnode = "index/node/"+self.index+"?uniqueness=get_or_create" finalUrl = self.url + endUrlnode payload = '{"key" : "'+self.key+'" , "value" : "'+idStart+'" }' response = requests.post(finalUrl, headers=headers, data=payload) self.log("DEFAULT ENTITY: " + str(response.text)) idnodestart = str(response.json().get('metadata').get('id')) payload = '{"key" : "'+self.key+'" , "value" : "'+idEnd+'" }' response = requests.post(finalUrl, headers=headers, data=payload) self.log("EXIST 2 ENTITY: " + str(response.text)) idnodeend = str(response.json().get('metadata').get('id')) urlrelations = str(response.json().get('incoming_relationships')) response = requests.get(urlrelations, headers=headers) self.log("EXIST RELATION: " + str(response.text)) if response.text == "[ ]": self.log("CREO RELACION") crearRelation = True else: self.log("ENTRO SI EXISTER RELACIONES") for j in response.json(): self.log(str(j)) existrelation = str(j['start']) idstart = existrelation.split("/") self.log(str(idstart)) idfin = idstart[-1] if idfin == idnodestart: if j['metadata']['type'] == typeRelation: self.log("TODO ES IGUAL, RELACION EXISTENTE") crearRelation = False if crearRelation: self.log("ENTRO, nodo inicial: ") endUrlnode = "node/"+idnodestart+"/relationships" finalUrlrelation = self.url + endUrlnode payload = '{"to": "'+idnodeend+'" , "type" : "'+typeRelation+'"}' response = requests.post(finalUrlrelation, headers=headers, data=payload) self.log("CREATE RELATION: " + str(response.text)) except Exception, ex: self.log("Values is not a proper list element" + str(ex)) except Exception, ex: self.log("Error in check"+str(ex)) Neo4jRelationships2().run()