Esempio n. 1
0
class Event(neomodel.StructuredNode):
    name = neomodel.StringProperty(unique_index=True, required=True)
    weighting = neomodel.FloatProperty(required=False)
    modified = neomodel.DateTimeProperty(required=False)

    related_to = neomodel.RelationshipTo('Company', 'ABOUT')
    tweet_from = neomodel.RelationshipFrom('Tweet', 'TWEET_FROM')
    cited_from = neomodel.RelationshipFrom('News', 'CITE_FROM')

    def save(self):
        self.modified = datetime.datetime.now()
        super(Event, self).save()
        return self
Esempio n. 2
0
class Categories(StructuredNode):
    category_name = StringProperty(unique=True)
    parent_category = neomodel.RelationshipFrom('Categories', 'parent_catefory', model=CategoryRel)
    category_kind = StringProperty(max_length=50)
    false = 'false'
    true = 'true'
    boolean_choice = [(false,'false'),(true,'true')]
    reflexive = models.CharField(max_length=5, choices=boolean_choice, default=false)

    def __str__(self):
        return "{}".format(self.category_name)


    class Meta:
        app_label = 'notes'
Esempio n. 3
0
class Keyword(Base):
    movie = neo.RelationshipFrom(Movie, 'IS', cardinality=ZeroOrMore)
Esempio n. 4
0
class Genre(Base):
    movie = neo.RelationshipFrom(Movie, 'OWN', cardinality=ZeroOrMore)
Esempio n. 5
0
class Director(Base):
    movie = neo.RelationshipFrom(Movie, 'LED', cardinality=ZeroOrOne)
Esempio n. 6
0
class Compositor(Base):
    movie = neo.RelationshipFrom(Movie, 'COMPOSED', cardinality=ZeroOrOne)
Esempio n. 7
0
class Actor(Base):
    movie = neo.RelationshipFrom(Movie, 'PLAY_IN', cardinality=ZeroOrMore)
Esempio n. 8
0
class Producer(Base):
    movie = neo.RelationshipFrom(Movie, 'PRODUCED', cardinality=ZeroOrOne)
Esempio n. 9
0
class ASTNode(neomodel.StructuredNode):

    # properties
    Id = neomodel.UniqueIdProperty()
    Type = neomodel.StringProperty()
    Kind = neomodel.StringProperty()
    Code = neomodel.StringProperty()
    Range = neomodel.StringProperty()
    Location = neomodel.StringProperty()
    Value = neomodel.StringProperty()
    Raw = neomodel.StringProperty()
    Async = neomodel.StringProperty()
    SemanticType = neomodel.StringProperty()

    # Abstract Syntax Tree (AST) relationships
    ASTConnectionsTo = neomodel.RelationshipTo('ASTNode',
                                               'AST_parentOf',
                                               model=RelationshipSchema)
    ASTConnectionsFrom = neomodel.RelationshipFrom('ASTNode',
                                                   'AST_parentOf',
                                                   model=RelationshipSchema)
    ASTConnections = neomodel.Relationship('ASTNode',
                                           'AST_parentOf',
                                           model=RelationshipSchema)

    # Control Flow Graph (CFG) relationships
    CFGConnectionsTo = neomodel.RelationshipTo('ASTNode',
                                               'CFG_parentOf',
                                               model=RelationshipSchema)
    CFGConnectionsFrom = neomodel.RelationshipFrom('ASTNode',
                                                   'CFG_parentOf',
                                                   model=RelationshipSchema)
    CFGConnections = neomodel.Relationship('ASTNode',
                                           'CFG_parentOf',
                                           model=RelationshipSchema)

    # Program Dependence Graph (PDG) relationships
    PDGConnectionsTo = neomodel.RelationshipTo('ASTNode',
                                               'PDG_parentOf',
                                               model=RelationshipSchema)
    PDGConnectionsFrom = neomodel.RelationshipFrom('ASTNode',
                                                   'PDG_parentOf',
                                                   model=RelationshipSchema)
    PDGConnections = neomodel.Relationship('ASTNode',
                                           'PDG_parentOf',
                                           model=RelationshipSchema)

    # Inter-Procedural Call Graph (IPCG) relationships
    IPCGConnectionsTo = neomodel.RelationshipTo('ASTNode',
                                                'CG_parentOf',
                                                model=RelationshipSchema)
    IPCGConnectionsFrom = neomodel.RelationshipFrom('ASTNode',
                                                    'CG_parentOf',
                                                    model=RelationshipSchema)
    IPCGConnections = neomodel.Relationship('ASTNode',
                                            'CG_parentOf',
                                            model=RelationshipSchema)

    # Event Registration of ERDDG relationships
    ERDDGRegistrationConnectionsTo = neomodel.RelationshipTo(
        'ASTNode', 'ERDDG_Registration', model=RelationshipSchema)
    ERDDGRegistrationConnectionsFrom = neomodel.RelationshipFrom(
        'ASTNode', 'ERDDG_Registration', model=RelationshipSchema)
    ERDDGRegistrationConnections = neomodel.Relationship(
        'ASTNode', 'ERDDG_Registration', model=RelationshipSchema)

    # Event Dispatch of ERDDG relationships
    ERDDGDispatchConnectionsTo = neomodel.RelationshipTo(
        'ASTNode', 'ERDDG_Dispatch', model=RelationshipSchema)
    ERDDGDispatchConnectionsFrom = neomodel.RelationshipFrom(
        'ASTNode', 'ERDDG_Dispatch', model=RelationshipSchema)
    ERDDGRegistrationConnections = neomodel.Relationship(
        'ASTNode', 'ERDDG_Registration', model=RelationshipSchema)

    # Event Dependency of ERDDG relationships
    ERDDGDependencyConnectionsTo = neomodel.RelationshipTo(
        'ASTNode', 'ERDDG_Dependency', model=RelationshipSchema)
    ERDDGDependencyConnectionsFrom = neomodel.RelationshipFrom(
        'ASTNode', 'ERDDG_Dependency', model=RelationshipSchema)
    ERDDGDependencyConnections = neomodel.Relationship(
        'ASTNode', 'ERDDG_Dependency', model=RelationshipSchema)

    # ------------------------------------------------------------------------------------------------ #
    #					General Methods
    # ------------------------------------------------------------------------------------------------ #

    def get_line(self):
        """
		@return {list|None}: [(a, b)] where a, b are the start and end lines for the code of the AST node 
		
		"""
        if self.location is not None:
            loc = eval(self.location)
            return [loc.start.line, loc.end.line]

        return None

    def is_cfg_node(self):
        # TODO
        pass

    def has_cfg_edge(self):
        # TODO
        pass

    def has_pdg_edge(self):
        # TODO
        pass

    # ------------------------------------------------------------------------------------------------ #
    #					Edge Traversals
    # ------------------------------------------------------------------------------------------------ #

    def get_connections_by_ast(self,
                               direction=neomodel.match.OUTGOING,
                               **kwargs):
        """
		@param {string} direction: neomodel.match.OUTGOING / neomodel.match.INCOMING / neomodel.match.EITHER
		@param **kwargs: positional keyword arguments specifying the constraints on the edges for traversals
		@return {list}: related AST nodes
		"""

        if direction == neomodel.match.OUTGOING:
            return self.ASTConnectionsTo.match(**kwargs).all()
        elif direction == neomodel.match.INCOMING:
            return self.ASTConnectionsFrom.match(**kwargs).all()
        else:
            return self.ASTConnections.match(**kwargs).all()

    def get_connections_by_cfg(self,
                               direction=neomodel.match.OUTGOING,
                               **kwargs):
        """
		@param {string} direction: neomodel.match.OUTGOING / neomodel.match.INCOMING / neomodel.match.EITHER
		@param **kwargs: positional keyword arguments specifying the constraints on the edges for traversals
		@return {list} related CFG nodes
		"""

        if direction == neomodel.match.OUTGOING:
            return self.CFGConnectionsTo.match(**kwargs).all()
        elif direction == neomodel.match.INCOMING:
            return self.CFGConnectionsFrom.match(**kwargs).all()
        else:
            return self.CFGConnections.match(**kwargs).all()

    def get_connections_by_pdg(self,
                               direction=neomodel.match.OUTGOING,
                               **kwargs):
        """
		@param {string} direction: neomodel.match.OUTGOING / neomodel.match.INCOMING / neomodel.match.EITHER
		@param **kwargs: positional keyword arguments specifying the constraints on the edges for traversals
		@return {list} related PDG nodes
		"""

        if direction == neomodel.match.OUTGOING:
            return self.PDGConnectionsTo.match(**kwargs).all()
        elif direction == neomodel.match.INCOMING:
            return self.PDGConnectionsFrom.match(**kwargs).all()
        else:
            return self.PDGConnections.match(**kwargs).all()

    def get_connections_by_ipcg(self,
                                direction=neomodel.match.OUTGOING,
                                **kwargs):
        """
		@param {string} direction: neomodel.match.OUTGOING / neomodel.match.INCOMING / neomodel.match.EITHER
		@param **kwargs: positional keyword arguments specifying the constraints on the edges for traversals
		@return {list} related IPCG nodes
		"""

        if direction == neomodel.match.OUTGOING:
            return self.IPCGConnectionsTo.match(**kwargs).all()
        elif direction == neomodel.match.INCOMING:
            return self.IPCGConnectionsFrom.match(**kwargs).all()
        else:
            return self.IPCGConnections.match(**kwargs).all()

    def get_connections_by_erddg_dispatch(self,
                                          direction=neomodel.match.OUTGOING,
                                          **kwargs):
        """
		@param {string} direction: neomodel.match.OUTGOING / neomodel.match.INCOMING / neomodel.match.EITHER
		@param **kwargs: positional keyword arguments specifying the constraints on the edges for traversals
		@return {list} related nodes via ERDDG Dispatch edges
		"""

        if direction == neomodel.match.OUTGOING:
            return self.ERDDGDispatchConnectionsTo.match(**kwargs).all()
        elif direction == neomodel.match.INCOMING:
            return self.ERDDGDispatchConnectionsFrom.match(**kwargs).all()
        else:
            return self.ERDDGDispatchConnections.match(**kwargs).all()

    def get_connections_by_erddg_registration(self,
                                              direction=neomodel.match.
                                              OUTGOING,
                                              **kwargs):
        """
		@param {string} direction: neomodel.match.OUTGOING / neomodel.match.INCOMING / neomodel.match.EITHER
		@param **kwargs: positional keyword arguments specifying the constraints on the edges for traversals
		@return {list} related nodes via ERDDG Registration edges
		"""

        if direction == neomodel.match.OUTGOING:
            return self.ERDDGRegistrationConnectionsTo.match(**kwargs).all()
        elif direction == neomodel.match.INCOMING:
            return self.ERDDGRegistrationConnectionsFrom.match(**kwargs).all()
        else:
            return self.ERDDGRegistrationConnections.match(**kwargs).all()

    def get_connections_by_erddg_dependency(self,
                                            direction=neomodel.match.OUTGOING,
                                            **kwargs):
        """
		@param {string} direction: neomodel.match.OUTGOING / neomodel.match.INCOMING / neomodel.match.EITHER
		@param **kwargs: positional keyword arguments specifying the constraints on the edges for traversals
		@return {list} related nodes via ERDDG Dependency edges
		"""

        if direction == neomodel.match.OUTGOING:
            return self.ERDDGDependencyConnectionsTo.match(**kwargs).all()
        elif direction == neomodel.match.INCOMING:
            return self.ERDDGDependencyConnectionsFrom.match(**kwargs).all()
        else:
            return self.ERDDGDependencyConnections.match(**kwargs).all()
Esempio n. 10
0
class Deck(nm.StructuredNode):
    name = nm.StringProperty(unique_index=True)
    cards = nm.RelationshipTo('Card', 'CARD')
    owner = nm.RelationshipFrom('User', 'USER', cardinality=nm.One)
    attributes = nm.ArrayProperty()
Esempio n. 11
0
class DocumentNode(DjangoNode):
    document_id = neomodel.IntegerProperty(
        unique_index=True)  # one-to-one to Document model in SQL
    authors = neomodel.RelationshipFrom('AuthorNode', 'OWNS')