class Author(StructuredNode):
    id = IntegerProperty(unique_index=True)
    name = StringProperty(unique_index=True)
    books = RelationshipFrom('Book', 'AUTHOR')
class Stoat(StructuredNode):
    name = StringProperty(unique_index=True)
    hates = RelationshipTo('Badger', 'HATES', model=HatesRel)
示例#3
0
class Entity(StructuredNode):
    uid = UniqueIdProperty()
    name = StringProperty(unique_index=False)
示例#4
0
 class User(StructuredNode):
     __abstract_node__ = True
     name = StringProperty(unique_index=True)
示例#5
0
 class Issue233(BaseIssue233):
     uid = StringProperty(unique_index=True, required=True)
示例#6
0
class Next(StructuredRel):
    label = StringProperty(required=False)
示例#7
0
class Customer2(StructuredNode):
    __label__ = 'customers'
    email = StringProperty(unique_index=True, required=True)
    age = IntegerProperty(index=True)
示例#8
0
class PageNode(StructuredNode):
    id = StringProperty(unique_index=True, required=True)
    name = StringProperty(unique_index=True, required=True)
    wbs = StringProperty(unique_index=True, required=True)

    haspool = RelationshipTo('PoolNode', 'HASPOOL', model=TermRel)
示例#9
0
class Country(StructuredNode):
    code = StringProperty(unique_index=True)
    inhabitant = RelationshipFrom(Person, 'IS_FROM')
    president = RelationshipTo(Person, 'PRESIDENT', cardinality=One)
示例#10
0
class TermRel(StructuredRel):
    rel_type = StringProperty()
示例#11
0
class PoolNode(StructuredNode):
    id = StringProperty(unique_index=True, required=True)
    name = StringProperty(unique_index=True, required=True)
    wbs = StringProperty(unique_index=True, required=True)

    hasactor = RelationshipTo('SwimlaneNode', 'HASACTOR', model=TermRel)
示例#12
0
class SwimlaneNode(StructuredNode):
    id = StringProperty(unique_index=True, required=True)
    actor = StringProperty(required=True)
    wbs = StringProperty(unique_index=True, required=True)

    responsible = RelationshipTo('ProcessNode', 'Responsible', model=TermRel)
示例#13
0
class AnnotateNode(StructuredNode):
    id = StringProperty(unique_index=True, required=True)
    text = StringProperty()
    wbs = StringProperty(unique_index=True, required=True)

    flow = RelationshipTo('ProcessNode', 'ANNOTATES', model=TermRel)
class Book(StructuredNode):
    id = IntegerProperty(unique_index=True)
    title = StringProperty(unique_index=True)
    author = RelationshipTo('Author', 'AUTHOR')
示例#15
0
class SupplierRel(StructuredRel):
    since = DateTimeProperty(default=datetime.now)
    courier = StringProperty()
示例#16
0
class SuperHero(Person):
    power = StringProperty(index=True)

    def special_power(self):
        return "I have powers"
示例#17
0
class Supplier(StructuredNode):
    name = StringProperty()
    delivery_cost = IntegerProperty()
    coffees = RelationshipTo('Coffee',
                             'COFFEE SUPPLIERS')  # Space to check for escaping
示例#18
0
class ShoppingItem(StructuredNode):
    name = StringProperty()
示例#19
0
class ToothBrush(StructuredNode):
    name = StringProperty()
示例#20
0
class Shopper(StructuredNode):
    name = StringProperty(unique_index=True)
    friend = RelationshipTo('Shopper', 'FRIEND')
    basket = RelationshipTo('Basket', 'BASKET')
示例#21
0
 class Customer3(Customer2):
     address = StringProperty()
class Cuisine(StructuredNode):
    cid = UniqueIdProperty()
    name = StringProperty()
示例#23
0
 class UserMixin(object):
     name = StringProperty(unique_index=True)
     password = StringProperty()
class Location(StructuredNode):
    locality = StringProperty()
class Badger(StructuredNode):
    name = StringProperty(unique_index=True)
    friend = Relationship('Badger', 'FRIEND', model=FriendRel)
    hates = RelationshipTo('Stoat', 'HATES', model=HatesRel)
class Locrel(StructuredRel):
    addr = StringProperty(required=True)
    lat = FloatProperty()
    long = FloatProperty()
示例#27
0
class StepInst(StepModel):
    components = RelationshipTo('ComponentModel', 'HasComponent', model=HasComponent)
    nexts = RelationshipTo('StepInst', 'Next', model=Next)
    prevs = RelationshipFrom('StepInst', 'Next', model=Next)
    sid = UniqueIdProperty()
    status = StringProperty(default=STATUS.NEW, choices=STATUS_LIST)

    @db.transaction
    def add_components(self, components):
        for component in components:
            component_model = ComponentModel(**component).save()
            self.components.connect(component_model)
        return self.get_components()

    def delete_components(self, oid_list=None):
        if oid_list is None:
            components = self.components.all()
        else:
            components = self.components.filter(oid__in=oid_list)
        for component in components:
            component.delete()
        return self.get_components()

    def delete(self):
        self.delete_components()
        super(StepInst, self).delete()

    def get_components(self):
        return {
            component.oid : component.get_info()
            for component in self.components.all()
        }

    def get_info(self):
        info = self.__properties__
        if 'id' in info:
            del info['id']
        return info

    def update(self, data):
        if 'sid' in data:
            del data['sid']
        if 'id' in data:
            del data['id']
        if 'deadline' in data:
            utils.update_datetime(self, 'deadline', data)
        for key in data:
            setattr(self, key, data[key])
        self.save()

    def trigger(self, role=None):
        if self.node_type == NODE_TYPE.START and self.status == STATUS.NEW:
            self.task.get().start()
            self.complete()
        elif self.status == STATUS.IN_PROGRESS and (role in self.assignees or not self.assignees):
            if self.reviewers:
                self.submit_for_review()
            else:
                self.complete()
        elif self.status == STATUS.READY_FOR_REVIEW and (role in self.reviewers or not self.reviewers):
            self.complete()
        else:
            raise CannotComplete()

    def submit_for_review(self):
        """change the status to submit for review and save
        """
        self.status = STATUS.READY_FOR_REVIEW
        self.save()

    def check_parents_are_completed(self, node):
        parensts_relations = node.prevs
        all_completed = True
        for parent in parensts_relations:
            # if parent is skip, find its grandparents
            if parent.status == STATUS.SKIPPED:
                if self.check_parents_are_completed(parent) is False:
                    all_completed = False
            elif parent.status != STATUS.COMPLETED:
                all_completed = False
        return all_completed

    def trigger_next(self):
        for next_node in self.nexts:
            if next_node.status == STATUS.SKIPPED or \
                    next_node.status == STATUS.COMPLETED:
                next_node.trigger_next()
            elif next_node.status == STATUS.NEW and self.check_parents_are_completed(next_node) is True:
                next_node.trigger_self()

    def trigger_self(self):
        if self.node_type == NODE_TYPE.END:
            self.status = STATUS.COMPLETED
            self.task.get().complete()
        else:
            self.status = STATUS.IN_PROGRESS
        self.save()

    def complete(self):
        """complete a step.
        this one will be a little bit tricky since it may involves a lot of cases
        """
        self.status = STATUS.COMPLETED
        self.save()
        self.trigger_next()
class User(StructuredNode):
    name = StringProperty()
    FRIEND = Relationship('User', 'FRIENDS')
    RATED = RelationshipTo(Restaurant, 'RATED', model=Rated)
    LIKES = RelationshipTo(Cuisine, 'LIKES', model=Liked)
    SIM = RelationshipTo(Restaurant, 'SIMILARITY', model=Sim)
示例#29
0
class Group(StructuredNode, models.Node):
    uid = UniqueIdProperty()
    name = StringProperty(required=True)

    members = Relationship('Person', 'IS_MEMBER')
示例#30
0
class Authorization(StructuredRel):
    authorizer = StringProperty(required=True)
    auth_time = DateTimeProperty(default_now=True)
    auth_level = IntegerProperty(required=True)
    auth_account = StringProperty(required=True)