示例#1
0
class CostumNode(Node):  # Serves as a basis for the annotation
    element_type = "CostumNode"
    ID = String(
        nullable=False
    )  # Fixed IDs to allow interoperability between different DB versions
    displayName = String()  # To see what it is, for the human operator
    custom = String()  # Just in case
示例#2
0
class CostumLink(Relationship):
    label = "CostumLink"
    costum_from = String()
    costum_to = String()
    linkType = String()
    custom = String()
    load = Float()
示例#3
0
class User(Node):
    element_type = "User"
    username = String(nullable=False, unique=True)
    password_hash = String(nullable=True)

    def set_password(self, password):
        self.password_hash = generate_password_hash(password)

    def verify_password(self, password):
        return check_password_hash(self.password_hash, password)

    def generate_auth_token(self, expires_in=3600):
        s = Serializer(current_app.config['SECRET_KEY'], expires_in=expires_in)
        return s.dumps({'id': self.eid}).decode('utf-8')

    @staticmethod
    def verify_auth_token(token):
        s = Serializer(current_app.config['SECRET_KEY'])
        try:
            data = s.loads(token)
        except:
            return None
        return graph.users.get(data['id'])

    def get_node(self):
        return {'id': self.eid, 'label': self.username}
示例#4
0
class Post(Node):
    __mode__ = STRICT
    element_type = "post"

    title = String(nullable=False)
    body = String(nullable=False)
    at = DateTime(default=current_datetime, nullable=False)
    root = Integer(default=0, nullable=False)

    x = Float(default=0, nullable=True)
    y = Float(default=0, nullable=True)

    tile_x = Integer(default=0, nullable=True)
    tile_y = Integer(default=0, nullable=True)

    @classmethod
    def get_proxy_class(cls):
        return PostProxy

    def parents(self):
        return sorted([element_to_model(e, Post) for e in self.inV("reply")],
                      key=lambda e: e.at,
                      reverse=True)

    def children(self):
        return sorted([element_to_model(e, Post) for e in self.outV("reply")],
                      key=lambda e: e.at,
                      reverse=True)

    def poster(self):
        return [element_to_model(e) for e in self.InV("posted")]

    def has_ancestor_any(self, needles):
        # TODO: Use aggregate/exclude to avoid searching the same parts of the
        # tree twice
        script = graph.scripts.get('has_ancestor_any')
        params = {
            'id': self.eid,
            'needle_ids': [needle.eid for needle in needles]
        }
        items = list(graph.gremlin.query(script, params))
        if len(items) > 0:
            return items[0]
        else:
            return None

    def save(self):
        self.tile_x = (self.x +
                       app.config['TILE_SIZE'] / 2) // app.config['TILE_SIZE']
        self.tile_y = (self.y +
                       app.config['TILE_SIZE'] / 2) // app.config['TILE_SIZE']
        super(Post, self).save()

    def __unicode__(self):
        result = unicode(self.eid)
        if self.title:
            result += " [%s]" % (unicode(self.title), )
        result += " posted on %s" % (unicode(self.at), )
        return result
示例#5
0
class AnnotNode(
        Node):                # Used mainly the simplest annotation basis annotation
    """
    Available AnnotNode Types are listed in AnnotNode_ptypes
    """
    element_type = "AnnotNode"
    ptype = String(nullable=False)    # Payload type
    payload = String(nullable=False)  # Indexed payload
示例#6
0
class CostumNode(Node):             # Serves as a basis for the annotation
    element_type = "CostumNode"
    ID = String(nullable=False)
    # TODO: rename to the legacy ID. This is a Reactome import legacy
    displayName = String()            # To see what it is, for the human operator
    main_connex = Bool()
    custom = String()                 # Just in case
    load = Float()                    # Deprecated. To freeze information transmission score
示例#7
0
class Proposal(Node):
    element_type = 'proposal'
    title = String(nullable=False)
    body = String(nullable=False)
    ups = Integer()
    downs = Integer()
    datetime_created = DateTime(default=current_datetime, nullable=False)
    datetime_modification = DateTime()
示例#8
0
class Comment(Node):
    element_type = 'comment'
    title = String(nullable=False)
    body = String(nullable=False)
    ups = Integer()  # Redundant storage of upvotes
    downs = Integer()  # Redundant storage of downvotes
    datetime_created = DateTime(default=current_datetime, nullable=False)
    datetime_modification = DateTime()
示例#9
0
class Person(Node):
    element_type = 'person'
    firstname = String(nullable=False)
    secondname = String(nullable=False)
    username = String(nullable=False)
    password = String(nullable=False)
    email = String(nullable=False)
    created = DateTime(default=current_datetime, nullable=False)
示例#10
0
class Website(Node):
    element_type = "Website"
    name = String(indexed=True)
    description = String()
    content = String()
    domain = Url()

    def hosts(self):
        return self.outV('hosts')
示例#11
0
class Idea(Node):

    element_type = "idea"

    text = String(nullable=False)
    stub = String("make_stub")

    def make_stub(self):
        return utils.create_stub(self.text)

    def after_created(self):
        Relationship.create(self, "created_by", current_user)
示例#12
0
class User(Node, UserMixin):
    __mode__ = STRICT
    element_type = "user"

    username = String(nullable=False, unique=True)
    password = String(nullable=False)
    joined = DateTime(default=current_datetime, nullable=False)
    active = Integer(nullable=False)

    def get_id(self):
        return self.username

    def is_active(self):
        return self.active
示例#13
0
class Agent(Node):
    element_type = "agent"
    snac_type = String(nullable=False, indexed=True)
    identifier = String(nullable=False, indexed=True)
    name = String(nullable=False)
    altNames = List()
    startDate = String()
    endDate = String()
    occupations = List()
    subjects = List()
    languages = List()
    nationalities = List()
    places = List()
    sameAs = List()
示例#14
0
class Message(Node):

    element_type = "message"

    mid = String()  # Unique pseudo message ID
    hasImage = Null()  # With image? (1= Yes, 0=No)
    source = String()  #The application name of the client program
    text = String(nullable=False)  # body of the message
    created_at = DateTime(default=current_datetime,
                          nullable=False)  # Original posting time
    deleted_last_seen = DateTime(
    )  #The last seen time before this message was missing from the user timeline
    permission_denied = Null(
    )  # 'permission denied' status is marked when the message was found missing in the timeline and the API return message was 'permission denied' - See details in (Fu, Chan, Chau 2013)
示例#15
0
class Neuron(Node):
    element_type = "neuron"

    name = String(nullable=False)

    creation_time = DateTime(default=current_datetime, nullable=False)
    edition_time = DateTime(default=current_datetime, nullable=False)
示例#16
0
class User(Node):
	"""A user node"""
	#
	#Class members
	#
	element_type = "user"
	
	#
	#Node properties
	#
	name = String(nullable=True)
	age = Integer()
	gender = String(nullable=True)
	email = String(nullable=False)
	sportChosen = List()
	isAvailable = List()
示例#17
0
class Person(Node):

    element_type = "person"

    name = String(nullable=False)
    age = Integer()
    is_adult = Bool()
class Product(BizBase, Node):
    "Product, categroy and product-instance. Will be detailed later on."
    element_type = 'Product'
    name = String(indexed=True)
    date_start = DateTime()
    date_activated = DateTime()
    date_end = DateTime()
    amount = Integer()
示例#19
0
class User(Node):

    element_type = "user"

    #unique, index (if no index=True, index all properties)
    password =  String(nullable=False, indexed=False)
    username = String(nullable=False, unique=True, indexed=True)
    email = String(nullable=True, unique=True, indexed=False)
    photo = String(nullable=True, indexed=False) #Imagen en Base64 (TODO Ciclo2)

    @staticmethod
    def authenticate(uname, upass):
        try:
            user = g.user.index.lookup(username=uname).next()#Intentamos sacar el primer elemento
            if user and user.password == upass:
                return user
        except Exception:
            return

    @staticmethod
    def register(uname, upass):
        try:
            g.user.index.lookup(username=uname).next() #Intentamos sacar el primer elemento
        except Exception: #No hay elemento
            user = g.user.create(username=uname,password=upass) #Lo creamos
            return user
        return

    @staticmethod
    def get(id):
        return g.user.get(id)

    def is_authenticated(self):
        return True

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_id(self):
        #return g.user.index.lookup(username=self.username).next().eid #No creo que funcione
        return self.eid
示例#20
0
class Page(Node):
    element_type = "Page"
    url = Url(indexed=True)
    title = String()

    def isHostedBy(self):
        website = self.inV('hosts')
        if website:
            return next(website)
        return None
示例#21
0
class Sport(Node):
	"""A sport node"""
	#
	#Class members
	#
	element_type = "sport"
	
	#
	#Node properties
	#
	name = String(nullable=False)
示例#22
0
class Location(Node):
	"""A location node"""
	
	#
	#Class members
	#
	element_type = "location"
	
	#
	#Node properties
	#
	location = String(nullable=False)
示例#23
0
class Customer(Node):
    element_type = "Customer"

    name = String(nullable=False)

    def get_url(self):
        return url_for('api.get_customer', id=self.eid, _external=True)

    def export_data(self):
        return {'self_url': self.get_url(), 'name': self.name}

    def get_node(self):
        return {'id': self.eid, 'label': self.name}
示例#24
0
class Product(Node):
    element_type = "Product"
    label = "Product"

    name = String(nullable=False)

    def get_url(self):
        return url_for('api.get_product', id=self.eid, _external=True)

    def export_data(self):
        return {'self_url': self.get_url(), 'name': self.name}

    def get_node(self):
        return {'id': self.eid, 'label': self.name}
示例#25
0
class Persona(Node):
    element_type = 'persona'
    id = Integer(nullable=False)

    nombre_y_apellido = String(nullable=False)
    titulo = String()  # XXX puede ser una relacion
    prefijo = String()
    sufijo = String()
    cuit = Integer()
    dni = Integer()
    estado_civil = String()
    domicilio = String()
    boletines = String()
示例#26
0
class Local(Node):

    element_type = "local"

    #unique, index (if no index=True, index all properties)
    localname = String(nullable=False, unique=True, indexed=True)
    address = String(nullable=False, unique=True, indexed=True)
    photo = String(nullable=True, indexed=False) #Imagen en Base64 (TODO Ciclo2)

    @staticmethod
    def register(lname, laddress):
        try:
            g.local.index.lookup(localname=lname,address=laddress).next() #Comprobar si puedes buscar varios par/valores
        except Exception: #No hay elemento
            user = g.local.create(localname=lname,address=laddress) #Lo creamos
            return user
        return

    @staticmethod
    def get(id):
        return g.local.get(id)

    def get_id(self):
        return self.eid
示例#27
0
        class Page(Node):
            element_type = 'Page'
            title = String()
            url = Url()

            def isHostedBy(self):
                return self._relation('hosts', 'in', unique=True)

            def isHostedBy_add(self, relation, node):
                return self._relation_add('hosts', 'in', relation, node)

            def isHostedBy_del(self, relation):
                return self._relation_del('hosts', 'in', relation)

            def describes(self):
                return self._relation('describes', 'out', unique=False)

            def describes_add(self, relation, node):
                return self._relation_add('describes', 'out', relation, node)

            def describes_del(self, relation):
                return self._relation_del('describes', 'out', relation)
class Address(BizBase, Node):
    element_type = 'Address'
    number = Integer()
    addition = String()

    @classmethod
    def new(cls,
            number,
            addition=None,
            city=None,
            zipcode=None,
            street=None,
            g=graph):
        """Create or retrieve new address. Number is mandatory, combination of city/street, 
        zipcode is mandatory, other params are optional."""
        c = City.new(name=city)
        z = Zipcode.new(code=zipcode)
        s = Street.new(name=street)
        a = g.Address.create(number=number, addition=addition)
        g.AddressCity.create(a, c)
        g.AddressZipcode.create(a, z)
        g.AddressStreet.create(a, s)
        return a
class Person(Customer):
    "The name of the person is the surname."
    element_type = 'Person'  # ToDo: create in meta-class
    initials = String(indexed=True, unique=True)
    infix = String(indexed=True, unique=True)
class Customer(BizBase, Node):
    element_type = 'customer'
    name = String(indexed=True, unique=True)