Example #1
0
class User(GeniusNode):
    '''
    Represents user data from Genius.com
    '''

    genius_id = IntegerProperty()

    # TODO: Build connections with annotations
    api_path = StringProperty(unique_index=True)
    avatar = JSONProperty()
    header_image_url = StringProperty()
    human_readable_role_for_display = StringProperty()
    iq = IntegerProperty()
    login = StringProperty(unique_index=True)
    name = StringProperty()
    role_for_display = StringProperty()
    url = StringProperty()

    @classmethod
    def inst(cls, **kwargs):
        kwargs['genius_id'] = kwargs.pop('id')
        kwargs.pop('current_user_metadata')

        # TODO: clean this shit

        raise NotImplementedError('Not fully implemented yet')
Example #2
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()],
        }
Example #3
0
class Person(StructuredNode):
    name = StringProperty()
    person_id = IntegerProperty()
    gender = IntegerProperty()

    acts_in = RelationshipTo("Movie", "ACTS_IN", model=ActsIn)
    crew_of = RelationshipTo("Movie", "CREW_IN", model=CrewIn)
Example #4
0
class Info(StructuredNode):

	# ---- attributi
	info_id = StringProperty(UniqueIndex=True, Required=True)
	END = IntegerProperty()
	ID = StringProperty()
	QUAL = FloatProperty()
	FILTER = StringProperty()
	FORMAT = StringProperty()
	HETEROZIGOSITY = FloatProperty()
	dbSNP = StringProperty()

	DP = FloatProperty()
	Gene_refGene = ArrayProperty()
	Func_refGene = ArrayProperty()
	QD = FloatProperty()
	SIFT_score = FloatProperty()
	otg_all = FloatProperty()
	NM = IntegerProperty()
	LM = ArrayProperty()
	FS = FloatProperty()
	MQ0 = FloatProperty()
	attributes = JSONProperty()

	# ---- relazioni
	contains = RelationshipFrom('File', 'Contains')
	supportedBy = RelationshipTo('Genotype', 'Supported_By', model=SupportedByRel)
	forVariant = RelationshipTo('Variant', 'For_Variant')
class LinkRel(StructuredRel):
    last_seen = DateTimeProperty(default=lambda: datetime.now())
    input_rate = IntegerProperty()
    output_rate = IntegerProperty()
    speed = IntegerProperty()
    local_port = StringProperty()
    remote_port = StringProperty()
Example #6
0
class Comment(TaggableContent):
    table = StringProperty(default='comments')
    up_vote_adjustment = IntegerProperty(default=2)
    down_vote_adjustment = IntegerProperty(default=-1)
    # Valid values for visibility are private and public. If this is set to
    # public any votes on the content will be counted towards reputation.
    action_name = StringProperty(default="commented on your ")
    parent_type = StringProperty()
    parent_id = StringProperty()
    comment_on = RelationshipTo('sb_base.neo_models.SBContent', 'COMMENT_ON')

    @classmethod
    def get_comment_on(cls, object_uuid):
        from sb_base.neo_models import SBContent
        query = 'MATCH (c:Comment {object_uuid:"%s"})<-[:HAS_A]-(o) ' \
                'RETURN o' % object_uuid
        res, _ = db.cypher_query(query)
        return SBContent.inflate(res.one)

    @classmethod
    def get_mission(cls, object_uuid, request):
        from sb_solutions.neo_models import Solution
        from sb_questions.neo_models import Question
        comment = Comment.nodes.get(object_uuid=object_uuid)
        if comment.parent_type == "solution":
            return Solution.get_mission(comment.parent_id, request)
        elif comment.parent_type == "question":
            return Question.get_mission(comment.parent_id, request)
        else:
            return None
Example #7
0
class Patient(DjangoNode):
    name = StringProperty(required=True)
    last_name = StringProperty(required=True)
    NFZ_ID = IntegerProperty(required=True)
    addres = StringProperty(required=True)
    phone = IntegerProperty()
    hospitalized = RelationshipTo("Hospital",
                                  "HOSPITALIZED",
                                  cardinality=ZeroOrOne)
    treatments = RelationshipTo("Treatment",
                                "HAS/HAD SCHEDULDED",
                                cardinality=ZeroOrMore)

    def __str__(self):
        return f"{self.NFZ_ID} - {self.name} {self.last_name}"

    def details(self):
        a = [
            ('Numer NFZ:', self.NFZ_ID),
            ('Adres: ', self.addres),
        ]
        if self.phone:
            a.append(('Telefon: ', self.phone))
        return a

    def url(self):
        return f'/view?patient_choosment={self.NFZ_ID}'
Example #8
0
class User(StructuredNode):
    id_str = StringProperty(unique_index=True, required=True)
    screen_name = StringProperty(required=False)
    followers_count = IntegerProperty(required=False)
    friends_count = IntegerProperty(required=False)
    description = StringProperty(required=False)
    follows = RelationshipTo('User', 'FOLLOWS')
Example #9
0
class Media(StructuredNode):
    media_id = IntegerProperty(unique_index=True)
    caption = StringProperty()
    taken_at = DateTimeProperty()
    comments_disabled = BooleanProperty()
    display_url = StringProperty()
    shortcode = StringProperty()

    location = RelationshipFrom('.locations.Location', 'TAGGED_LOCATION')
    accessibility_caption = StringProperty()

    height = IntegerProperty()
    width = IntegerProperty()

    liked_by = RelationshipFrom('.users.User', "LIKES")
    comments = RelationshipFrom('.interactions.Comment', 'ON')
    hashtags = RelationshipTo('.tags.Hashtag', "MENTIONED")
    tagged_users = RelationshipTo('.users.User',
                                  "TAGGED_USER",
                                  model=TaggedUserRel)

    edge_liked_by_count = IntegerProperty()
    edge_comments_count = IntegerProperty()

    has_ranked_comments = BooleanProperty()
    is_ad = BooleanProperty()
    caption_is_edited = BooleanProperty()

    owner = RelationshipFrom('.users.User',
                             "POSTED",
                             model=PostRel,
                             cardinality=One)
    sponsors = RelationshipTo('.users.User', "SPONSORED_BY")
Example #10
0
class Node(StructuredNode):
    handle_id = IntegerProperty(blank=False)
    is_real = BooleanProperty(default = False)
    tree_size = IntegerProperty(default = 1)
    content = StringProperty(default='')
    content_size = IntegerProperty()
    max_id = IntegerProperty(default=0)
    min_id = IntegerProperty(default=0)
    left = RelationshipTo('Node', 'left')
    right = RelationshipTo('Node', 'right')
    father = RelationshipTo('Node', 'father')
    #depth = IntegerProperty(blank=False, default=1)
    def update(self):
        lsize = 0 if len(self.left.all()) == 0 else self.left.all()[0].tree_size
        rsize = 0 if len(self.right.all()) == 0 else self.right.all()[0].tree_size
        self.tree_size = lsize + rsize + 1
        nc = ""
        for i in range(0, self.content_size):
            lc = 0 if len(self.left.all()) == 0 else int(self.left.all()[0].content[i])
            rc = 0 if len(self.right.all()) == 0 else int(self.right.all()[0].content[i])
            nc += str(lc | rc)
        if self.tree_size > 1:
            self.min_id = self.left.all()[0].min_id if not len(self.left.all()) == 0 else self.right.all()[0].min_id
            self.max_id = self.right.all()[0].max_id if not len(self.right.all()) == 0 else self.left.all()[0].max_id
            self.id = self.right.all()[0].min_id if not len(self.right.all()) == 0 else self.left.all()[0].max_id + 1
Example #11
0
class Movie(StructuredNode):
    oid = StringProperty(unique_index=True)
    imdb_id = StringProperty()
    original_title = StringProperty()
    title = StringProperty()
    original_language = StringProperty()
    overview = StringProperty()
    popularity = FloatProperty()
    status = StringProperty()
    tagline = StringProperty()
    adult = BooleanProperty()
    poster_path = StringProperty()
    video = StringProperty()
    release_date = DateProperty()
    revenue = IntegerProperty()
    budget = IntegerProperty()
    runtime = FloatProperty()
    homepage = StringProperty()
    vote_average = FloatProperty()
    vote_count = IntegerProperty()

    genres = RelationshipTo(".genre.Genre", "IS_KIND")
    spoken_languages = RelationshipFrom(".language.Language", "SPOKEN_IN")
    keywords = RelationshipTo("Keyword", "CONTAINS")
    produced_by = RelationshipTo(".production_company.ProductionCompany",
                                 "PRODUCED_BY")
    produced_in = RelationshipTo(".production_country.ProductionCountry",
                                 "PRODUCED_IN")
    is_part_of = RelationshipTo(".collection.Collection", "IS_PART_OF")

    acted_in = RelationshipFrom("Person", "ACTS_IN", model=ActsIn)
    crew_in = RelationshipFrom("Person", "CREW_IN", model=CrewIn)
Example #12
0
class Hallway(StructuredNode, Node):
    """Hallway model"""
    __validation_rules__ = {
        "uid": fields.Str(),
        "name": fields.Str(required=True),
        'markerId': fields.Int(required=True),
        "buildingName": fields.Str(required=True),
        "floorLevel": fields.Int(required=True),
        'shapeType': fields.Str(required=False),
        'color': fields.Str(required=False),
        'width': fields.Float(required=False),
        'length': fields.Float(required=False),
        'x': fields.Float(required=False),
        'y': fields.Float(required=False),
    }

    uid = UniqueIdProperty()
    name = StringProperty(required=True, index=True)
    markerId = IntegerProperty(required=True, index=True)
    buildingName = StringProperty(required=True, index=True)
    floorLevel = IntegerProperty(required=True, index=True)
    shapeType = StringProperty(required=False)
    color = StringProperty(required=False)
    width = FloatProperty(required=False)
    length = FloatProperty(required=False)
    x = FloatProperty(required=False)
    y = FloatProperty(required=False)
    floor = RelationshipFrom('models.Floor', 'HAS', cardinality=One)

    def pre_save(self):
        Floor.nodes.get(buildingName=self.buildingName, level=self.floorLevel)

    def post_save(self):
        Floor.nodes.get(buildingName=self.buildingName,
                        level=self.floorLevel).hallways.connect(self)
Example #13
0
class Coffee(StructuredNode):
    name = StringProperty(unique_index=True)
    price = IntegerProperty()
    suppliers = RelationshipFrom(Supplier,
                                 'COFFEE SUPPLIERS',
                                 model=SupplierRel)
    id_ = IntegerProperty()
Example #14
0
class FreshmakerEvent(EstuaryStructuredNode):
    """Definition of a Freshmaker event in Neo4j."""

    event_type_id = IntegerProperty()
    id_ = UniqueIdProperty(db_property='id')
    message_id = StringProperty()
    state = IntegerProperty()
    state_name = StringProperty()
    state_reason = StringProperty()
    time_created = DateTimeProperty()
    time_done = DateTimeProperty()
    triggered_by_advisory = RelationshipTo(
        '.errata.Advisory', 'TRIGGERED_BY', cardinality=ZeroOrOne)
    successful_koji_builds = RelationshipTo('.koji.ContainerKojiBuild', 'TRIGGERED')
    requested_builds = RelationshipTo('.FreshmakerBuild', 'TRIGGERED')

    @property
    def display_name(self):
        """Get intuitive (human readable) display name for the node."""
        return 'Freshmaker event {0}'.format(self.id_)

    @property
    def timeline_datetime(self):
        """Get the DateTime property used for the Estuary timeline."""
        return self.time_created
Example #15
0
class Hotel(StructuredNode):
    uid = UniqueIdProperty()
    name = StringProperty(max_length=120, required=True)
    price = IntegerProperty(required=True)
    description = StringProperty(max_length=4096, required=True)
    photos = ArrayProperty(required=True, base_property=StringProperty())
    address = StringProperty(max_length=512, required=True)
    locality = StringProperty(required=True)
    postal_code = IntegerProperty(required=True)
    latitude = FloatProperty(required=True)
    longitude = FloatProperty(required=True)
    phone = RegexProperty(expression=r"^\+(\d){12}$", required=True)
    amenities = ArrayProperty(base_property=StringProperty(choices=HOTEL_AMENITIES))

    located_in = RelationshipTo(
        "City", "LOCATED_IN", model=OwnsRel, cardinality=cardinality.One
    )

    owned_by = RelationshipFrom("HotelOwner", "OWNS_HOTEL", model=OwnsRel)

    liked_by = RelationshipFrom("Traveller", "LIKES_HOTEL", model=LikesRel)

    has_booking = RelationshipFrom("HotelBooking", "FOR_HOTEL", model=OwnsRel)
    reviewed_by = RelationshipFrom("Traveller", "REVIEWED_HOTEL", model=ReviewedRel)

    stayed_by = RelationshipFrom("Traveller", "STAYED_AT_HOTEL", model=StayedAtRel)
Example #16
0
class Role(StructuredNode):
    uid = IntegerProperty(unique_index=True, required=True)
    name = StringProperty(required=True)
    permissions = IntegerProperty(required=True)

    parents = RelationshipTo('Role', 'R_CHILD_OF')
    board = RelationshipFrom('Board', 'ROLE_OF', cardinality=One)
class Profile(StructuredNode):
    @classmethod
    def category(cls):
        pass

    poster_username = StringProperty()
    poster_profile_url = StringProperty()
    poster_profile_id = IntegerProperty()
    aim = StringProperty()
    activity = IntegerProperty()
    age = IntegerProperty()
    date_registered = IntegerProperty()
    email = EmailProperty()
    gender = StringProperty()
    icq = StringProperty()
    last_active = DateProperty()
    location = StringProperty()
    msn = StringProperty()
    merit = StringProperty()
    position = StringProperty()
    post_count = IntegerProperty()
    signature = StringProperty()
    website = StringProperty()
    yim = StringProperty()
    posted = RelationshipTo('Post', 'written')
Example #18
0
class Bus(StructuredNode):
    Name = StringProperty()
    Fare = IntegerProperty()

    name = StringProperty()
    Fare = IntegerProperty(default=0.0)  # add kea hay int

    stopat = Relationship(Station, 'STOPAT')
class Summoner(StructuredNode):
    summoner_name = StringProperty(unique_index=True)
    summoner_id = StringProperty(unique_index=True)
    account_id = StringProperty(unique_index=True)
    summoner_level = IntegerProperty(unique_index=True)
    profile_icon_id = IntegerProperty()
    last_match_history_update = DateProperty()
    games = Relationship("league_analytics_bot.model.GameInstance", "PLAYED_IN", model=PlayedInRel)
Example #20
0
class BaseMolecule(StructuredNode):
    smiles = StringProperty(unique_index=True)
    heavy_atom_count = IntegerProperty()
    ring_atom_count = IntegerProperty()
    ring_smiles = StringProperty()
    # Annotations of price and molecule id
    price = IntegerProperty()
    mol_id = StringProperty()
class Release(StructuredNode):
    emid = IntegerProperty(unique_index=True)
    name = StringProperty()
    link = StringProperty()
    release_type = StringProperty(choices=RELEASE_TYPES)
    rating = IntegerProperty()
    review_count = IntegerProperty()
    release_date = DateProperty()
    recorded_by = RelationshipFrom('Band', 'RECORDED')
Example #22
0
class City(StructuredNode, NodeUtils):
    elevation = StringProperty()
    digital_elevation_model = IntegerProperty()
    geonameid = IntegerProperty()
    timezone = StringProperty()
    latitude = FloatProperty()
    population = IntegerProperty()
    alternatenames = StringProperty()
    country_code = StringProperty()
    feature_class = StringProperty()
    composite_id = StringProperty()
    name = StringProperty()
    asciiname = StringProperty()
    feature_code = StringProperty()
    alternate_country_codes = FloatProperty()
    longitude = FloatProperty()
    country = RelationshipFrom(Country, 'IS_IN')

    @property
    def serialize(self):
        return {
            'node_properties': {
                "elevation": self.elevation,
                "digital_elevation_model": self.digital_elevation_model,
                "geonameid": self.geonameid,
                "timezone": self.timezone,
                "latitude": str(self.latitude),
                "population": self.population,
                "alternatenames": self.alternatenames,
                "country_code": self.country_code,
                "feature_class": self.feature_class,
                "composite_id": self.composite_id,
                "name": self.name,
                "asciiname": self.asciiname,
                "feature_code": self.feature_code,
                "alternate_country_codes": str(self.alternate_country_codes),
                "longitude": str(self.longitude)
            },
        }

    @property
    def serialize_connections(self):
        return [
            {
                'nodes_type': 'Country',
                'nodes_related':
                self.serialize_relationships(self.country.all()),
            },
        ]

    def getData(self, city_name, country_code):
        self.cypher(
            "MATCH (c:City) where toLower(c.name) = {city_name} and "
            "c.country_code = {country_code} and toString(c.latitude) "
            "starts with toString({city_lat}) and toString(c.longitude) "
            "starts with toString({city_lon}) MATCH (u:User)  "
            "where u.id = {current_user_id}")
Example #23
0
class Actor(StructuredNode):
    idactors = UniqueIdProperty()
    lname = StringProperty()
    fname = StringProperty()
    mname = StringProperty()
    gender = IntegerProperty()
    number = IntegerProperty()

    movies = Relationship('Movie', 'ACTED_IN')
Example #24
0
class Redditor(StructuredNode):
    rid = StringProperty(unique_index=True)
    name = StringProperty(index=True)
    comment_karma = IntegerProperty()
    link_karma = IntegerProperty()
    is_employee = BooleanProperty()
    is_mod = BooleanProperty()
    is_gold = BooleanProperty()
    created_utc = DateTimeProperty(index=True)
class Member(StructuredNode):
    emid = IntegerProperty(unique_index=True)
    link = StringProperty()
    visited = DateProperty()
    name = StringProperty()
    age = IntegerProperty()
    origin = StringProperty(choices=COUNTRY_NAMES)
    gender = StringProperty(choices=GENDER)
    played_in = RelationshipTo("Band", "PLAYED_IN", model=MemberRelationship)
Example #26
0
class Channel(StructuredNode):
    uid = IntegerProperty(unique_index=True, required=True)
    position = IntegerProperty(required=True)
    type = IntegerProperty(required=True)
    name = StringProperty(required=True)
    topic = StringProperty(required=False)

    board_parent = RelationshipTo('Board', 'CHANNEL_OF', cardinality=One)
    messages = RelationshipFrom('Message', 'POSTED_TO', cardinality=ZeroOrMore)
Example #27
0
class GTCommittee(StructuredNode):
    abbrev = StringProperty()
    code = StringProperty()
    committee_id = IntegerProperty(unique_index=True)
    person = IntegerProperty()
    role = StringProperty()
    role_label = StringProperty()

    # relationships
    committee = RelationshipTo('GTCommittee', 'HAS_A_SUB')
Example #28
0
class PaperSimple(StructuredNode):
    """Represents a Paper node in Neo4j"""
    id = IntegerProperty(unique_index=True)
    cc = IntegerProperty()
    year = IntegerProperty()
    abstract = StringProperty()
    label = StringProperty()
    source = StringProperty()
    title = StringProperty(index=True)
    doi = StringProperty()
    prob = FloatProperty()
Example #29
0
class Comment(StructuredNode):
    comment_id = IntegerProperty(unique_index=True)
    text = StringProperty()
    owner = RelationshipFrom(".users.User",
                             "COMMENTED",
                             model=CommentRel,
                             cardinality=One)
    post = RelationshipTo(".media.Media", "ON", cardinality=One)
    edge_liked_by_count = IntegerProperty()
    edge_threaded_comments_count = IntegerProperty()
    replies = RelationshipTo("ThreadedComment", "REPLY")
Example #30
0
class SearchQuery(StructuredNode):
    weight = IntegerProperty(default=0)
    search_query = StringProperty(unique_index=True)
    times_searched = IntegerProperty(default=1)
    last_searched = DateTimeProperty(default=get_current_time)
    trending = BooleanProperty(default=False)

    # relationships
    searched_by = Relationship('plebs.neo_models.Pleb', 'SEARCHED_BY')
    keywords = RelationshipTo(KeyWord, 'KEYWORDS', model=KeyWordRel)
    results = RelationshipTo(SearchResult, 'RESULT')