示例#1
0
class Paper(StructuredNode):
    """Represents a Paper node in Neo4j"""
    __name__ = 'Paper'
    PaperId = IntegerProperty(unique_index=True)
    Rank = IntegerProperty()
    DOI = StringProperty()
    Doctype = StringProperty()
    name = StringProperty(index=True)
    label = StringProperty()
    Year = IntegerProperty()
    Date = DateProperty()
    Publisher = StringProperty()
    Volume = StringProperty()
    Issue = StringProperty()
    FirstPage = StringProperty()
    LastPage = StringProperty()
    ReferenceCount = IntegerProperty()
    CitationCount = IntegerProperty()
    abstract = StringProperty()
    source = StringProperty()
    prob = FloatProperty()
    community = IntegerProperty()
    UpdatedAt = DateProperty()

    Id = AliasProperty(to='PaperId')
    CC = AliasProperty(to='CitationCount')
    RC = AliasProperty(to='ReferenceCount')

    authors = RelationshipTo('.author.Author', 'HAS_AUTHOR')
    fields = RelationshipTo('.field.FieldOfStudy', 'HAS_FIELD')
    references = RelationshipTo('.paper.Paper', 'CITES')
    cited_by = RelationshipFrom('.paper.Paper', 'CITES')
示例#2
0
class Channel(StructuredNode):
    uid = UniqueIdProperty()
    slug = StringProperty(unique_index=True, required=True)
    title = StringProperty()
    body = StringProperty()
    created_date = DateProperty()
    updated_date = DateProperty()
    image = StringProperty()
    is_featured = BooleanProperty(default=False)
    link = StringProperty()
    follows = RelationshipTo('Channel', 'FOLLOWS')
    likes = RelationshipTo('Track', 'LIKES', model=TrackRel)
示例#3
0
class NeoTempEntity(StructuredNode):
    apis_uri = StringProperty(unique_index=True, required=True)
    n_name = StringProperty(unique=False)
    start_date = DateProperty()
    start_date_written = StringProperty()
    end_date = DateProperty()
    end_date_written = StringProperty()
    ent_type = StringProperty()
    rel_ent = Relationship('NeoTempEntity', 'RELATED', model=NeoTempEntRel)
    neo_project = Relationship('NeoProject', 'RELATED_PROJECT')

    def __str__(self):
        return f"{self.n_name}"
示例#4
0
class Author(StructuredNode):
    print 'Class for Author nodes'
    # Names shoud not be duplicate (Unique_Index=True)
    # http://neo4j.com/docs/stable/query-constraints.html
    name = StringProperty(Unique_Index=True, required=True)
    # The DateProperty accepts datetime.date objects which are stored as a
    # string property YYYY-MM-DD
    born = DateProperty()
    died = DateProperty(default=None)

    wrote = RelationshipTo('Book', 'WROTE', OneOrMore)
    recommended = RelationshipTo('Book',
                                 'RECOMMENDED',
                                 OneOrMore,
                                 model=Recommended)
class Band(StructuredNode):
    emid = IntegerProperty(unique_index=True)
    link = StringProperty()
    visited = DateProperty()
    name = StringProperty()
    country = StringProperty(choices=COUNTRY_NAMES)
    locations = ArrayProperty()
    status = StringProperty(choices=BAND_STATUS)
    formed = DateProperty()
    active = ArrayProperty(DateProperty())
    themes = ArrayProperty()  # Should a theme be a node?
    genres = ArrayProperty()
    current_lineup = RelationshipFrom("Member",
                                      "PLAYED_IN",
                                      model=MemberRelationship)
    releases = RelationshipTo('Release', 'RECORDED')
示例#6
0
class Band(StructuredNode):
    
    # PROPERTIES
    band_id = StringProperty(unique_index=True, required=True)
    name = StringProperty(required=True, unique_index=True)   
    genres = StringProperty(required=True)  
    logo_url = StringProperty() 
    description = StringProperty(required=True) 
    founded = DateProperty(required=True)
    # Edges
    members = RelationshipTo('User', 'HAS_MEMBER')
    rehearsals = RelationshipTo('Rehearsal', 'HAS_SCHEDULED')
    
    def set_founded(self, day, month, year):
        """
            Sets the date object in Student class
            
            :param day: The day
            :param month: The month
            :param year: The year
            :return: True if well formatted and valid date provided. False if not.
            
        """
        try:
            self.founded = date(int(year), int(month), int(day))
            return True
        except Exception as ex:
            # TODO good exception handling!!!
            print(ex)
            return False
示例#7
0
class Transaction_Node(StructuredNode):
    tid = UniqueIdProperty()
    price = FloatProperty(required=True)
    buy = BooleanProperty(required=True)
    quantity = IntegerProperty(required=True)
    date = DateProperty(required=True)
    stock = RelationshipTo(Stock_Node, "TRANSACTIONTOSTOCK")
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')
示例#9
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)
示例#10
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)
示例#11
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()
示例#12
0
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)
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')
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)
示例#15
0
class TechnicalMetadata(TimestampedNode):
    name = StringProperty(required=True)
    sequencing_date = DateProperty()
    platform = StringProperty()
    enrichment_kit = StringProperty()

    defined_in = RelationshipTo("Study", "DEFINED_IN", cardinality=ZeroOrMore)
    describe = RelationshipFrom("Dataset",
                                "IS_DESCRIBED_BY",
                                cardinality=ZeroOrOne)
示例#16
0
class Reader(StructuredNode):
    print 'Class for Reader nodes'

    name = StringProperty(Unique_Index=True, required=True)
    born = DateProperty()

    read = RelationshipTo('Book', 'READ', OneOrMore)
    recommended = RelationshipTo('Book',
                                 'RECOMMENDED',
                                 OneOrMore,
                                 model=Recommended)
示例#17
0
class Student(StructuredNode):

    # Attributes
    student_id = StringProperty(unique_index=True, required=True)
    personal_id = StringProperty(unique_index=True, required=True)
    date_of_birth = DateProperty(required=True)
    name = StringProperty(required=True, index=True)
    last_name = StringProperty(required=True, index=True)
    second_last_name = StringProperty(required=True)
    education_level = StringProperty(required=True, index=True)
    education_level_year = StringProperty(required=True, index=True)
    active = BooleanProperty(required=True)
    section = IntegerProperty(required=True)

    # Edges
    legal_guardians = RelationshipTo('LegalGuardian', 'IS_DEPENDENT_OF')
    courses = RelationshipTo('Course', 'IS_TAKING')
    past_courses = RelationshipTo('Course', 'TOOK')

    # --------------------------------------------------------------------------
    # DICTIONARY PROPERTY
    # --------------------------------------------------------------------------
    @property
    def dictionary(self):
        """
            Gets a dictionary representation of the current instance of Student
            :return: 
        """
        output = {}
        for prop in self.__dict__.keys():
            if not prop.startswith('__'):
                output[prop] = getattr(prop)
        return output

    # --------------------------------------------------------------------------
    # SET DATE OF BIRTH
    # --------------------------------------------------------------------------
    def set_date_of_birth(self, day, month, year):
        """
            Sets the date object in Student class
            
            :param day: The day
            :param month: The month
            :param year: The year
            :return: True if well formatted and valid date provided. False if not.
            
        """
        try:
            self.date_of_birth = date(year, month, day)
            return True
        except Exception as ex:
            # TODO good exception handling!!!
            print(ex)
            return False
示例#18
0
class HotelBooking(StructuredNode):
    uid = UniqueIdProperty()
    booked_at = DateTimeProperty(default_now=True)
    booking_date = DateProperty(required=True)
    days = IntegerProperty(required=True)
    adults = IntegerProperty(required=True)
    children = IntegerProperty(required=True)
    rooms = IntegerProperty(required=True)

    by_user = RelationshipFrom("Traveller", "HAS_BOOKING", model=OwnsRel)
    for_hotel = RelationshipTo("Hotel", "FOR_HOTEL", model=OwnsRel)
示例#19
0
class Organization(StructuredNode):
    rid = IntegerProperty(unique_index=True)
    name = StringProperty(unique_index=True)
    level = DateProperty()
    location = RelationshipTo('Country', 'LOCATION')

    @classmethod
    def from_resource(cls, organization):
        o = cls(rid=organization.id, name=organization.name)
        o.save()
        return o
示例#20
0
class Grade(StructuredNode):

    # ATTRIBUTES ---------------------------------------------------------------
    passing = BooleanProperty(required=True)
    total_points = FloatProperty(required=True)
    value_percentage = FloatProperty(required=True)
    date = DateProperty(required=True)

    # RELATIONS ----------------------------------------------------------------
    student = RelationshipTo('Student', 'WAS_OBTAINED_BY', cardinality=One)
    course = RelationshipTo('Course', 'WAS_OBTAINED_IN', cardinality=One)
    period = RelationshipTo('Period', 'WAS_OBTAINED_DURING', cardinality=One)
示例#21
0
class Trip(StructuredNode):
    uid = UniqueIdProperty()
    destination = StringProperty()
    start_date = DateProperty()
    end_date = DateProperty()
    adults = IntegerProperty()
    infants = IntegerProperty()
    estimated_budget_start = IntegerProperty()
    estimated_budget_end = IntegerProperty()
    events = JSONProperty()
    creation_date = DateTimeProperty(default=datetime.now())
    last_updated = DateTimeProperty(default=datetime.now())

    user = RelationshipTo(User, 'PLANNED_BY')

    @property
    def serialize(self):
        return {
            'node_properties': {
                "id": self.uid,
                "destination": self.destination,
                "start_date": self.start_date,
                "end_date": self.end_date,
                "adults": self.adults,
                "infants": self.infants,
                "estimated_budget_start": self.estimated_budget_start,
                "estimated_budget_end": self.estimated_budget_end,
                "events": self.events,
            },
        }

    @property
    def serialize_connections(self):
        return [
            {
                'nodes_type': 'User',
                'nodes_related': self.serialize_relationships(self.user.all()),
            },
        ]
class User(StructuredNode, flask_login.UserMixin):
    login = StringProperty(required=True, primary=True)
    password = StringProperty(required=True)
    email = EmailProperty()
    birth_date = DateProperty()
    owned_repositories = RelationshipTo("Repository", "OWNS")
    contributed_repositories = RelationshipTo("Repository",
                                              "CONTRIBUTED_TO",
                                              model=ContributedTo)
    recommended_repositories = RelationshipTo("Repository", "RECO")

    def get_id(self):
        return self.login
示例#23
0
class model(StructuredNode, grest.models.Node):
    GREEK = (("A", "Alpha"), ("B", "Beta"), ("G", "Gamma"))

    uuid = UniqueIdProperty()
    string = StringProperty(required=True)
    choices = StringProperty(choices=GREEK)
    integer = IntegerProperty()
    json = JSONProperty()
    array_of_string = ArrayProperty(StringProperty())
    raw_data = ArrayProperty()
    date = DateProperty()
    datetime = DateTimeProperty()
    boolean = BooleanProperty()
    email = EmailProperty()
示例#24
0
class User(StructuredNode):
    username = StringProperty(required=True, max_length=NAME_MAX_LEN, unique_index=True)
    email = EmailProperty(required=True, unique_index=True)
    password = StringProperty(required=True)
    first_name = StringProperty(required=True, max_length=NAME_MAX_LEN)
    last_name = StringProperty(required=True, max_length=NAME_MAX_LEN)
    birthdate = DateProperty(required=True)
    gender = StringProperty(required=True, choices=GENDERS)
    city = StringProperty(required=True, choices=CITIES)
    address = StringProperty(required=False, max_length=ADDRESS_MAX_LEN)
    role = StringProperty(required=True, choices=ROLES)
    authorized = BooleanProperty(default=False)
    reservations = RelationshipTo('Seat', 'RESERVED_A')
    token = RelationshipTo('Token', 'BEARS_A', cardinality=ZeroOrOne)
示例#25
0
class Rehearsal(StructuredNode):
    
    # PROPERTIES
    rehearsal_id = StringProperty(unique_index=True, required=True)
    date = DateProperty(required=True, index=True)
    start_hour = IntegerProperty(required=True)
    start_minute = IntegerProperty(required=True)
    end_hour = IntegerProperty(required=True)
    end_minute = IntegerProperty(required=True)
    place= StringProperty(required=True)
    description = StringProperty(required=True)
    
    # Edges
    band = RelationshipTo('Band', 'SCHEDULED_FOR', cardinality=One)
class Post(StructuredNode):
    @classmethod
    def category(cls):
        pass

    message_count_in_post = IntegerProperty()
    message_date = DateProperty()
    message_date_time_stamp = IntegerProperty()
    message_link = StringProperty()
    post_text = StringProperty()
    poster_profile_url = StringProperty()
    poster_username = StringProperty()
    topic = RelationshipTo('Topic', 'belongs_to')
    written_by = RelationshipTo('Profile', 'written_by')
示例#27
0
class Author(StructuredNode):
    """Represents an Author node in Neo4j"""
    __name__ = 'Author'
    AuthorId = IntegerProperty(index=True)
    Rank = IntegerProperty()
    name = StringProperty(index=True)
    label = StringProperty()
    PaperCount = IntegerProperty()
    CitationCount = IntegerProperty()
    UpdatedAt = DateProperty()

    Id = AliasProperty(to='AuthorId')

    papers = RelationshipFrom('.paper.Paper', 'HAS_AUTHOR')
示例#28
0
class Structure(Resource):
    deposit_date = DateProperty()
    method = StringProperty()

    @classmethod
    def from_resource(cls, sample):
        g = cls(rid=sample.id,
                title=sample.name,
                subdivision=sample.subdivision,
                collection_date=sample.collection_date)
        g.save()
        if sample.country:
            c = Country.nodes.get(name=sample.country)
            r.country.connect(c)
        return g
示例#29
0
class Paper(StructuredNode):
    pmid = StringProperty(unique_index=True, required=True)
    pmcid = StringProperty(index=True)
    doi = StringProperty(index=True)
    ppr = StringProperty(index=True)
    title = StringProperty()
    date = DateProperty(required=True, index=True)
    date_type = StringProperty(required=True)

    publish_on = RelationshipFrom('Journal', "PUBLISH", OneOrMore)
    authors = RelationshipFrom('Author', "WRITE", OneOrMore, model=PaperAuthor)
    references = RelationshipTo("Paper", "REFER", OneOrMore)
    cited_by = RelationshipFrom("Paper", "REFER", OneOrMore)
    entities = RelationshipTo('Entity', "APPEAR", OneOrMore, model=PaperEntity)
    pub_types = RelationshipTo('PubType', "IS_A", OneOrMore)
示例#30
0
class Sample(Resource):
    country = RelationshipTo('Country', 'COUNTRY')
    subdivision = StringProperty()
    collection_date = DateProperty()

    @classmethod
    def from_resource(cls, sample):
        g = cls(rid=sample.id,
                title=sample.name,
                subdivision=sample.subdivision,
                collection_date=sample.collection_date)
        g.save()
        if sample.country:
            c = Country.nodes.get(name=sample.country)
            r.country.connect(c)
        return g