コード例 #1
0
class Product(StructuredNode):
    created_at = DateTimeProperty()
    updated_at = DateTimeProperty()
    name = StringProperty()
    label_id = IntegerProperty()
    price = FloatProperty()
    color = StringProperty()
    style = StringProperty()

    similar = Relationship('Product', 'SIMILARITY_SCORE')
    category = RelationshipFrom('ProductsCategory', 'HAS_PRODUCT')
    styles = RelationshipFrom('Style', 'PRODUCT_STYLE')
    brand_rel = RelationshipTo('Brand', 'BRAND')
    prime_rel = RelationshipTo('Primary_Material', 'PRIMARY MATERIAL')
コード例 #2
0
class Course(StructuredNode):
    name = StringProperty(required=True)
    description = StringProperty(required=True)
    taught_on_semester = IntegerProperty(required=True)
    is_elective = BooleanProperty(default=False)

    student_mark = RelationshipTo('.Student.Student',
                                  'EVALUATES',
                                  model=ValuedRelationship)
    professor = RelationshipFrom('.Professor.Professor', 'TEACHES')
    keyword = RelationshipFrom('.Keyword.Keyword',
                               'DESCRIBES',
                               model=ValuedRelationship)
    field_of_study = RelationshipTo('.FieldOfStudy.FieldOfStudy', 'HAS')
コード例 #3
0
class Comment(StructuredNode):
    uid = UniqueIdProperty()
    author = RelationshipFrom('User', 'AUTHOR', cardinality=One)
    text = StringProperty()
    date = DateTimeProperty(
        default=lambda: datetime.now(pytz.utc)
    )
    post = RelationshipTo('Post', "COMMENT")
    liked_by = RelationshipFrom('User', 'LIKED BY', model=Like)
    commented_by = RelationshipFrom('Comment', 'COMMENTED BY')

    @property
    def name(self):
        return f"{self.author.name}'s comment" if self.author else None
コード例 #4
0
ファイル: room.py プロジェクト: rukaury/vsrpapi
class Room(StructuredNode):
    """
    Class to represent the VSR room node
    """
    uuid = UniqueIdProperty()
    name = StringProperty(required=True)
    active = BooleanProperty(required=True)

    # traverse outgoing PARTICIPANT relationship, inflate Users who are in the room
    participants = RelationshipFrom("app.models.user.User",
                                    'PARTICIPATES_IN',
                                    cardinality=ZeroOrMore,
                                    model=BaseRel)
    # traverse outgoing CREATED_BY relationship, inflate User who created/owns the room
    admin = RelationshipTo("app.models.user.User",
                           'CREATED_BY',
                           cardinality=One,
                           model=BaseRel)
    # traverse the PRACTICES relations, inflate the class it studies
    course = RelationshipTo("app.models.course.Course",
                            'PRACTICES',
                            cardinality=One,
                            model=BaseRel)
    # traverse the incoming ASKED_IN relationship, inflate the question class
    questions = RelationshipFrom("app.models.question.Question",
                                 "ASKED_IN",
                                 cardinality=ZeroOrMore,
                                 model=BaseRel)

    def update(self, name, course, rel):
        """
        Function will update the course
        :param code: the new course code
        """

        self.name = name if name is not None else self.name

        if course:
            self.course.reconnect(self.course.get(), course)
        rel.updated_on = datetime.datetime.now()
        self.save()

    def json(self):
        """
        Json representation of the room model.
        :return name: the name of the room entered by the admin
        :return active: flag representing if the room is active (true) or disabled (false)
        :return rid: the uuid of the room
        """
        return {"name": self.name, "active": self.active, "room_id": self.uuid}
コード例 #5
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)
コード例 #6
0
class Department(StructuredNode):
    ident = ArrayProperty(IntegerProperty(), unique_index = True, required = True)

    shifts = RelationshipFrom('shift.Shift', 'INCORPORATION')
    operations = RelationshipFrom('operation.Operation', 'INCORPORATION')

    controller = RelationshipFrom('person.Person', 'DIRECTOR', cardinality=One)

    def __init__(self, *args, **kwargs):
        kwargs['ident'] = mongo_adapter.validate_id('department_test', kwargs['ident'])
        super(Department, self).__init__(self, *args, **kwargs)

    @property
    def ident_hex(self):
        return mongo_adapter.int_to_mongo_str_id(self.ident) if self.ident else None
コード例 #7
0
class Blog(StructuredNode):
    uid = UniqueIdProperty()
    title = StringProperty(max_length=512, required=True)
    content = StringProperty(max_length=4096, required=True)
    published_on = DateTimeProperty(default_now=True)
    photos = ArrayProperty(base_property=StringProperty())

    authored_by = RelationshipFrom("Traveller", "AUTHOR_OF", model=OwnsRel)

    read_by = RelationshipFrom("Traveller", "READ_BLOG", model=VisitedRel)
    liked_by = RelationshipFrom("Traveller", "LIKES_BLOG", model=LikesRel)
    commented_by = RelationshipFrom("Traveller", "COMMENTED_ON", model=CommentedOnRel)

    tagged_topic = RelationshipTo("Topic", "TAGGED_TOPIC", model=TaggedRel)
    tagged_location = RelationshipTo("Location", "TAGGED_LOCATION", model=TaggedRel)
コード例 #8
0
class Group(StructuredNode):
    uuid = StringProperty(unique_index=True, default=uuid4)
    address = StringProperty()
    name = StringProperty()
    currency = StringProperty(required=True)
    approval_required = BooleanProperty()
    members = RelationshipFrom('User', 'MEMBER_OF', model=MemberOf)
    corporate_entity = RelationshipTo(
        'CorporateEntity',
        'MEMBER_OF_CORPORATE_ENTITY',
        cardinality=cardinality.One)  # can belong to only one corporate entity
    corporate_members = RelationshipFrom('User',
                                         'CORPORATE_GROUP_RELATION',
                                         model=CorporateGroupRelation)
    bills = RelationshipFrom('Bill', 'BILL_OF', model=BillOf)
コード例 #9
0
class Movie(StructuredNode, models.Node):
    " Definition of the movie model"
    __validation_rules__ = {"movie_id": fields.Str(), "title": fields.Str()}

    movie_id = UniqueIdProperty()
    title = StringProperty()
    genres = RelationshipFrom("Movie", "HAS_GENRE")
コード例 #10
0
ファイル: models.py プロジェクト: trevorthyme/BandcampScraper
class Album(StructuredNode):
    # We assign a uid instead of using bandcamps internal id because it's not always
    #   consistent. Instead we use the url as our unique "key" since no two albums
    #   could have the same link.
    uid = UniqueIdProperty()
    url = StringProperty(unique_index=True)

    # Name of the album
    name = StringProperty()
    # We store the band name because it's useful for filtering so you don't just
    #   reccommend the same bands albums to a person.
    band_name = StringProperty()

    # genres and fans are our "foreign keys" edges to our Genre and Fan classes
    genres = RelationshipTo('Genre', 'TAGGED')
    fans = RelationshipFrom('Fan', 'BOUGHTBY')

    # Returns all Genres connected to the Album
    def getGenres(self):
        results, columns = self.cypher(
            "MATCH (a) WHERE a.url = '{}' MATCH (a)-[:TAGGED]->(b) RETURN b".
            format(self.url))
        return [self.inflate(row[0]) for row in results]

    # Returns all Fans connected to the Album
    def getFans(self):
        results, columns = self.cypher(
            "MATCH (a) WHERE a.url = '{}' MATCH (a)<-[:BOUGHTBY]-(b) RETURN b".
            format(self.url))
        return [self.inflate(row[0]) for row in results]
コード例 #11
0
ファイル: test_match_api.py プロジェクト: Mkang1204/SCRIPTapi
class Coffee(StructuredNode):
    name = StringProperty(unique_index=True)
    price = IntegerProperty()
    suppliers = RelationshipFrom(Supplier,
                                 'COFFEE SUPPLIERS',
                                 model=SupplierRel)
    id_ = IntegerProperty()
コード例 #12
0
class ContainerKojiBuild(KojiBuild):
    """A Neo4j definition of a build that represents a container build in Koji."""

    original_nvr = StringProperty()
    triggered_by_freshmaker_event = RelationshipFrom(
        '.freshmaker.FreshmakerEvent', 'TRIGGERED', cardinality=ZeroOrOne)
    operator = BooleanProperty(default=False)
コード例 #13
0
class WorkLoad(StructuredNode):
    name = StringProperty(unique_index=True, required=True)
    workLoadType = StringProperty()
    version = StringProperty()
    metaData = StringProperty()
    spec = StringProperty()
    component = RelationshipFrom('Component', 'PART_OF')
コード例 #14
0
class Collection(StructuredNode):
    collection_id   = IntegerProperty(unique_index=True)
    name            = StringProperty()
    poster_path     = StringProperty()
    backdrop_path   = StringProperty()
    
    has_movies      = RelationshipFrom(".movie.Movie", "IS_PART_OF")
コード例 #15
0
 def addRelationToNodeType(crispClass, relName, relTo, relFrom):
     if relTo:
         rel = RelationshipTo(relTo, relName)
     elif relFrom:
         rel = RelationshipFrom(relFrom, relName)
     setattr(crispClass, relName, rel)
     return rel
コード例 #16
0
class DatasetModel(StructuredNode):
    label = StringProperty(index=True)
    description = StringProperty()
    uri = StringProperty(unique_index=True)
    hashed_uri = StringProperty(unique_index=True)

    license = RelationshipFrom("LicenseModel", "Protects")
コード例 #17
0
class PageN(StructuredNode):
    """
        Node representation of a page
    """
    href = StringProperty(unique_index=True, required=True)
    profiles = RelationshipFrom('ProfileN', 'IS_FROM')
    website = RelationshipTo(WebsiteN, 'BELONGS_TO')
コード例 #18
0
class Application(StructuredNode):
    uid = IntegerProperty(unique_index=True, required=True)
    name = StringProperty(required=True)
    description = StringProperty(required=True)
    redirect_uri = StringProperty(required=True)

    owner = RelationshipFrom('User', 'OWNS', cardinality=One)
コード例 #19
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)
コード例 #20
0
class Client(StructuredNode):
    uid = IntegerProperty(unique_index=True, required=True)
    username = StringProperty(required=True)
    discriminator = StringProperty(required=True)

    messages = RelationshipFrom('Message', 'SAID_BY', cardinality=ZeroOrMore)
    boards = RelationshipTo('Board', 'SUBSCRIBED_TO', cardinality=ZeroOrMore)
コード例 #21
0
class Keyword(StructuredNode):
    name = StringProperty(unique_index=True, required=True)
    topic = RelationshipFrom('Topic', 'hasKeyword', model=WeightRel)

    @property
    def serialize(self):
        return self.__properties__
コード例 #22
0
class Board(StructuredNode):
    uid = IntegerProperty(unique_index=True, required=True)
    name = StringProperty(required=True)
    #    owner_id = IntegerProperty(required=True)

    subscribers = RelationshipFrom('User',
                                   'SUBSCRIBED_TO',
                                   model=Subscribed_To,
                                   cardinality=OneOrMore)

    roles = RelationshipFrom('Role', 'ROLE_OF', cardinality=OneOrMore)
    board_parents = RelationshipTo('Board', 'B_CHILD_OF')
    board_children = RelationshipFrom('Board', 'B_CHILD_OF')
    channel_children = RelationshipFrom('Channel',
                                        'CHANNEL_OF',
                                        cardinality=OneOrMore)
コード例 #23
0
class User(StructuredNode):
    uid = UniqueIdProperty()
    name = StringProperty()
    following = RelationshipFrom('User', 'FOLLOWS', model=Follow)
    followers = RelationshipTo('User', 'FOLLOWED BY', model=Follow)
    likes = RelationshipTo('Photo', 'LIKES', model=Like)
    posts = RelationshipTo('Post', 'ADDED')
コード例 #24
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)
コード例 #25
0
ファイル: model.py プロジェクト: s-perfilev/bcsb
class Show(StructuredNode):
    def __init__(self, *args, **kwargs):

        # leads to lower case title
        if 'title' in kwargs:
            kwargs['title_lower'] = kwargs['title'].lower()

        try:
            super(Show, self).__init__(*args, **kwargs)
        except:
            pass

    title = StringProperty(required=True)
    title_lower = StringProperty(unique_index=True, required=True)

    # traverse incoming IS_SUBSCRIBED_FOR relation, inflate to Person objects
    subscribers = RelationshipFrom('Chat', 'IS_SUBSCRIBED_FOR')

    # traverse outgoing HAS relation, inflate to Season objects
    seasons = RelationshipTo('Season', 'HAS')

    @property
    def available_seasons(self):
        return [s for s in self.seasons.all() if s.is_available]

    @property
    def unavailable_seasons(self):
        return [s for s in self.seasons.all() if not s.is_available]

    @property
    def is_available(self):
        return bool(len(self.available_seasons))
コード例 #26
0
class FreshmakerBuild(EstuaryStructuredNode):
    """Definition of a Freshmaker build in Neo4j."""

    id_ = UniqueIdProperty(db_property='id')
    build_id = IntegerProperty()
    dep_on = StringProperty()
    name = StringProperty()
    original_nvr = StringProperty()
    rebuilt_nvr = StringProperty()
    state_name = StringProperty()
    state_reason = StringProperty()
    time_completed = DateTimeProperty()
    time_submitted = DateTimeProperty()
    type_name = StringProperty()
    koji_builds = RelationshipTo('.koji.ContainerKojiBuild',
                                 'TRIGGERED_BY',
                                 cardinality=ZeroOrOne)
    event = RelationshipFrom('.FreshmakerEvent',
                             'TRIGGERED',
                             cardinality=ZeroOrOne)

    @property
    def display_name(self):
        """Get intuitive (human readable) display name for the node."""
        return 'Freshmaker build {0}'.format(self.id_)
コード例 #27
0
ファイル: models.py プロジェクト: Guigxs/ProjetMyShop
class Product(StructuredNode):
    category = RelationshipTo('Category', "PART_OF")
    name = StringProperty(max_length=200, index=True)
    slug = StringProperty(max_length=200, index=True)
    image = StringProperty()
    description = StringProperty()
    price = FloatProperty()
    available = StringProperty(default="1")
    created = StringProperty(
        default=datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
    updated = StringProperty(
        default=datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
    orders = RelationshipFrom("orders.models.Order", "CONTAINS")

    # created = DateTimeFormatProperty(default_now=True, format='%Y-%m-%d %H:%M:%S')
    # updated = DateTimeFormatProperty(default_now=True, format='%Y-%m-%d %H:%M:%S')

    def __str__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('shop:product_detail', args=[self.id, self.slug])

    def getID(self):
        return self.id
コード例 #28
0
class Publisher(BillboardNode):
    '''
    Represents a Publisher from Billboard
    '''
    tracks = RelationshipFrom('model.graph.billboard.track.Track',
                              'PUBLISHED BY',
                              model=Credited)

    publisher_id = IntegerProperty(unique_index=True)
    publisher_name = StringProperty()

    @classmethod
    def clean(cls, **kwargs) -> Tuple[StructuredNode, Dict[str, dict]]:
        kwargs['publisher_id'] = kwargs.pop('id')
        return cls(**kwargs), {}

    @classmethod
    def exists(cls, identifier):
        return cls.nodes.get_or_none(
            publisher_id=identifier.get('publisher_id'))

    @classmethod
    def inst(cls, **kwargs):
        tor = cls.build(cls, {'publisher_id': kwargs['id']}, **kwargs)
        return tor
コード例 #29
0
ファイル: paper.py プロジェクト: matmcc/graph_django_neomodel
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')
コード例 #30
0
class School(StructuredNode):
    """
    Class to represent the School node
    """
    uuid = UniqueIdProperty()
    name = StringProperty()
    courses = RelationshipFrom(
        'app.models.course.Course', 'TAUGHT_AT', cardinality=ZeroOrMore, model=BaseRel)

    def update(self, name, rel):
        """
        Function will update the name of the school
        :param name: the name of the school
        """

        self.name = name if name is not None else self.name
        rel.updated_on = datetime.datetime.now()
        self.save()

    def json(self):
        """
        Json representation of the event model.
        :return:
        """
        return {
            'uuid': self.uuid,
            'name': self.name
        }