Ejemplo n.º 1
0
class Post(DjangoNode):
    post_id = UniqueIdProperty()
    date = DateTimeProperty(default=datetime.datetime.now())
    link = StringProperty(required=True)
    text = StringProperty(required=False)
    upvoted = IntegerProperty(default=0)
    downvoted = IntegerProperty(default=0)
    tags = RelationshipTo("Tag", "TAGGED", cardinality=OneOrMore)
    user = RelationshipFrom("User", "POSTED", cardinality=One)
    comments = RelationshipFrom("Comment",
                                "CONCERNING",
                                cardinality=ZeroOrMore)

    votes = Relationship('User', 'RATED', model=VotingRel)

    @property
    def serialize(self):
        return {
            'post_id': self.post_id,
            'date': self.date,
            'link': self.link,
            'text': self.text,
            'upvoted': self.upvoted,
            'downvoted': self.downvoted,
            'tags': [x.tag_id for x in self.tags.all()],
            'user': [x.name for x in self.user.all()],
            'comments': [x.comment_id for x in self.comments.all()],
        }
Ejemplo n.º 2
0
class Advisory(EstuaryStructuredNode):
    """Definition of an Errata advisory in Neo4j."""

    actual_ship_date = DateTimeProperty()
    advisory_name = StringProperty(unique=True)
    content_types = ArrayProperty()
    created_at = DateTimeProperty()
    id_ = UniqueIdProperty(db_property='id')
    issue_date = DateTimeProperty()
    product_name = StringProperty()
    product_short_name = StringProperty()
    release_date = DateTimeProperty()
    security_impact = StringProperty()
    security_sla = DateTimeProperty()
    state = StringProperty()
    status_time = DateTimeProperty()
    synopsis = StringProperty()
    type_ = StringProperty(db_property='type')
    update_date = DateTimeProperty()
    updated_at = DateTimeProperty()
    assigned_to = RelationshipTo('.user.User',
                                 'ASSIGNED_TO',
                                 cardinality=ZeroOrOne)
    attached_bugs = RelationshipTo('.bugzilla.BugzillaBug', 'ATTACHED')
    attached_builds = RelationshipTo('.koji.KojiBuild', 'ATTACHED')
    package_owner = RelationshipTo('.user.User',
                                   'PACKAGE_OWNED_BY',
                                   cardinality=ZeroOrOne)
    reporter = RelationshipTo('.user.User',
                              'REPORTED_BY',
                              cardinality=ZeroOrOne)
    states = RelationshipFrom('AdvisoryState', 'STATE_OF')
    triggered_freshmaker_event = RelationshipFrom(
        '.freshmaker.FreshmakerEvent', 'TRIGGERED_BY')
Ejemplo n.º 3
0
class EmailAddress(DjangoNode):
    uuid = UniqueIdProperty()
    value = EmailProperty()

    profile = RelationshipFrom(PROFILE_MODEL,
                               HasEmailAddress.rel_name,
                               model=HasEmailAddress)
Ejemplo n.º 4
0
class User(EstuaryStructuredNode):
    """Definition of a generic user in Neo4j."""

    # These relationships can be reverse relationships of ones with cardinality set. So
    # these relationships should be treated as read-only or else cardinality will not be respected.
    advisories_assigned = RelationshipFrom('.errata.Advisory', 'ASSIGNED_TO')
    advisories_package_owner = RelationshipFrom('.errata.Advisory',
                                                'PACKAGE_OWNED_BY')
    advisories_reported = RelationshipFrom('.errata.Advisory', 'REPORTED_BY')
    advisories_state_creator = RelationshipFrom('.errata.AdvisoryState',
                                                'CREATED_BY')
    bugs_assigned = RelationshipFrom('.bugzilla.BugzillaBug', 'ASSIGNED_TO')
    bugs_qa_contact_for = RelationshipFrom('.bugzilla.BugzillaBug', 'QA_BY')
    bugs_reported = RelationshipFrom('.bugzilla.BugzillaBug', 'REPORTED_BY')
    distgit_authored_commits = RelationshipFrom('.distgit.DistGitCommit',
                                                'AUTHORED_BY')
    distgit_branches = RelationshipFrom('.distgit.DistGitBranch',
                                        'CONTRIBUTED_BY')
    distgit_committed_commits = RelationshipFrom('.distgit.DistGitCommit',
                                                 'COMMITTED_BY')
    distgit_pushes = RelationshipFrom('.distgit.DistGitPush', 'PUSHED_BY')
    distgit_repos = RelationshipFrom('.distgit.DistGitRepo', 'CONTRIBUTED_BY')
    email = StringProperty()
    koji_builds = RelationshipFrom('.koji.KojiBuild', 'OWNED_BY')
    koji_tasks = RelationshipFrom('.koji.KojiTask', 'OWNED_BY')
    name = StringProperty()
    username = UniqueIdProperty()
Ejemplo n.º 5
0
class Question(StructuredNode):
    nodeId = UniqueIdProperty()
    slug = StringProperty(unique_index=True)
    language = StringProperty(required=True, choices={
                              'en': 'English',
                              'fr': 'French'
                            }
                        )
    question = StringProperty(unique_index=True)
    addedOn = DateTimeProperty(default_now=True)
    options = ArrayProperty(base_property= StringProperty())
    type = StringProperty(
        choices={
            'text': 'text',
            'mcq': 'mcq',
            'dropdown': 'dropdown'
        }
    )
    related_questions = Relationship(
        'Question',
        'RELATED_QUESTION',
        model= Question_Question_Rel
    )
    preQuestions = RelationshipFrom(
        'PreQuestion',
        'PREQUESTION_QUESTION'
    )
    surveyVersions = RelationshipFrom(
        ".survey_model.SurveyVersion",
        "SURVEY_QUESTION"
    )
Ejemplo n.º 6
0
class Document(StructuredNode):
    id = UniqueIdProperty()

    language = StringProperty()
    title = StringProperty()

    paragraph = RelationshipTo('Paragraph', 'REFERENCES')
    entity = RelationshipTo('Entity', 'INCLUDES', model=EntityRelation)

    like = RelationshipFrom('Document', 'LIKES')
    dislike = RelationshipFrom('Document', 'DISLIKES')
    view = RelationshipFrom('Document', 'VIEWED')

    def get_connected_entitys(self):
        results, columns = self.cypher(
            "MATCH (b) WHERE id(b)={self} MATCH (b)-[i1:INCLUDES]->(c) WHERE NOT c.text CONTAINS '.' AND NOT c.text CONTAINS '%' WITH c.text AS entity, toFloat(i1.count) AS count1, toFloat(i1.relevance) AS rel1, b.title AS startdoc RETURN  entity, (count1*rel1) AS totalscore  ORDER BY totalscore DESC LIMIT 10"
        )

        #list of dicts
        result_list = []
        for res in results:
            res_dict = {}
            res_dict['entity'] = res[0]
            res_dict['score'] = round(res[1], 2)
            result_list.append(res_dict)

        return result_list
Ejemplo n.º 7
0
class Entity(StructuredNode):
    id = UniqueIdProperty()

    text = StringProperty()
    type = StringProperty()

    def get_total(self):
        result, columns = self.cypher(
            "MATCH (a)-[r:INCLUDES]->(b) WHERE id(b)={self} RETURN COUNT(r)")
        return result[0][0]

    document = RelationshipFrom('Document', 'INCLUDES', model=EntityRelation)

    def generate_absolute_url(self):
        slug = self.text.replace(' ', '-')
        url = "/entity_search/" + slug
        return url

    # retrieves all documents connected to this entity with a score for relevance
    def get_connected_documents(self):
        results, columns = self.cypher(
            "MATCH (b)-[i1:INCLUDES]->(c) WHERE id(c)={self} WITH c.text AS entity, toFloat(i1.count) AS count1, toFloat(i1.relevance) AS rel1, b.title AS startdoc RETURN  startdoc, (count1*rel1) AS totalscore  ORDER BY totalscore DESC LIMIT 10"
        )

        #list of dicts
        result_list = []
        for res in results:
            res_dict = {}
            res_dict['startdoc'] = res[0]
            res_dict['score'] = round(res[1], 2)
            result_list.append(res_dict)

        return result_list
Ejemplo n.º 8
0
class Paragraph(StructuredNode):
    id = UniqueIdProperty()
    name = StringProperty()

    document = RelationshipFrom('Document', 'REFERENCES')

    def get_total(self):
        result, columns = self.cypher(
            "MATCH (a)-[r:REFERENCES]->(b) WHERE id(b)={self} RETURN COUNT(r)")
        return result[0][0]

    def generate_absolute_url(self):
        slug = self.name.replace(' ', '-')
        url = "/paragraph_search/" + slug
        return url

    # retrieves all documents connected to this paragraph with a score for relevance
    def get_connected_documents(self):
        results, columns = self.cypher(
            "MATCH (b)-[:REFERENCES]->(c) WHERE id(c)={self} WITH  b.title AS startdoc RETURN  startdoc LIMIT 10"
        )

        #list of dicts
        result_list = []
        for res in results:
            res_dict = {}
            res_dict['startdoc'] = res[0]
            result_list.append(res_dict)

        return result_list
Ejemplo n.º 9
0
class PersonaNode(DjangoNode):
    uid = UniqueIdProperty()
    nombre = StringProperty()
    creada = DateTimeProperty(default=datetime.utcnow)
    beacons = RelationshipTo('BeaconNode', 'INTERACCION', model=InteraccionRel)

    class Meta:
        app_label = 'logs'
Ejemplo n.º 10
0
class Tag(StructuredNode):
    """Node Tag which is known as HashTag"""
    pk = UniqueIdProperty()
    tag = StringProperty(required=True, unique_index=True)
    created_at = DateTimeProperty(default_now=True)

    """Tweets which has this tag."""
    tweets_has = RelationshipFrom('Tweet', 'HAS_TAG', model=TweetHasTag)
Ejemplo n.º 11
0
class PackageBooking(StructuredNode):
    uid = UniqueIdProperty()
    booked_at = DateTimeProperty(default_now=True)
    booking_date = DateProperty(required=True)
    people = IntegerProperty(required=True)

    by_user = RelationshipFrom("Traveller", "HAS_BOOKING", model=OwnsRel)
    for_package = RelationshipTo("Package", "FOR_PACKAGE", model=OwnsRel)
Ejemplo n.º 12
0
class Genre(StructuredNode):
    # Genre (or tag in bandcamp internal language) doesn't actually have even an internal id
    #   so we just store the name (which has been normalized)
    uid = UniqueIdProperty()
    name = StringProperty(unique_index=True)
    # Bandcamp stores whether or not the tag is representing a location and I
    #   am not sure how I'll use it yet but I think it's pretty neat.
    isloc = BooleanProperty()
Ejemplo n.º 13
0
class SubBus(StructuredNode):
    uid = UniqueIdProperty()
    Name = StringProperty(unique_index=True)
    NumberPlate = StringProperty(unique_index=True)
    Status = StringProperty(default="Unassign")
    Speed = FloatProperty(default=0.0)
    Lat = FloatProperty(default=0.0)
    Lng = FloatProperty(default=0.0)
Ejemplo n.º 14
0
class Message(StructuredNode, models.Node):
    mid = UniqueIdProperty()
    message = StringProperty()
    timestamp = DateTimeProperty(default_now=True)

    chat = Relationship('Chat', 'IN_CHAT', cardinality=One)
    sender = Relationship('Person', 'SENDER', cardinality=One)
    unseen = Relationship('Person', 'READER')
Ejemplo n.º 15
0
class Person(StructuredNode):
    uid = UniqueIdProperty()
    name = StringProperty(unique_index=True)
    age = IntegerProperty(index=True, default=0)

    # Relations :
    city = RelationshipTo(City, 'LIVES_IN')
    friends = RelationshipTo('Person','FRIEND')
Ejemplo n.º 16
0
class Admin(StructuredNode):
    uid = UniqueIdProperty()
    admin_name = StringProperty(unique_index=True)
    admin_email = StringProperty(required=True)
    admin_password = StringProperty(required=True)
    admin_contact = StringProperty(index=True, default=0)
    admin_cnic = StringProperty(unique_index=True)
    address = StringProperty(required=True)
Ejemplo n.º 17
0
class User(StructuredNode):
    uid = UniqueIdProperty()
    firebase_id = StringProperty()
    name = StringProperty(max_length=120, required=True)
    phone = RegexProperty(expression=r"^\+(\d){12}$", required=True)
    profile_picture = StringProperty(
        default="https://picsum.photos/201"  # TODO: get proper asset for new user
    )
Ejemplo n.º 18
0
 class Custom(StructuredNode):  # type: ignore
     custom = StringProperty(required=True, choices=CHOICES_tuple)
     myint = IntegerProperty(required=True)
     myfloat = FloatProperty(required=True)
     # do not set it as required because:
     # ValueError: required argument ignored by UniqueIdProperty
     myuuid = UniqueIdProperty()
     mydate = DateProperty()
Ejemplo n.º 19
0
class KojiBuild(EstuaryStructuredNode):
    """Definition of a Koji build in Neo4j."""

    advisories = RelationshipFrom('.errata.Advisory',
                                  'ATTACHED',
                                  model=Advisory.BuildAttachedRel)
    commit = RelationshipTo('.distgit.DistGitCommit',
                            'BUILT_FROM',
                            cardinality=ZeroOrOne)
    completion_time = DateTimeProperty(index=True)
    creation_time = DateTimeProperty()
    epoch = StringProperty()
    id_ = UniqueIdProperty(db_property='id')
    module_builds = RelationshipFrom('ModuleKojiBuild', 'ATTACHED')
    name = StringProperty(index=True)
    owner = RelationshipTo('.user.User', 'OWNED_BY', cardinality=ZeroOrOne)
    release = StringProperty(index=True)
    start_time = DateTimeProperty()
    state = IntegerProperty()
    version = StringProperty(index=True)

    @property
    def display_name(self):
        """Get intuitive (human readable) display name for the node."""
        return '{0}-{1}-{2}'.format(self.name, self.version, self.release)

    @property
    def timeline_datetime(self):
        """Get the DateTime property used for the Estuary timeline."""
        return self.creation_time

    @classmethod
    def find_or_none(cls, identifier):
        """
        Find the node using the supplied identifier.

        :param str identifier: the identifier to search the node by
        :return: the node or None
        :rtype: EstuaryStructuredNode or None
        """
        uid = identifier
        if re.match(r'^\d+$', uid):
            # The identifier is an ID
            return cls.nodes.get_or_none(id_=uid)
        elif uid.endswith('.src.rpm'):
            # The identifer is likely an NVR with .src.rpm at the end, so strip that part of it
            # so it can be treated like a normal NVR
            uid = uid[:-8]

        if len(uid.rsplit('-', 2)) == 3:
            # The identifier looks like an NVR
            nvr = uid.rsplit('-', 2)
            return cls.nodes.get_or_none(name=nvr[0],
                                         version=nvr[1],
                                         release=nvr[2])

        raise ValidationError(
            '"{0}" is not a valid identifier'.format(identifier))
Ejemplo n.º 20
0
class User(StructuredNode):
    __abstract_node__ =  True
    uid=UniqueIdProperty()
    username=StringProperty()
    firstName=StringProperty()
    lastName=StringProperty()
    email=StringProperty()
    cell=StringProperty()
    created=DateTimeProperty()
Ejemplo n.º 21
0
class E1_CRM_Entity(StructuredNode):
    name = StringProperty(unique_index=True, required=True)
    uid = UniqueIdProperty()
    P1_is_identified_by = RelationshipTo("E42_Identifier",
                                         "P1_is_identified_by")
    P48_has_preferred_identifier = RelationshipTo(
        "E42_Identifier",
        "P48_has_preferred_identifier",
        cardinality=ZeroOrOne)
Ejemplo n.º 22
0
class Shelf(DjangoNode):
    uid = UniqueIdProperty(primary_key=True)
    name = StringProperty()

    class Meta:
        app_label = "someapp"

    def __str__(self):
        return self.name
Ejemplo n.º 23
0
class BusinessCapability(StructuredNode):
    BC_ID = UniqueIdProperty()
    BC_NAME = StringProperty()
    BC_DESC = StringProperty()
    BC_TYPE = StringProperty()
    BC_LEVEL = StringProperty()
    bef = RelationshipTo(Organisation, 'BEF')
    bc_child = RelationshipTo('BusinessCapability', 'Child')
    app = RelationshipFrom('Applications', 'APP_BC')
Ejemplo n.º 24
0
class Busstop(StructuredNode):
    uid = UniqueIdProperty()
    name = StringProperty()
    latitude = FloatProperty(index=True)
    longitude = FloatProperty(index=True)

    # Relationship
    next_stop = Relationship('Busstop', 'ROUTE', model=Busroute)
    user = Relationship('User', 'OWNED_BY')
Ejemplo n.º 25
0
class User(StructuredNode, models.Node):
    """
    Person model
    """
    __validation_rules__ = {"username": fields.Str(), "password": fields.Str()}

    uid = UniqueIdProperty()
    username = StringProperty()
    password = StringProperty()
Ejemplo n.º 26
0
class Locations(StructuredNode):
    uid = UniqueIdProperty()
    country = StringProperty(required=True)
    latitude = FloatProperty(required=True)
    longitude = FloatProperty(required=True)
    viewport = JSONProperty(required=False)
    created_at = DateTimeProperty(default_now=True)
    updated_at = DateTimeProperty(default_now=True)
    deleted_at = DateTimeProperty(required=False, default=None)
Ejemplo n.º 27
0
class ServletsEngine(StructuredNode, models.Node):
    """
    servlets engine model
    1. (app)->[USE]->(ServletsEngine)
    """
    servletsengine_id = UniqueIdProperty()
    servletsengine_name = StringProperty()

    app_use = RelationshipFrom("App", "USE")
Ejemplo n.º 28
0
class User(StructuredNode):
    uid = UniqueIdProperty()
    fcm_id = StringProperty()
    token_bal = IntegerProperty()
    name = StringProperty()
    contact = StringProperty(unique_index=True)
    email = EmailProperty()
    knows = RelationshipTo('User', 'knows')
    create_date = DateTimeProperty(default=lambda: datetime.utcnow())
Ejemplo n.º 29
0
class Option(StructuredNode):
    option_id = UniqueIdProperty()
    title = StringProperty(required=True)
    question = RelationshipTo('App.models.Question',
                              'FOR_QUESTION',
                              cardinality=One)
    users = RelationshipFrom('App.models.User',
                             'ANSWERED_TO',
                             cardinality=ZeroOrMore)
Ejemplo n.º 30
0
class RecommendedType(StructuredNode, models.Node):
    """
    host recommended type model
    1. (host)-[USE]->(recommendedType)
    """
    recommendedtype_id = UniqueIdProperty()
    recommendedtype_name = StringProperty()

    host_use = RelationshipFrom("Host", "USE")