Beispiel #1
0
class Target(GraphObject):
    __primarylabel__ = "target"
    __primarykey__ = "TID"
    TID = Property()
    name = Property()
    longitude = Property()
    latitude = Property()
Beispiel #2
0
class User(Model):
    __primarykey__ = "id"
    id = Property("id")
    name = Property("name")
    email = Property("email")

    subscribed_to = RelatedTo(Feed, "SUBSCRIBED")
Beispiel #3
0
class Tweet(GraphObject):
    id = Property()
    text = Property()

    retweeted = RelatedTo('Tweet')
    replied_to = RelatedTo('Tweet')
    mentioned = RelatedTo('User')
Beispiel #4
0
class Region(BaseModel):
    __primarykey__ = 'name'

    name = Property()
    population = Property()

    country = RelatedTo('Country', 'BELONGS_TO')
Beispiel #5
0
class Village(BaseModel):
    __primarykey__ = 'name'

    name = Property()
    population = Property()

    district = RelatedTo('District', 'BELONGS_TO')
Beispiel #6
0
class Genre(GraphObject):
    __primarykey__ = 'name'

    name = Property()
    description = Property()

    preferred = RelatedFrom("User", "PREFER")
class Entity(GraphObject):
    __primarykey__ = "eId"
    Name = Property()
    eId = Property()
    Email = Property()
    Address = Property()
    Tags = Property()
Beispiel #8
0
class CodeSet(Model):
    __primarykey__ = 'identifier'
    identifier: str = Property()
    description: str = Property()
    uri: str = Property()

    members = RelatedTo(ConceptReference, 'HAS_MEMBER')
Beispiel #9
0
class Author(GraphObject):
    __primarylabel__ = 'author'

    id = Property()
    authorName = Property()
    papers = RelatedTo('Paper', 'publish')
    affiliation_ = RelatedTo('Affiliation', 'work_in')
Beispiel #10
0
class URL(GraphObject):
    __primarykey__ = "path"

    path = Property()
    domain = Property()

    points_at = RelatedTo(IP)
Beispiel #11
0
class PermissibleValue(Model):
    # Permissible Value
    __primarykey__ = 'identifier'
    identifier: str = Property()
    value: str = Property()
    enumerated_value = RelatedFrom(Enumeration, 'HAS_PERMISSIBLE_VALUE')
    mappings = RelatedFrom('Mapping', 'MAPPED_FROM')
Beispiel #12
0
class Movie(Neo4JManager):
    __primarykey__ = "title"

    title = Property()
    tagline = Property()

    actors = RelatedFrom("Person", "ACTED_IN")
Beispiel #13
0
class Person(base.BaseModel):
    __primarykey__ = 'IdObject'
    IdObject = Property()
    Name = Property()
    NameFamily = Property()
    NameFull = Property()

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

    def as_dict(self):
        return {
            'user_name': self.IdObject,
            'first_name': self.Name,
            'last_name': self.NameFamily,
            'full_name': self.NameFull
        }

    def fetch(self):
        graph = base.get_graph_obj()

        person = self.match(graph).where(IdObject=self.IdObject).first()

        if person is None:
            raise GraphQLError(
                f'"{self.IdObject}" has not been found in our employee list.')

        return person
class Attribute(ApplicationGraphObject):
    __primarykey__ = 'attribute_name'

    attribute_name = Property('attribute_name')
    value = Property('value')
    weight = Property('weight')
    bias = Property('bias')
Beispiel #15
0
class Receipt(BaseModel):
    total_amount = Property()
    timestamp = Property()

    products = RelatedTo('Product', 'HAS')

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        if kwargs.get('validate', False):
            self.__validate_timestamp()

    def as_dict(self):
        return {
            '_id': self._GraphObject__ogm.node._Entity__remote._id,
            'total_amount': self.total_amount,
            'timestamp': maya.parse(self.timestamp)
        }

    def fetch(self, _id):
        return self.select(graph, _id).first()

    def fetch_products(self):
        return [{
            **product[0].as_dict(),
            **product[1]
        } for product in self.products._related_objects]

    def __validate_timestamp(self):
        try:
            maya.parse(self.timestamp, day_first=True, year_first=False)
        except Exception:
            raise GraphQLError(
                'The timestamp you provided is not within the format: "dd/mm/yyyy hh:mm"'
            )
Beispiel #16
0
class Paper(GraphObject):
    __primarylabel__ = 'paper'

    id = Property()
    title = Property()
    authors = RelatedFrom('Author', 'publish')
    conference = RelatedTo('Conference', 'publish_on')
Beispiel #17
0
class Article(GraphObject):
    __primarykey__ = "FullId"

    Id = Property()
    FullId = Property()
    Title = Property()
    Marginalia = Property()
    Numerical = Property()

    paragraphs = RelatedTo("Paragraph", "HAS_PARAGRAPH")
    ClassifiedCompilation = RelatedFrom(ClassifiedCompilation, "HAS_ARTICLE")

    def __repr__(self):
        return "Article[Id={}, FullId={}, Title={}]".format(
            self.Id, self.FullId, self.Title)

    def toDict(self):
        return {
            "Id": self.Id,
            "FullId": self.FullId,
            "Title": self.Title,
            "Marginalia": self.Marginalia,
            "Numerical": self.Numerical,
            "Paragraphs": [p.toDict() for p in self.paragraphs],
            "ClassifiedCompilation":
            [c.CCNr for c in self.ClassifiedCompilation]
        }
Beispiel #18
0
class NISTFunction(GraphObject):
    """Neo4j Graph Object (node) representing a NIST Function
    """
    __primarykey__ = "id"

    id = Property()
    title = Property()
Beispiel #19
0
class User(GraphObject):
    __primarykey__ = "email"
    name = Property()
    email = Property()
    password = Property()
    token = Property()
    SUBMITS = RelatedTo("Report")
Beispiel #20
0
class User(BaseModel):

    __primarykey__ = 'email'

    email = Property()
    first_name = Property()
    last_name = Property()
    passwod = Property()

    def as_dict(self):
        return {
            'email': self.email,
            'first_name': self.first_name,
            'last_name': self.last_name,
        }

    def fetch_by_email(graph, email):
        return User.match(graph, email).first()

    def fetch_network(graph, email, network_id):
        return graph.run("MATCH (u:User)-[r:ATTACHMENT]-(n:Network)\
        WHERE u.email='%s' and n.id='%s'\
        RETURN u.email" % (email, network_id)).data()

    def fetch_networks_available(graph, email, network_id):
        return graph.run("MATCH (u:User)-[r]-(n:Network)\
        WHERE u.email='%s' and n.id='%s'\
        RETURN n.id" % (email, network_id)).data()

    def fetchSharedUser(graph, email, network_id):
        return graph.run("MATCH (u)-[rel:sharing]->(n) \
        WHERE u.email='%s' AND n.id='%s' \
        RETURN u" % (email, network_id)).data()

    def secure_fetch_by_email(graph, email):
        result = graph.run(
            "MATCH (user:User) where user.email='%s' REMOVE user.password RETURN user"
            % (email)).data()
        return result

    def unshare(graph, email, network_id):
        graph.run("MATCH (u)-[rel:sharing]->(n) \
        WHERE u.email='%s' AND n.id='%s' \
        DELETE rel" % (email, network_id)).data()

    def sharingNetworkAccess(graph, id_network):
        result = graph.run(
            "MATCH (user:User)-[s:sharing]-(n:Network{id:'%s'}) return user" %
            (id_network)).data()
        return result

    def addNetworkShared(graph, email, id_network):
        graph.run(
            "MATCH (u:User),(n:Network) WHERE u.email='%s' and n.id='%s' \
        create (u)-[s:sharing]->(n)" % (email, id_network)).data()

    def fetch_by_email_and_password(graph, email, password):
        condicao = "_.email = '{0}' AND _.passwod = '{1}'".format(
            email, password)
        return User.match(graph, email).where(condicao).first()
Beispiel #21
0
class User(GraphObject):
    __primarykey__ = 'email'

    username = Property()
    email = Property()

    materials = RelatedTo(Material, 'OWNS')
class Person(GraphObject):
    __primarykey__ = 'name'
    name = Property()
    born = Property()
    acted_in = RelatedTo('Movie')
    directed = RelatedTo('Movie')
    produced = RelatedTo('Movie')
Beispiel #23
0
class District(BaseModel):
    __primarykey__ = 'name'

    name = Property()
    population = Property()

    region = RelatedTo('Region', 'BELONGS_TO')
Beispiel #24
0
class Node(GraphObject):
    __primarykey__ = "id"

    id = Property()
    name = Property()

    edges = RelatedTo('Node')
Beispiel #25
0
class Server(GraphObject):
    __primarykey__ = "name"

    name = Property()
    ip = Property()
    os = RelatedTo(OS, "INSTALED_OS")
    cpu_type = Property()
    cpu_count = Property()
    memory = Property()

    def __init__(self, name, ip, ios):
        self.name = name
        self.ip = ip
        self.os.add(ios)

    #RelatedTo(OS,relationship_type="HAS_OS")
    #Relationship(alice, "KNOWS", bob, since=1999)

    #acted_in = RelatedTo(Movie)
    #directed = RelatedTo(Movie)
    #produced = RelatedTo(Movie)
    #actors = RelatedFrom("Person", "ACTED_IN")
    #directors = RelatedFrom("Person", "DIRECTED")
    #producers = RelatedFrom("Person", "PRODUCED")
    #comments = RelatedTo("Comment", "COMMENT")

    def __lt__(self, other):
        return self.name < other.name
Beispiel #26
0
class Graphmv_item(GraphObject):
    __primarykey__ = "user"

    user = Property()
    url = Property()
    score = Property()
    amigos = RelatedTo("Graphmv_item")
Beispiel #27
0
class URL(BaseModel):
    __primarykey__ = 'domain'

    name = Property()
    domain = Property()
    # datestamp = Property()

    ips = RelatedTo('IP', 'POINTS_TO')

    def fetch(self):
        url = self.match(graph, self.domain).first()
        if url == None:
            raise GraphQLError('')
        return url
    
    def as_dict(self):
        return {
            'domain' : self.domain,
            'name' : self.name,
            # 'datestamp' self.datestamp,
            'ips' : self.ips,
        }

    def __add_link(self, addr, datestamp=None):
        ip = IP(addr=addr).fetch()
        self.ips.add(ip)
        # if datestamp is not None:
            # self.datestamp.add(datestamp)


    def associate_ip(self, addr, datestamp=None):
        #THIS MAY BE TOO SIMPLE.
        self.__add_link(addr, datestamp)
Beispiel #28
0
class Store(BaseModel):
    name = Property()
    address = Property()

    products = RelatedTo('Product', 'SELLS')
    receipts = RelatedTo('Product', 'EMITTED')

    def fetch(self, _id):
        return Store.select(graph, _id).first()

    def fetch_by_name_and_address(self):
        return Store.select(graph).where(
            f'_.name = "{self.name}" AND _.address = "{self.address}"'
        ).first()

    def fetch_products(self):
        return [{
            **product[0].as_dict(),
            **product[1]
        } for product in self.products._related_objects]

    def as_dict(self):
        return {
            '_id': self._GraphObject__ogm.node._Entity__remote._id,
            'name': self.name,
            'address': self.address
        }
Beispiel #29
0
class Evaluation(BaseModel):
    __primarykey__ = 'rid'

    rid = Property()
    accuracy = Property()
    setup_id = Property()
    flow_id = Property()
    flow_name = Property()

    def __repr__(self):
        return f"Evaluation ({self.rid}, {self.accuracy})"
    
    def __eq__(self, other):
        if isinstance(other, Evaluation):
            return ((self.rid == other.rid) and (self.accuracy == other.accuracy))
        else:
            return False
    
    def __hash__(self):
        return hash(self.__repr__())
        
    def as_dict(self):
        return {
            'rid': self.rid,
            'accuracy': self.accuracy,
            'setup_id': self.setup_id,
            'flow_id': self.flow_id,
            'flow_name': self.flow_name
        }
    
    def fetch(self):
        evaluation = self.match(graph, self.rid).first()
        return evaluation
Beispiel #30
0
class GuildMixin(GraphObject):
    __primarylabel__ = "Guild"
    __primarykey__ = "id"

    id = Property()
    channel = Property()
    support_role = Property()
    prefix = Property()
    default_scope = Property()
    language = Property()
    ticket_category = Property()
    voice_category = Property()
    log_channel = Property()
    auto_assigning = Property()

    tickets = RelatedFrom("TicketMixin", "TICKET_LOCATED_ON")
    responses = RelatedFrom("ResponseMixin", "RESPONSE_LOCATED_ON")

    joined_users = RelatedFrom(UserMixin, "JOINED_GUILD")

    warnings = RelatedFrom("WarningMixin", "WARNING_EXECUTED_ON")
    kicks = RelatedFrom("KickMixin", "KICK_EXECUTED_ON")
    bans = RelatedFrom("BanMixin", "BAN_EXECUTED_ON")

    blacklist = RelatedFrom(UserMixin, "BLACKLISTED_ON")

    reports = RelatedFrom("ReportMixin", "REPORT_ISSUED_ON")