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)
Exemple #3
0
class Entity(StructuredNode):
    uid = UniqueIdProperty()
    name = StringProperty(unique_index=False)
Exemple #4
0
 class User(StructuredNode):
     __abstract_node__ = True
     name = StringProperty(unique_index=True)
Exemple #5
0
 class Issue233(BaseIssue233):
     uid = StringProperty(unique_index=True, required=True)
Exemple #6
0
class Next(StructuredRel):
    label = StringProperty(required=False)
Exemple #7
0
class Customer2(StructuredNode):
    __label__ = 'customers'
    email = StringProperty(unique_index=True, required=True)
    age = IntegerProperty(index=True)
Exemple #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)
Exemple #9
0
class Country(StructuredNode):
    code = StringProperty(unique_index=True)
    inhabitant = RelationshipFrom(Person, 'IS_FROM')
    president = RelationshipTo(Person, 'PRESIDENT', cardinality=One)
Exemple #10
0
class TermRel(StructuredRel):
    rel_type = StringProperty()
Exemple #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)
Exemple #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)
Exemple #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')
Exemple #15
0
class SupplierRel(StructuredRel):
    since = DateTimeProperty(default=datetime.now)
    courier = StringProperty()
Exemple #16
0
class SuperHero(Person):
    power = StringProperty(index=True)

    def special_power(self):
        return "I have powers"
Exemple #17
0
class Supplier(StructuredNode):
    name = StringProperty()
    delivery_cost = IntegerProperty()
    coffees = RelationshipTo('Coffee',
                             'COFFEE SUPPLIERS')  # Space to check for escaping
Exemple #18
0
class ShoppingItem(StructuredNode):
    name = StringProperty()
class ToothBrush(StructuredNode):
    name = StringProperty()
Exemple #20
0
class Shopper(StructuredNode):
    name = StringProperty(unique_index=True)
    friend = RelationshipTo('Shopper', 'FRIEND')
    basket = RelationshipTo('Basket', 'BASKET')
Exemple #21
0
 class Customer3(Customer2):
     address = StringProperty()
class Cuisine(StructuredNode):
    cid = UniqueIdProperty()
    name = StringProperty()
Exemple #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()
Exemple #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)
Exemple #29
0
class Group(StructuredNode, models.Node):
    uid = UniqueIdProperty()
    name = StringProperty(required=True)

    members = Relationship('Person', 'IS_MEMBER')
Exemple #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)