Exemplo n.º 1
0
class Employee(db.Model):

    __primarykey__ = 'id'

    person = db.Label()
    id = db.Property()
    email = db.Property()
    first_name = db.Property()
    last_name = db.Property()
    street_address = db.Property()
    city = db.Property()
    state = db.Property()
    zip_code = db.Property()

    works_for = db.RelatedTo('Company')
    worked_on = db.RelatedTo('Project')
    has_access_to = db.RelatedTo('Application')

    @staticmethod
    def push(employee_id, employee_email):
        employee = Employee()
        employee.person = True
        employee.id = employee_id
        employee.email = employee_email
        db.graph.push(employee)
        return employee
Exemplo n.º 2
0
class Item(db.Model):
    label = db.Label(name="item")
    next = db.RelatedTo('Item')
    property = db.RelatedTo('Property')

    name = db.Property()
    synonym = db.Property()
    config = db.Property()

    @classmethod
    def create(cls, name, synonym=None, config={}):
        _item = cls()
        _item.name = name
        _item.score = 0

        if synonym:
            _item.synonym = synonym

        if config:
            _item.config = config

        db.graph.create(_item)
        return _item

    def add_item(self, item):
        self.next.add(item)
        db.graph.push(self)
        return self

    def add_property(self, property):
        self.property.add(property)
        db.graph.push(self)
        return self
Exemplo n.º 3
0
class Application(db.Model):

    __primarykey__ = 'name'

    crm = db.Label()
    erp = db.Label()
    compliance = db.Label()
    cloud = db.Label()

    name = db.Property()

    # accessed_by = db.RelatedFrom('Employee')
    uses_database = db.RelatedTo('Database')

    @staticmethod
    def push_crm(app_name):
        crm_app = Application()
        crm_app.crm = True
        crm_app.cloud = True
        crm_app.name = app_name
        db.graph.push(crm_app)
        return crm_app

    @staticmethod
    def push_erp(app_name):
        erp_app = Application()
        erp_app.erp = True
        erp_app.name = app_name
        db.graph.push(erp_app)
        return erp_app

    @staticmethod
    def push_compliance(app_name):
        comp_app = Application()
        comp_app.compliance = True
        comp_app.name = app_name
        db.graph.push(comp_app)
        return comp_app
Exemplo n.º 4
0
class Client(db.Model):
    """define the client node"""
    __primarykey__ = 'company_id'

    person = db.Label()

    company_id = db.Property()
    company_name = db.Property()

    has_onboard = db.RelatedTo('Onboard')

    @staticmethod
    def create(company_id, company_name):
        client = Client()
        client.person = True
        client.company_id = company_id
        client.company_name = company_name
        db.graph.create(client)
        return client

    @staticmethod
    def list_all():
        """list all clients"""
        return [_ for _ in Client.select(db.graph)]

    @staticmethod
    def list_all_with_compliance_status():
        """get a list of all clients with compliance status"""
        cursor = db.graph.run(
            ("match (c:Client)-[:HAS_ONBOARD]->(o) "
             "return c, o.completed AS completed, o.valid_onboard AS v "
             "order by c.company_name"))
        return [{
            'client': result['c'],
            'completed': result['completed'],
            'valid_onboard': result['v']
        } for result in cursor]

    @staticmethod
    def list_all_with_document_status():
        """get a list of all clients with document status"""
        cursor = db.graph.run((
            "match (c:Client)-[:HAS_ONBOARD]->()-[:MISSING_DOCUMENT]->(d)-[:FOR_STEP]->(s) "
            "return c, d, s "
            "order by c.company_name, s.step_number"))
        return [{
            'client': result['c'],
            'document_type': result['d']['document_type'],
            'step_number': result['s']['step_number']
        } for result in cursor]
Exemplo n.º 5
0
class Property(db.Model):
    label = db.Label(name="property")
    next = db.RelatedTo('Property')

    name = db.Property()
    synonym = db.Property()
    score = db.Property()

    @classmethod
    def create(cls, name, synonym=None):
        _property = cls()
        _property.name = name
        _property.score = 0
        if synonym:
            _property.synonym = synonym

        db.graph.create(_property)
        return _property

    def add_property(self, property):
        self.next.add(property)
        db.graph.push(self)
        return self