예제 #1
0
 def assemble_content(content_object, dimension=0, parent_path=[]):
     """
     Parses content object and builds a list with Field and Group objects
     @param content_object:
     @param dimension:
     """
     content_list = Content()
     for obj in content_object:
         if obj.get('group'):
             this_path = parent_path[:]
             group_metadata = GroupMetadata(**obj['group']['metadata'])
             this_path.append(group_metadata.name)
             child_path = this_path[:]
             _dimension = dimension
             if group_metadata.multivalued:
                 _dimension += 1
             if group_metadata.multivalued:
                 child_path.append('*')
             group_content = assemble_content(obj['group']['content'],
                                              dimension=_dimension,
                                              parent_path=child_path)
             group = Group(metadata=group_metadata, content=group_content)
             content_list.append(group)
             group.path = this_path
         elif obj.get('field'):
             field = Field(**obj['field'])
             if field.multivalued:
                 field.__dim__ = dimension + 1
             else:
                 field.__dim__ = dimension
             content_list.append(field)
             this_path = parent_path[:]
             this_path.append(field.name)
             field.path = this_path
     return content_list
예제 #2
0
 def object2content(self, obj, dimension=0, parent_path=[]):
     if obj.get('group'):
         this_path = parent_path[:]
         group_metadata = GroupMetadata(**obj['group']['metadata'])
         this_path.append(group_metadata.name)
         child_path = this_path[:]
         _dimension = dimension
         if group_metadata.multivalued:
             _dimension += 1
         if group_metadata.multivalued:
             child_path.append('*')
         group_content = Content()
         for item in obj['group']['content']:
             content = self.object2content(item,
                                           dimension=_dimension,
                                           parent_path=parent_path)
             group_content.append(content)
         group = Group(metadata=group_metadata, content=group_content)
         group.path = this_path
         return group
     elif obj.get('field'):
         field = Field(**obj['field'])
         if field.multivalued:
             field.__dim__ = dimension + 1
         else:
             field.__dim__ = dimension
         this_path = parent_path[:]
         this_path.append(field.name)
         field.path = this_path
         return field
     else:
         raise TypeError('Value must be a Field or Group')
예제 #3
0
    def lbbase(self):
        """
        LB Base do órgão
        """
        item = Field(**dict(
            name='item',
            description='Nome do item que será adicionado a lista.',
            alias='nome',
            datatype='Text',
            indices=['Textual', 'Unico'],
            multivalued=False,
            required=True
        ))

        base_metadata = BaseMetadata(
            name='blacklist',
        )

        content_list = Content()
        content_list.append(item)

        lbbase = Base(
            metadata=base_metadata,
            content=content_list
        )

        return lbbase
예제 #4
0
 def object2content(self, obj, dimension=0, parent_path=[]):
     if obj.get('group'):
         this_path=parent_path[:]
         group_metadata=GroupMetadata(**obj['group']['metadata'])
         this_path.append(group_metadata.name)
         child_path=this_path[:]
         _dimension=dimension
         if group_metadata.multivalued:
             _dimension += 1
         if group_metadata.multivalued:
             child_path.append('*')
         group_content=Content()
         for item in obj['group']['content']:
             content=self.object2content(
                 item,
                 dimension=_dimension,
                 parent_path=parent_path)
             group_content.append(content)
         group=Group(
             metadata=group_metadata,
             content=group_content)
         group.path=this_path
         return group
     elif obj.get('field'):
         field=Field(**obj['field'])
         if field.multivalued:
             field.__dim__=dimension + 1
         else:
             field.__dim__=dimension
         this_path=parent_path[:]
         this_path.append(field.name)
         field.path=this_path
         return field
     else:
         raise TypeError('Value must be a Field or Group')
예제 #5
0
 def assemble_content(content_object, dimension=0):
     """
     Parses content object and builds a list with Field and Group objects
     @param content_object:
     @param dimension:
     """
     content_list = Content()
     for obj in content_object:
         if obj.get('group'):
             group_metadata = GroupMetadata(**obj['group']['metadata'])
             _dimension = dimension
             if group_metadata.multivalued:
                 _dimension += 1
             group_content = assemble_content(
                 obj['group']['content'],
                 dimension=_dimension)
             group = Group(
                 metadata=group_metadata,
                 content=group_content)
             content_list.append(group)
         elif obj.get('field'):
             field = Field(**obj['field'])
             if field.multivalued:
                 field.__dim__ = dimension + 1
             else:
                 field.__dim__ = dimension
             content_list.append(field)
     return content_list
예제 #6
0
    def lbbase(self):
        """
        Base no LB
        :return: LB Base object
        """
        tipo = Field(**dict(name='tipo',
                            description='Tipo de atividade',
                            alias='tipo',
                            datatype='Text',
                            indices=['Textual', 'Ordenado'],
                            multivalued=False,
                            required=True))

        usuario = Field(**dict(name='usuario',
                               description='Usuário que realizou a atividade',
                               alias='usuario',
                               datatype='Text',
                               indices=['Textual', 'Ordenado'],
                               multivalued=False,
                               required=True))

        descricao = Field(**dict(name='descricao',
                                 description='Descrição da atividade',
                                 alias='descricao',
                                 datatype='Text',
                                 indices=['Textual'],
                                 multivalued=False,
                                 required=True))

        data = Field(**dict(name='data',
                            description='Data de execução da tarefa',
                            alias='data',
                            datatype='Date',
                            indices=['Ordenado'],
                            multivalued=False,
                            required=True))

        data_hora = Field(
            **dict(name='data_hora',
                   description='Data e Hora de execução da tarefa',
                   alias='data_hora',
                   datatype='DateTime',
                   indices=['Ordenado'],
                   multivalued=False,
                   required=False))

        content_list = Content()
        content_list.append(tipo)
        content_list.append(usuario)
        content_list.append(descricao)
        content_list.append(data)
        content_list.append(data_hora)

        base_metadata = BaseMetadata(name='atividade')

        lbbase = Base(metadata=base_metadata, content=content_list)

        return lbbase
예제 #7
0
def pyobject2base(obj):
    """
    Convert python object to base
    @param obj: Python object
    @return: LBBase instance
    """
    content = Content()
    elms = lbutils.get_attr(obj)
    for elm in elms:
        content.append(attribute2lbfield(*elm))
    return Base(metadata=BaseMetadata(getattr(type(obj), '__name__')),
                content=content)
예제 #8
0
def pyobject2base(obj):
    """
    Convert python object to base
    @param obj: Python object
    @return: LBBase instance
    """
    content = Content()
    elms = lbutils.get_attr(obj)
    for elm in elms:
        content.append(attribute2lbfield(*elm))
    return Base(
        metadata=BaseMetadata(getattr(type(obj), '__name__')),
        content=content)
예제 #9
0
    def test_json_base(self):
        """
        Test JSON base serialization
        :return:
        """
        field = Field(**self.field)

        field2 = Field(**self.field2)

        content_list = Content()
        content_list.append(field)
        content_list.append(field2)

        group_metadata = GroupMetadata(**self.group_metadata)

        group = Group(
            metadata=group_metadata,
            content=content_list,
        )

        field3 = Field(**self.field3)

        content_list = Content()
        content_list.append(group)
        content_list.append(field3)

        base_metadata = BaseMetadata(**self.base_metadata)

        base = Base(metadata=base_metadata, content=content_list)

        j = base.json
        fd = open('/tmp/test.json', 'w+')
        fd.write(j)
        fd.close()
        assert j
예제 #10
0
    def test_base_json(self):
        """
        Test generated JSON conversion back to base
        :return:
        """

        field = Field(**self.field)

        field2 = Field(**self.field2)

        content_list = Content()
        content_list.append(field)
        content_list.append(field2)

        group_metadata = GroupMetadata(**self.group_metadata)

        group = Group(
            metadata=group_metadata,
            content=content_list,
        )

        field3 = Field(**self.field3)

        content_list = Content()
        content_list.append(group)
        content_list.append(field3)

        base_metadata = BaseMetadata(**self.base_metadata)

        base = Base(metadata=base_metadata, content=content_list)

        j = base.json
        b = json2base(j)
        assert (isinstance(b, Base))
예제 #11
0
    def lbbase(self):
        """
        LB Base de Notify
        """
        orgao = Field(**dict(name='orgao',
                             description='Órgão referente a notrificção',
                             alias='orgao',
                             datatype='Text',
                             indices=['Textual'],
                             multivalued=False,
                             required=True))

        data_coleta = Field(**dict(name='data_coleta',
                                   alias='data_coleta',
                                   description='data da coleta notificada',
                                   datatype='Text',
                                   indices=['Textual'],
                                   multivalued=False,
                                   required=True))

        notify = Field(**dict(name='notify',
                              alias='notify',
                              description='tipo de notificação',
                              datatype='Text',
                              indices=['Textual'],
                              multivalued=False,
                              required=True))

        coment = Field(**dict(name='coment',
                              alias='coment',
                              description='comentario',
                              datatype='Text',
                              indices=['Textual'],
                              multivalued=False,
                              required=True))

        status = Field(**dict(name='status',
                              alias='status',
                              description='status da notificação',
                              datatype='Text',
                              indices=['Textual'],
                              multivalued=False,
                              required=True))

        base_metadata = BaseMetadata(name='notify', )
        content_list = Content()
        content_list.append(orgao)
        content_list.append(data_coleta)
        content_list.append(notify)
        content_list.append(coment)
        content_list.append(status)

        lbbase = Base(metadata=base_metadata, content=content_list)

        return lbbase
예제 #12
0
    def lbbase(self):
        """
        LB Base do órgão
        """
        item = Field(
            **dict(name='item',
                   description='Nome do item que será adicionado a lista.',
                   alias='nome',
                   datatype='Text',
                   indices=['Textual', 'Unico'],
                   multivalued=False,
                   required=True))

        base_metadata = BaseMetadata(name='blacklist', )

        content_list = Content()
        content_list.append(item)

        lbbase = Base(metadata=base_metadata, content=content_list)

        return lbbase
예제 #13
0
 def assemble_content(content_object, dimension=0, parent_path=[]):
     """
     Parses content object and builds a list with Field and Group objects
     @param content_object:
     @param dimension:
     """
     content_list = Content()
     for obj in content_object:
         if obj.get('group'):
             this_path = parent_path[:]
             group_metadata = GroupMetadata(**obj['group']['metadata'])
             this_path.append(group_metadata.name)
             child_path = this_path[:]
             _dimension = dimension
             if group_metadata.multivalued:
                 _dimension += 1
             if group_metadata.multivalued:
                 child_path.append('*')
             group_content = assemble_content(
                 obj['group']['content'],
                 dimension=_dimension,
                 parent_path=child_path)
             group = Group(
                 metadata=group_metadata,
                 content=group_content)
             content_list.append(group)
             group.path = this_path
         elif obj.get('field'):
             field = Field(**obj['field'])
             if field.multivalued:
                 field.__dim__ = dimension + 1
             else:
                 field.__dim__ = dimension
             content_list.append(field)
             this_path = parent_path[:]
             this_path.append(field.name)
             field.path = this_path
     return content_list
예제 #14
0
    def test_json_groups(self):
        """
        Test JSON groups serialization
        :return:
        """

        field = Field(**self.field)

        field2 = Field(**self.field2)

        content_list = Content()
        content_list.append(field)
        content_list.append(field2)

        group_metadata = GroupMetadata(**self.group_metadata)

        group = Group(
            metadata=group_metadata,
            content=content_list,
        )

        j = group.json
        print(j)
        assert j
예제 #15
0
    def test_json_groups(self):
        """
        Test JSON groups serialization
        :return:
        """

        field = Field(**self.field)

        field2 = Field(**self.field2)

        content_list = Content()
        content_list.append(field)
        content_list.append(field2)

        group_metadata = GroupMetadata(**self.group_metadata)

        group = Group(
            metadata=group_metadata,
            content=content_list,
        )

        j = group.json
        print(j)
        assert j
예제 #16
0
    def setUp(self):
        """
        Load data from previous tests and setup test data
        :return:
        """
        lbjson_test.TestJSON.setUp(self)

        # Start base definition
        field = Field(**self.field)

        field2 = Field(**self.field2)

        content_list = Content()
        content_list.append(field)
        content_list.append(field2)

        group_metadata = GroupMetadata(**self.group_metadata)

        group = Group(
            metadata=group_metadata,
            content=content_list,
        )

        field3 = Field(**self.field3)

        content_list = Content()
        content_list.append(group)
        content_list.append(field3)

        base_metadata = BaseMetadata(**self.base_metadata)

        self.base = Base(
            metadata=base_metadata,
            content=content_list
        )
        # End Base definition

        #self.rest_url = "http://localhost/api"
        self.rest_url = "http://127.0.0.1/api"
        self.baserest = lbrest.BaseREST(rest_url=self.rest_url, response_object=True)
        pass
예제 #17
0
    def setUp(self):
        """
        Load data from previous tests and setup test data
        :return:
        """
        lbjson_test.TestJSON.setUp(self)

        # Start base definition
        field = Field(**self.field)

        field2 = Field(**self.field2)

        content_list = Content()
        content_list.append(field)
        content_list.append(field2)

        group_metadata = GroupMetadata(**self.group_metadata)

        group = Group(
            metadata=group_metadata,
            content=content_list,
        )

        field3 = Field(**self.field3)

        content_list = Content()
        content_list.append(group)
        content_list.append(field3)

        base_metadata = BaseMetadata(**self.base_metadata)

        self.base = Base(metadata=base_metadata, content=content_list)
        # End Base definition

        #self.rest_url = "http://localhost/api"
        self.rest_url = "http://127.0.0.1/api"
        self.baserest = lbrest.BaseREST(rest_url=self.rest_url,
                                        response_object=True)
        pass
예제 #18
0
    def test_json_base(self):
        """
        Test JSON base serialization
        :return:
        """
        field = Field(**self.field)

        field2 = Field(**self.field2)

        content_list = Content()
        content_list.append(field)
        content_list.append(field2)

        group_metadata = GroupMetadata(**self.group_metadata)

        group = Group(
            metadata=group_metadata,
            content=content_list,
        )

        field3 = Field(**self.field3)

        content_list = Content()
        content_list.append(group)
        content_list.append(field3)

        base_metadata = BaseMetadata(**self.base_metadata)

        base = Base(
            metadata=base_metadata,
            content=content_list
        )

        j = base.json
        fd = open('/tmp/test.json', 'w+')
        fd.write(j)
        fd.close()
        assert j
예제 #19
0
    def test_base_json(self):
        """
        Test generated JSON conversion back to base
        :return:
        """

        field = Field(**self.field)

        field2 = Field(**self.field2)

        content_list = Content()
        content_list.append(field)
        content_list.append(field2)

        group_metadata = GroupMetadata(**self.group_metadata)

        group = Group(
            metadata=group_metadata,
            content=content_list,
        )

        field3 = Field(**self.field3)

        content_list = Content()
        content_list.append(group)
        content_list.append(field3)

        base_metadata = BaseMetadata(**self.base_metadata)

        base = Base(
            metadata=base_metadata,
            content=content_list
        )

        j = base.json
        b = json2base(j)
        assert(isinstance(b, Base))
예제 #20
0
    def lbbase(self):
        """
        Generate LB Base object
        :return:
        """
        location_name = Field(**dict(
            name='location_name',
            description='Location name',
            alias='Location name',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        latitude = Field(**dict(
            name='latitude',
            description='Latitude',
            alias='Latitude',
            datatype='Decimal',
            indices=[],
            multivalued=False,
            required=True
        ))

        longitude = Field(**dict(
            name='longitude',
            description='Longitude',
            alias='longitude',
            datatype='Decimal',
            indices=[],
            multivalued=False,
            required=True
        ))

        location_type = Field(**dict(
            name='location_type',
            description='Location type',
            alias='Location type',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        loc_origin = Field(**dict(
            name='loc_origin',
            description='Location origin',
            alias='Location origin',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        city = Field(**dict(
            name='city',
            description='Location that comes from social networks. Used in searches',
            alias='City',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        base_metadata = BaseMetadata(**dict(
            name='location',
            description='Status location',
            idx_exp=True,
            idx_exp_url=self.es_url + '/location',
            idx_exp_time=300,
        ))

        content_list = Content()
        content_list.append(location_name)
        content_list.append(latitude)
        content_list.append(longitude)
        content_list.append(location_type)
        content_list.append(loc_origin)
        content_list.append(city)

        lbbase = Base(
            metadata=base_metadata,
            content=content_list
        )

        return lbbase
예제 #21
0
    def lbbase(self):
        """
        LB Base de email
        """
        usuario = Field(**dict(
            name='usuario',
            description='Usuario',
            alias='Usuario',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        to = Field(**dict(
            name='to',
            description='Destino do email',
            alias='to',
            datatype='Text',
            indices=['Textual'],
            multivalued=True,
            required=True
        ))

        reply_to = Field(**dict(
            name='reply_to',
            alias='reply_to',
            description='reply_to',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        subject = Field(**dict(
            name='subject',
            alias='Assunto',
            description='Assunto do e-mail',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        body = Field(**dict(
            name='body',
            alias='body',
            description='Corpo do e-mail',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        headers = Field(**dict(
            name='headers',
            alias='headers',
            description='headers',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        data_send = Field(**dict(
            name='data_send',
            alias='data_send',
            description='Data de envio',
            datatype='DateTime',
            indices=['Ordenado'],
            multivalued=False,
            required=True
        ))

        status = Field(**dict(
            name='status',
            alias='status',
            description='status',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        hidden_destination = Field(**dict(
            name='hidden_destination',
            alias='hd',
            description='hd',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=False
        ))

        base_metadata = BaseMetadata(
            name='email',
        )

        content_list = Content()
        content_list.append(usuario)
        content_list.append(to)
        content_list.append(reply_to)
        content_list.append(subject)
        content_list.append(body)
        content_list.append(headers)
        content_list.append(data_send)
        content_list.append(status)
        content_list.append(hidden_destination)

        lbbase = Base(
            metadata=base_metadata,
            content=content_list
        )

        return lbbase
예제 #22
0
    def lbbase(self):
        """
        Generate LB Base object
        :return:
        """
        category_name = Field(**dict(name='category_name',
                                     description='category name',
                                     alias='category_name',
                                     datatype='Text',
                                     indices=['Ordenado', 'Unico'],
                                     multivalued=False,
                                     required=True))

        category_pretty_name = Field(**dict(name='category_pretty_name',
                                            description='category pretty name',
                                            alias='category_pretty_name',
                                            datatype='Text',
                                            indices=['Ordenado'],
                                            multivalued=False,
                                            required=True))

        description = Field(**dict(name='description',
                                   description='category description',
                                   alias='description',
                                   datatype='Text',
                                   indices=[],
                                   multivalued=False,
                                   required=False))

        tokens = Field(
            **dict(name='tokens',
                   description='Identified tokens for this category',
                   alias='tokens',
                   datatype='Text',
                   indices=['Ordenado'],
                   multivalued=True,
                   required=False))

        total = Field(**dict(name='total',
                             description='Total criminal events',
                             alias='total',
                             datatype='Integer',
                             indices=['Ordenado'],
                             multivalued=False,
                             required=False))

        date = Field(**dict(name='date',
                            description='Taxonomy last update',
                            alias='date',
                            datatype='DateTime',
                            indices=['Ordenado'],
                            multivalued=False,
                            required=True))

        images = Field(**dict(name='images',
                              description='Taxonomy related images',
                              alias='images',
                              datatype='File',
                              indices=[],
                              multivalued=True,
                              required=False))

        default_token = Field(
            **dict(name='default_token',
                   description='Default token for this category',
                   alias='default_token',
                   datatype='Text',
                   indices=['Ordenado'],
                   multivalued=False,
                   required=False))

        color = Field(**dict(name='color',
                             description='Color to be shown on interface',
                             alias='Color',
                             datatype='Text',
                             indices=[],
                             multivalued=False,
                             required=False))

        base_metadata = BaseMetadata(
            **dict(name='crime',
                   description='Criminal data from social networks',
                   password='******',
                   idx_exp=True,
                   idx_exp_url=self.es_url + '/crime',
                   idx_exp_time=300,
                   file_ext=True,
                   file_ext_time=300,
                   color='#FFFFFF'))

        content_list = Content()
        content_list.append(total)
        content_list.append(category_name)
        content_list.append(category_pretty_name)
        content_list.append(description)
        content_list.append(tokens)
        content_list.append(date)
        content_list.append(images)
        content_list.append(default_token)
        content_list.append(color)

        lbbase = Base(metadata=base_metadata, content=content_list)

        return lbbase
예제 #23
0
    def lbbase(self):
        """
        LB Base de email
        """
        usuario = Field(**dict(name='usuario',
                               description='Usuario',
                               alias='Usuario',
                               datatype='Text',
                               indices=['Textual'],
                               multivalued=False,
                               required=True))

        to = Field(**dict(name='to',
                          description='Destino do email',
                          alias='to',
                          datatype='Text',
                          indices=['Textual'],
                          multivalued=True,
                          required=True))

        reply_to = Field(**dict(name='reply_to',
                                alias='reply_to',
                                description='reply_to',
                                datatype='Text',
                                indices=['Textual'],
                                multivalued=False,
                                required=True))

        subject = Field(**dict(name='subject',
                               alias='Assunto',
                               description='Assunto do e-mail',
                               datatype='Text',
                               indices=['Textual'],
                               multivalued=False,
                               required=True))

        body = Field(**dict(name='body',
                            alias='body',
                            description='Corpo do e-mail',
                            datatype='Text',
                            indices=['Textual'],
                            multivalued=False,
                            required=True))

        headers = Field(**dict(name='headers',
                               alias='headers',
                               description='headers',
                               datatype='Text',
                               indices=['Textual'],
                               multivalued=False,
                               required=True))

        data_send = Field(**dict(name='data_send',
                                 alias='data_send',
                                 description='Data de envio',
                                 datatype='DateTime',
                                 indices=['Ordenado'],
                                 multivalued=False,
                                 required=True))

        status = Field(**dict(name='status',
                              alias='status',
                              description='status',
                              datatype='Text',
                              indices=['Textual'],
                              multivalued=False,
                              required=True))

        hidden_destination = Field(**dict(name='hidden_destination',
                                          alias='hd',
                                          description='hd',
                                          datatype='Text',
                                          indices=['Textual'],
                                          multivalued=False,
                                          required=False))

        base_metadata = BaseMetadata(name='email', )

        content_list = Content()
        content_list.append(usuario)
        content_list.append(to)
        content_list.append(reply_to)
        content_list.append(subject)
        content_list.append(body)
        content_list.append(headers)
        content_list.append(data_send)
        content_list.append(status)
        content_list.append(hidden_destination)

        lbbase = Base(metadata=base_metadata, content=content_list)

        return lbbase
예제 #24
0
    def lbbase(self):
        """
        Base no LB
        :return: LB Base object
        """
        win32_physicalmemory_memorytype_list = Content()

        win32_physicalmemory_memorytype_key = Field(**dict(
            name='win32_physicalmemory_memorytype_key',
            description='Chave do atributo MemoryType',
            alias='win32_physicalmemory_memorytype_key',
            datatype='Integer',
            indices=['Ordenado'],
            multivalued=False,
            required=False
        ))

        win32_physicalmemory_memorytype_list.append(win32_physicalmemory_memorytype_key)

        win32_physicalmemory_memorytype_value = Field(**dict(
            name='win32_physicalmemory_memorytype_value',
            description='Valro do atributo MemoryType',
            alias='win32_physicalmemory_memorytype_value',
            datatype='Text',
            indices=['Textual', 'Ordenado'],
            multivalued=False,
            required=False
        ))

        win32_physicalmemory_memorytype_list.append(win32_physicalmemory_memorytype_value)

        win32_physicalmemory_memorytype_metadata = GroupMetadata(**dict(
            name='win32_physicalmemory_memorytype',
            alias='win32_physicalmemory_memorytype',
            description='Descrição do campo win32_physicalmemory_memorytype',
            multivalued=True
        ))

        win32_physicalmemory_memorytype = Group(
            metadata=win32_physicalmemory_memorytype_metadata,
            content=win32_physicalmemory_memorytype_list
        )

        win32_processor_family_list = Content()

        win32_processor_family_key = Field(**dict(
            name='win32_processor_family_key',
            description='Chave do atributo MemoryType',
            alias='win32_processor_family_key',
            datatype='Integer',
            indices=['Ordenado'],
            multivalued=False,
            required=False
        ))

        win32_processor_family_list.append(win32_processor_family_key)

        win32_processor_family_value = Field(**dict(
            name='win32_processor_family_value',
            description='Valor do atributo Family',
            alias='win32_processor_family_value',
            datatype='Text',
            indices=['Textual', 'Ordenado'],
            multivalued=False,
            required=False
        ))

        win32_processor_family_list.append(win32_processor_family_value)

        win32_processor_family_metadata = GroupMetadata(**dict(
            name='win32_processor_family',
            alias='win32_processor_family',
            description='Descrição do campo win32_processor_family',
            multivalued=True
        ))

        win32_processor_family = Group(
            metadata=win32_processor_family_metadata,
            content=win32_processor_family_list
        )

        content_list = Content()
        content_list.append(win32_physicalmemory_memorytype)
        content_list.append(win32_processor_family)

        base_metadata = BaseMetadata(
            name='descriptions',
            description='Field descriptions'
        )

        lbbase = Base(
            metadata=base_metadata,
            content=content_list
        )

        return lbbase
예제 #25
0
    def lbbase(self):
        """
        LB Base de Users
        """
        nome = Field(**dict(name='nome',
                            description='Nome do Usuário',
                            alias='nome',
                            datatype='Text',
                            indices=['Textual'],
                            multivalued=False,
                            required=True))

        matricula = Field(**dict(name='matricula',
                                 alias='matricula',
                                 description='Matricula do Usuário',
                                 datatype='Text',
                                 indices=['Textual'],
                                 multivalued=False,
                                 required=True))

        email = Field(**dict(name='email',
                             alias='email',
                             description='E-mail do Usuário',
                             datatype='Text',
                             indices=['Textual'],
                             multivalued=False,
                             required=True))

        telefone = Field(**dict(name='telefone',
                                alias='telefone',
                                description='Telefone do Usuário',
                                datatype='Text',
                                indices=['Textual'],
                                multivalued=False,
                                required=True))

        orgao = Field(**dict(name='orgao',
                             alias='orgao',
                             description='Orgão do Usuário',
                             datatype='Text',
                             indices=['Textual'],
                             multivalued=False,
                             required=True))

        cargo = Field(**dict(name='cargo',
                             alias='cargo',
                             description='Cargo do Usuário',
                             datatype='Text',
                             indices=['Textual'],
                             multivalued=False,
                             required=True))

        setor = Field(**dict(name='setor',
                             alias='setor',
                             description='Setor do Usuário',
                             datatype='Text',
                             indices=['Textual'],
                             multivalued=False,
                             required=True))

        permissao = Field(**dict(name='permissao',
                                 alias='permissao',
                                 description='Permissão do Usuário',
                                 datatype='Text',
                                 indices=['Textual'],
                                 multivalued=False,
                                 required=True))

        senha = Field(**dict(name='senha',
                             alias='senha',
                             description='Senha do Usuário',
                             datatype='Text',
                             indices=['Textual'],
                             multivalued=False,
                             required=True))
        favoritos = Field(**dict(name='favoritos',
                                 alias='favoritos',
                                 description='Favoritos do Usuário',
                                 datatype='Text',
                                 indices=['Textual'],
                                 multivalued=True,
                                 required=False))
        home = Field(**dict(name='home',
                            alias='home',
                            description='Home do Usuário',
                            datatype='Text',
                            indices=['Textual'],
                            multivalued=True,
                            required=False))
        itens = Field(**dict(name='itens',
                             alias='itens',
                             description='Itens do Usuário',
                             datatype='Text',
                             indices=['Textual'],
                             multivalued=True,
                             required=False))

        url_hash = Field(
            **dict(name='url_hash',
                   alias='url_hash',
                   description='hash que sera usado para para criar a url',
                   datatype='Text',
                   indices=['Textual'],
                   multivalued=True,
                   required=False))

        nm_user = Field(**dict(name='nm_user',
                               alias='nm_user',
                               description='Nome do usuario',
                               datatype='Text',
                               indices=['Textual'],
                               multivalued=True,
                               required=False))

        HashUrl_content = Content()
        HashUrl_content.append(nm_user)
        HashUrl_content.append(url_hash)

        HashUrl_metadata = GroupMetadata(name='HashUrl',
                                         alias='HashUrl',
                                         description='HashUrl',
                                         multivalued=False)

        HashUrl = Group(metadata=HashUrl_metadata, content=HashUrl_content)

        base_metadata = BaseMetadata(name='users', )

        content_list = Content()
        content_list.append(nome)
        content_list.append(matricula)
        content_list.append(email)
        content_list.append(telefone)
        content_list.append(orgao)
        content_list.append(cargo)
        content_list.append(setor)
        content_list.append(permissao)
        content_list.append(senha)
        content_list.append(favoritos)
        content_list.append(home)
        content_list.append(itens)
        content_list.append(HashUrl)

        lbbase = Base(metadata=base_metadata, content=content_list)

        return lbbase
예제 #26
0
    def lbbase(self):
        """
        Generate LB Base object
        :return:
        """
        category_name = Field(**dict(
            name='category_name',
            description='category name',
            alias='category_name',
            datatype='Text',
            indices=['Ordenado', 'Unico'],
            multivalued=False,
            required=True
        ))
        
        category_pretty_name = Field(**dict(
            name='category_pretty_name',
            description='category pretty name',
            alias='category_pretty_name',
            datatype='Text',
            indices=['Ordenado'],
            multivalued=False,
            required=True
        ))
        
        description = Field(**dict(
            name='description',
            description='category description',
            alias='description',
            datatype='Text',
            indices=[],
            multivalued=False,
            required=False
        ))
        
        tokens = Field(**dict(
            name='tokens',
            description='Identified tokens for this category',
            alias='tokens',
            datatype='Text',
            indices=['Ordenado'],
            multivalued=True,
            required=False
        ))
        
        total = Field(**dict(
            name='total',
            description='Total criminal events',
            alias='total',
            datatype='Integer',
            indices=['Ordenado'],
            multivalued=False,
            required=False
        ))

        date = Field(**dict(
            name='date',
            description='Taxonomy last update',
            alias='date',
            datatype='DateTime',
            indices=['Ordenado'],
            multivalued=False,
            required=True
        ))

        images = Field(**dict(
            name='images',
            description='Taxonomy related images',
            alias='images',
            datatype='File',
            indices=[],
            multivalued=True,
            required=False
        ))

        default_token = Field(**dict(
            name='default_token',
            description='Default token for this category',
            alias='default_token',
            datatype='Text',
            indices=['Ordenado'],
            multivalued=False,
            required=False
        ))

        color = Field(**dict(
            name='color',
            description='Color to be shown on interface',
            alias='Color',
            datatype='Text',
            indices=[],
            multivalued=False,
            required=False
        ))

        base_metadata = BaseMetadata(**dict(
            name='crime',
            description='Criminal data from social networks',
            password='******',
            idx_exp=True,
            idx_exp_url=self.es_url + '/crime',
            idx_exp_time=300,
            file_ext=True,
            file_ext_time=300,
            color='#FFFFFF'
        ))

        content_list = Content()
        content_list.append(total)
        content_list.append(category_name)
        content_list.append(category_pretty_name)
        content_list.append(description)
        content_list.append(tokens)
        content_list.append(date)
        content_list.append(images)
        content_list.append(default_token)
        content_list.append(color)

        lbbase = Base(
            metadata=base_metadata,
            content=content_list
        )

        return lbbase
예제 #27
0
    def lbbase(self):
        """
        LB Base do órgão
        """
        OperatingSystem_item = Field(**dict(name='OperatingSystem_item',
                                            description='Item Coletado',
                                            alias='Item',
                                            datatype='Text',
                                            indices=['Textual', 'Unico'],
                                            multivalued=False,
                                            required=True))

        OperatingSystem_amount = Field(**dict(name='OperatingSystem_amount',
                                              alias='amount',
                                              description='amount',
                                              datatype='Integer',
                                              indices=['Textual'],
                                              multivalued=False,
                                              required=True))

        Win32_BIOS_item = Field(**dict(name='Win32_BIOS_item',
                                       description='Item Coletado',
                                       alias='Item',
                                       datatype='Text',
                                       indices=['Textual', 'Unico'],
                                       multivalued=False,
                                       required=True))

        Win32_BIOS_amount = Field(**dict(name='Win32_BIOS_amount',
                                         alias='amount',
                                         description='amount',
                                         datatype='Integer',
                                         indices=['Textual'],
                                         multivalued=False,
                                         required=True))

        Win32_Processor_item = Field(**dict(name='Win32_Processor_item',
                                            description='Item Coletado',
                                            alias='Item',
                                            datatype='Text',
                                            indices=['Textual', 'Unico'],
                                            multivalued=False,
                                            required=True))

        Win32_Processor_amount = Field(**dict(name='Win32_Processor_amount',
                                              alias='amount',
                                              description='amount',
                                              datatype='Integer',
                                              indices=['Textual'],
                                              multivalued=False,
                                              required=True))

        Win32_DiskDrive_item = Field(**dict(name='Win32_DiskDrive_item',
                                            description='Item Coletado',
                                            alias='Item',
                                            datatype='Text',
                                            indices=['Textual', 'Unico'],
                                            multivalued=False,
                                            required=True))

        Win32_DiskDrive_amount = Field(**dict(name='Win32_DiskDrive_amount',
                                              alias='amount',
                                              description='amount',
                                              datatype='Integer',
                                              indices=['Textual'],
                                              multivalued=False,
                                              required=True))

        Win32_PhysicalMemory_item = Field(
            **dict(name='Win32_PhysicalMemory_item',
                   description='Item Coletado',
                   alias='Item',
                   datatype='Text',
                   indices=['Textual', 'Unico'],
                   multivalued=False,
                   required=True))

        Win32_PhysicalMemory_amount = Field(
            **dict(name='Win32_PhysicalMemory_amount',
                   alias='amount',
                   description='amount',
                   datatype='Integer',
                   indices=['Textual'],
                   multivalued=False,
                   required=True))

        software_item = Field(**dict(name='SoftwareList_item',
                                     description='Software Coletado',
                                     alias='SoftwareList_item',
                                     datatype='Text',
                                     indices=['Textual', 'Unico'],
                                     multivalued=False,
                                     required=True))

        software_amount = Field(**dict(name='SoftwareList_amount',
                                       alias='SoftwareList_amount',
                                       description='Software Amount',
                                       datatype='Integer',
                                       indices=['Textual'],
                                       multivalued=False,
                                       required=True))
        """
        GROUP Sistema Operacional
        """
        OperatingSystem_content = Content()
        OperatingSystem_content.append(OperatingSystem_item)
        OperatingSystem_content.append(OperatingSystem_amount)

        OperatingSystem_metadata = GroupMetadata(name='OperatingSystem',
                                                 alias='OperatingSystem',
                                                 description='OperatingSystem',
                                                 multivalued=False)

        OperatingSystem = Group(metadata=OperatingSystem_metadata,
                                content=OperatingSystem_content)
        """
        GROUP Bios
        """
        Win32_BIOS_content = Content()
        Win32_BIOS_content.append(Win32_BIOS_item)
        Win32_BIOS_content.append(Win32_BIOS_amount)

        Win32_BIOS_metadata = GroupMetadata(name='Win32_BIOS',
                                            alias='Win32_BIOS',
                                            description='Win32_BIOS',
                                            multivalued=False)

        Win32_BIOS = Group(metadata=Win32_BIOS_metadata,
                           content=Win32_BIOS_content)
        """
        GROUP Processador
        """
        Win32_Processor_content = Content()
        Win32_Processor_content.append(Win32_Processor_item)
        Win32_Processor_content.append(Win32_Processor_amount)

        Win32_Processor_metadata = GroupMetadata(name='Win32_Processor',
                                                 alias='Win32_Processor',
                                                 description='Win32_Processor',
                                                 multivalued=False)

        Win32_Processor = Group(metadata=Win32_Processor_metadata,
                                content=Win32_Processor_content)
        """
        GROUP DiskDrive
        """
        Win32_DiskDrive_content = Content()
        Win32_DiskDrive_content.append(Win32_DiskDrive_item)
        Win32_DiskDrive_content.append(Win32_DiskDrive_amount)

        Win32_DiskDrive_metadata = GroupMetadata(name='Win32_DiskDrive',
                                                 alias='Win32_DiskDrive',
                                                 description='Win32_DiskDrive',
                                                 multivalued=False)

        Win32_DiskDrive = Group(metadata=Win32_DiskDrive_metadata,
                                content=Win32_DiskDrive_content)
        """
        GROUP PhysicalMemory
        """
        Win32_PhysicalMemory_content = Content()
        Win32_PhysicalMemory_content.append(Win32_PhysicalMemory_item)
        Win32_PhysicalMemory_content.append(Win32_PhysicalMemory_amount)

        Win32_PhysicalMemory_metadata = GroupMetadata(
            name='Win32_PhysicalMemory',
            alias='Win32_PhysicalMemory',
            description='Win32_PhysicalMemory',
            multivalued=False)

        Win32_PhysicalMemory = Group(metadata=Win32_PhysicalMemory_metadata,
                                     content=Win32_PhysicalMemory_content)
        """
        GROUP Software
        """
        software_content = Content()
        software_content.append(software_item)
        software_content.append(software_amount)

        software_metadata = GroupMetadata(name='SoftwareList',
                                          alias='SoftwareList',
                                          description='Lista de softwares',
                                          multivalued=False)

        software = Group(metadata=software_metadata, content=software_content)

        base_metadata = BaseMetadata(name=self.nm_base + "_bk", )

        content_list = Content()
        content_list.append(OperatingSystem)
        content_list.append(Win32_BIOS)
        content_list.append(Win32_Processor)
        content_list.append(Win32_PhysicalMemory)
        content_list.append(Win32_DiskDrive)
        content_list.append(software)

        lbbase = Base(metadata=base_metadata, content=content_list)

        return lbbase
예제 #28
0
    def lbbase(self):
        """
        LB Base do órgão
        """
        OperatingSystem_item = Field(**dict(
            name='OperatingSystem_item',
            description='Item Coletado',
            alias='Item',
            datatype='Text',
            indices=['Textual', 'Unico'],
            multivalued=False,
            required=True
        ))

        OperatingSystem_amount = Field(**dict(
            name='OperatingSystem_amount',
            alias='amount',
            description='amount',
            datatype='Integer',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        Win32_BIOS_item = Field(**dict(
            name='Win32_BIOS_item',
            description='Item Coletado',
            alias='Item',
            datatype='Text',
            indices=['Textual', 'Unico'],
            multivalued=False,
            required=True
        ))

        Win32_BIOS_amount = Field(**dict(
            name='Win32_BIOS_amount',
            alias='amount',
            description='amount',
            datatype='Integer',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        Win32_Processor_item = Field(**dict(
            name='Win32_Processor_item',
            description='Item Coletado',
            alias='Item',
            datatype='Text',
            indices=['Textual', 'Unico'],
            multivalued=False,
            required=True
        ))

        Win32_Processor_amount = Field(**dict(
            name='Win32_Processor_amount',
            alias='amount',
            description='amount',
            datatype='Integer',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        Win32_DiskDrive_item = Field(**dict(
            name='Win32_DiskDrive_item',
            description='Item Coletado',
            alias='Item',
            datatype='Text',
            indices=['Textual', 'Unico'],
            multivalued=False,
            required=True
        ))

        Win32_DiskDrive_amount = Field(**dict(
            name='Win32_DiskDrive_amount',
            alias='amount',
            description='amount',
            datatype='Integer',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        Win32_PhysicalMemory_item = Field(**dict(
            name='Win32_PhysicalMemory_item',
            description='Item Coletado',
            alias='Item',
            datatype='Text',
            indices=['Textual', 'Unico'],
            multivalued=False,
            required=True
        ))

        Win32_PhysicalMemory_amount = Field(**dict(
            name='Win32_PhysicalMemory_amount',
            alias='amount',
            description='amount',
            datatype='Integer',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        software_item = Field(**dict(
            name='SoftwareList_item',
            description='Software Coletado',
            alias='SoftwareList_item',
            datatype='Text',
            indices=['Textual', 'Unico'],
            multivalued=False,
            required=True
        ))

        software_amount = Field(**dict(
            name='SoftwareList_amount',
            alias='SoftwareList_amount',
            description='Software Amount',
            datatype='Integer',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        """
        GROUP Sistema Operacional
        """
        OperatingSystem_content = Content()
        OperatingSystem_content.append(OperatingSystem_item)
        OperatingSystem_content.append(OperatingSystem_amount)

        OperatingSystem_metadata = GroupMetadata(
            name='OperatingSystem',
            alias='OperatingSystem',
            description='OperatingSystem',
            multivalued = False
        )

        OperatingSystem = Group(
            metadata = OperatingSystem_metadata,
            content = OperatingSystem_content
        )

        """
        GROUP Bios
        """
        Win32_BIOS_content = Content()
        Win32_BIOS_content.append(Win32_BIOS_item)
        Win32_BIOS_content.append(Win32_BIOS_amount)

        Win32_BIOS_metadata = GroupMetadata(
            name='Win32_BIOS',
            alias='Win32_BIOS',
            description='Win32_BIOS',
            multivalued=False
        )

        Win32_BIOS = Group(
            metadata=Win32_BIOS_metadata,
            content=Win32_BIOS_content
        )

        """
        GROUP Processador
        """
        Win32_Processor_content = Content()
        Win32_Processor_content.append(Win32_Processor_item)
        Win32_Processor_content.append(Win32_Processor_amount)

        Win32_Processor_metadata = GroupMetadata(
            name='Win32_Processor',
            alias='Win32_Processor',
            description='Win32_Processor',
            multivalued=False
        )

        Win32_Processor = Group(
            metadata=Win32_Processor_metadata,
            content=Win32_Processor_content
        )

        """
        GROUP DiskDrive
        """
        Win32_DiskDrive_content = Content()
        Win32_DiskDrive_content.append(Win32_DiskDrive_item)
        Win32_DiskDrive_content.append(Win32_DiskDrive_amount)

        Win32_DiskDrive_metadata = GroupMetadata(
            name='Win32_DiskDrive',
            alias='Win32_DiskDrive',
            description='Win32_DiskDrive',
            multivalued = False
        )

        Win32_DiskDrive = Group(
            metadata = Win32_DiskDrive_metadata,
            content = Win32_DiskDrive_content
        )

        """
        GROUP PhysicalMemory
        """
        Win32_PhysicalMemory_content = Content()
        Win32_PhysicalMemory_content.append(Win32_PhysicalMemory_item)
        Win32_PhysicalMemory_content.append(Win32_PhysicalMemory_amount)

        Win32_PhysicalMemory_metadata = GroupMetadata(
            name='Win32_PhysicalMemory',
            alias='Win32_PhysicalMemory',
            description='Win32_PhysicalMemory',
            multivalued=False
        )

        Win32_PhysicalMemory = Group(
            metadata=Win32_PhysicalMemory_metadata,
            content=Win32_PhysicalMemory_content
        )

        """
        GROUP Software
        """
        software_content = Content()
        software_content.append(software_item)
        software_content.append(software_amount)

        software_metadata = GroupMetadata(
            name='SoftwareList',
            alias='SoftwareList',
            description='Lista de softwares',
            multivalued=False
        )

        software = Group(
            metadata=software_metadata,
            content=software_content
        )

        base_metadata = BaseMetadata(
            name = self.nm_base + "_bk",
        )

        content_list = Content()
        content_list.append(OperatingSystem)
        content_list.append(Win32_BIOS)
        content_list.append(Win32_Processor)
        content_list.append(Win32_PhysicalMemory)
        content_list.append(Win32_DiskDrive)
        content_list.append(software)

        lbbase = Base(
            metadata=base_metadata,
            content=content_list
        )

        return lbbase
예제 #29
0
def attribute2lbfield(attr_name, attr_type, attr_value):
    """
    Convert object attributes to LB Field
    @param elm: Elm dictionary of attributes description
    @return: LB Field Object
    """

    try:
        content_list = Content()
        for group_elm in attr_value.__dict__.keys():
            # Now convert to field every group element
            content_list.append(
                attribute2lbfield(
                    #attr_name + '_' + group_elm,
                    group_elm,
                    type(attr_value.__dict__.get(group_elm)),
                    getattr(attr_value, group_elm)))
        group_metadata = GroupMetadata(name=attr_name,
                                       alias=attr_name,
                                       description=attr_name,
                                       multivalued=False)
        return Group(metadata=group_metadata, content=content_list)
    except:
        # Now proccess field regularly
        if attr_type == dict:
            # Consider it a group
            content_list = Content()
            for group_elm in attr_value.keys():
                content_list.append(
                    attribute2lbfield(
                        #attr_name + '_' + group_elm,
                        group_elm,
                        type(attr_value[group_elm]),
                        attr_value[group_elm]))
            group_metadata = GroupMetadata(name=attr_name,
                                           alias=attr_name,
                                           description=attr_name,
                                           multivalued=False)
            return Group(metadata=group_metadata, content=content_list)

        elif attr_type == list:
            # Check for multivalued group
            lbtype = 'Text'
            if len(attr_value) > 0:
                lbtype = pytypes.pytype2lbtype(type(attr_value[0]))
                try:
                    content_list = Content()
                    for group_elm in attr_value[0].__dict__.keys():
                        # Now convert to field every group element
                        content_list.append(
                            attribute2lbfield(
                                #attr_name + '_' + group_elm,
                                group_elm,
                                type(attr_value[0].__dict__.get(group_elm)),
                                getattr(attr_value[0], group_elm)))
                    group_metadata = GroupMetadata(name=attr_name,
                                                   alias=attr_name,
                                                   description=attr_name,
                                                   multivalued=True)
                    return Group(metadata=group_metadata, content=content_list)
                except:
                    # Now proccess field regularly
                    if type(attr_value[0]) == dict:
                        # Consider it a group
                        content_list = Content()
                        for group_elm in attr_value[0].keys():
                            content_list.append(
                                attribute2lbfield(
                                    #attr_name + '_' + group_elm,
                                    group_elm,
                                    type(attr_value[0][group_elm]),
                                    attr_value[0][group_elm]))
                        group_metadata = GroupMetadata(name=attr_name,
                                                       alias=attr_name,
                                                       description=attr_name,
                                                       multivalued=True)
                        return Group(metadata=group_metadata,
                                     content=content_list)

            return Field(name=attr_name,
                         description=attr_name,
                         alias=attr_name,
                         datatype=lbtype,
                         indices=['Textual'],
                         multivalued=True,
                         required=False)
        else:
            return Field(name=attr_name,
                         description=attr_name,
                         alias=attr_name,
                         datatype=pytypes.pytype2lbtype(attr_type) or 'Text',
                         indices=['Textual'],
                         multivalued=False,
                         required=False)
예제 #30
0
    def lbbase(self):
        """
        LB Base de Users
        """
        nome = Field(**dict(
            name='nome',
            description='Nome do Usuário',
            alias='nome',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        matricula = Field(**dict(
            name='matricula',
            alias='matricula',
            description='Matricula do Usuário',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        email = Field(**dict(
            name='email',
            alias='email',
            description='E-mail do Usuário',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        telefone = Field(**dict(
            name='telefone',
            alias='telefone',
            description='Telefone do Usuário',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        orgao = Field(**dict(
            name='orgao',
            alias='orgao',
            description='Orgão do Usuário',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))


        cargo = Field(**dict(
            name='cargo',
            alias='cargo',
            description='Cargo do Usuário',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        setor = Field(**dict(
            name='setor',
            alias='setor',
            description='Setor do Usuário',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        permissao = Field(**dict(
            name='permissao',
            alias='permissao',
            description='Permissão do Usuário',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))
        
        senha = Field(**dict(
                    name='senha',
                    alias='senha',
                    description='Senha do Usuário',
                    datatype='Text',
                    indices=['Textual'],
                    multivalued=False,
                    required=True
        ))
        favoritos = Field(**dict(
                    name='favoritos',
                    alias='favoritos',
                    description='Favoritos do Usuário',
                    datatype='Text',
                    indices=['Textual'],
                    multivalued=True,
                    required=False
        ))
        home = Field(**dict(
                    name='home',
                    alias='home',
                    description='Home do Usuário',
                    datatype='Text',
                    indices=['Textual'],
                    multivalued=True,
                    required=False
        ))
        itens = Field(**dict(
                    name='itens',
                    alias='itens',
                    description='Itens do Usuário',
                    datatype='Text',
                    indices=['Textual'],
                    multivalued=True,
                    required=False
        ))

        url_hash = Field(**dict(
                    name='url_hash',
                    alias='url_hash',
                    description='hash que sera usado para para criar a url',
                    datatype='Text',
                    indices=['Textual'],
                    multivalued=True,
                    required=False
        ))

        nm_user = Field(**dict(
                    name='nm_user',
                    alias='nm_user',
                    description='Nome do usuario',
                    datatype='Text',
                    indices=['Textual'],
                    multivalued=True,
                    required=False
        ))

        HashUrl_content = Content()
        HashUrl_content.append(nm_user)
        HashUrl_content.append(url_hash)

        HashUrl_metadata = GroupMetadata(
            name='HashUrl',
            alias='HashUrl',
            description='HashUrl',
            multivalued=False
        )

        HashUrl = Group(
            metadata = HashUrl_metadata,
            content = HashUrl_content
        )

        base_metadata = BaseMetadata(
            name='users',
        )

        content_list = Content()
        content_list.append(nome)
        content_list.append(matricula)
        content_list.append(email)
        content_list.append(telefone)
        content_list.append(orgao)
        content_list.append(cargo)
        content_list.append(setor)
        content_list.append(permissao)
        content_list.append(senha)
        content_list.append(favoritos)
        content_list.append(home)
        content_list.append(itens)
        content_list.append(HashUrl)

        lbbase = Base(
            metadata=base_metadata,
            content=content_list
        )

        return lbbase
예제 #31
0
    def lbbase(self):

        """
        Configuração da Coleta
        """
        nome_orgao = Field(**dict(
            name='nome_orgao',
            description='Nome do Órgão',
            alias='nome_orgao',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=False
        ))

        data_coleta = Field(**dict(
            name='data_coleta',
            description='Data da Coleta',
            alias='data_coleta',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        hash_machine = Field(**dict(
            name='hash_machine',
            description='hash para maquinas',
            alias='hash_machine',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=False
        ))

        data_ultimo_acesso = Field(**dict(
            name='data_ultimo_acesso',
            description='data do ultimo acesso',
            alias='data acesso',
            datatype='DateTime',
            indices=['Textual'],
            multivalued=False,
            required=False
        ))

        # Adições Jansen: 2015-11-26
        mac = Field(**dict(
            name='mac',
            description='MAC Address',
            alias='MAC',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=False
        ))

        ip_computador = Field(**dict(
            name='ip_computador',
            description='IP do Computador',
            alias='Endereço IP',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=False
        ))

        ip_rede = Field(**dict(
            name='ip_rede',
            description='IP da Rede',
            alias='IP da Rede',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=False
        ))

        nome_rede = Field(**dict(
            name='nome_rede',
            description='Nome da Rede',
            alias='Nome da Rede',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=False
        ))

        """
        LB Processadores
        """
        Win32_Processor_Manufacturer = Field(**dict(
            name='Win32_Processor_Manufacturer',
            description='Win32_Processor_Manufacturer',
            alias='Win32_Processor_Manufacturer',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=False
        ))
        Win32_Processor_NumberOfLogicalProcessors = Field(**dict(
            name='Win32_Processor_NumberOfLogicalProcessors',
            description='Win32_Processor_NumberOfLogicalProcessors',
            alias='Win32_Processor_NumberOfLogicalProcessors',
            datatype='Integer',
            indices=[],
            multivalued=False,
            required=False
        ))

        Win32_Processor_Caption = Field(**dict(
            name='Win32_Processor_Caption',
            description='Win32_Processor_Caption',
            alias='Win32_Processor_Caption',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=False
        ))

        Win32_Processor_MaxClockSpeed = Field(**dict(
            name='Win32_Processor_MaxClockSpeed',
            description='Win32_Processor_MaxClockSpeed',
            alias='Win32_Processor_MaxClockSpeed',
            datatype='Integer',
            indices=[],
            multivalued=False,
            required=False
        ))

        Win32_Processor_Family = Field(**dict(
            name='Win32_Processor_Family',
            description='Win32_Processor_Family',
            alias='Win32_Processor_Family',
            datatype='Integer',
            indices=[],
            multivalued=False,
            required=False
        ))

        # Adições Jansen: 2015-11-26
        win32_processor_installdate = Field(**dict(
            name='win32_processor_installdate',
            description='win32_processor_installdate',
            alias='win32_processor_installdate',
            datatype='Text',
            indices=[],
            multivalued=False,
            required=False
        ))

        """
        BaseBoard
        """
        # Adições Jansen: 2015-11-26
        win32_baseboard_installdate = Field(**dict(
            name='win32_baseboard_installdate',
            description='win32_baseboard_installdate',
            alias='win32_baseboard_installdate',
            datatype='Text',
            indices=[],
            multivalued=False,
            required=False
        ))

        """
        LB Sistema Operacional
        """
        OperatingSystem_Version = Field(**dict(
            name='OperatingSystem_Version',
            description='OperatingSystem_Version',
            alias='OperatingSystem_Version',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=False
        ))
        OperatingSystem_InstallDate = Field(**dict(
            name='OperatingSystem_InstallDate',
            description='OperatingSystem_InstallDate',
            alias='OperatingSystem_InstallDate',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=False
        ))
        OperatingSystem_Caption = Field(**dict(
            name='OperatingSystem_Caption',
            description='OperatingSystem_Caption',
            alias='OperatingSystem_Caption',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=False
        ))

        """
        LB SoftwareList
        """
        SoftwareList = Field(**dict(
            name='SoftwareList',
            description='SoftwareList',
            alias='SoftwareList',
            datatype='Text',
            indices=['Textual'],
            multivalued=True,
            required=False
        ))

        """
        LB Bios
        """
        Win32_BIOS_Manufacturer = Field(**dict(
            name='Win32_BIOS_Manufacturer',
            description='Win32_BIOS_Manufacturer',
            alias='Win32_BIOS_Manufacturer',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=False
        ))

        # Adições Jansen: 2015-11-26
        win32_bios_installdate = Field(**dict(
            name='win32_bios_installdate',
            description='win32_bios_installdate',
            alias='win32_bios_installdate',
            datatype='Text',
            indices=[],
            multivalued=False,
            required=False
        ))

        win32_bios_releasedate = Field(**dict(
            name='win32_bios_releasedate',
            description='win32_bios_releasedate',
            alias='win32_bios_releasedate',
            datatype='Text',
            indices=[],
            multivalued=False,
            required=False
        ))

        """
        LB Physical Memory
        """
        Win32_PhysicalMemory_MemoryType = Field(**dict(
            name='Win32_PhysicalMemory_MemoryType',
            description='Win32_PhysicalMemory_MemoryType',
            alias='Win32_PhysicalMemory_MemoryType',
            datatype='Integer',
            indices=[],
            multivalued=False,
            required=False
        ))

        Win32_PhysicalMemory_Capacity = Field(**dict(
            name='Win32_PhysicalMemory_Capacity',
            description='Win32_PhysicalMemory_Capacity',
            alias='Win32_PhysicalMemory_Capacity',
            datatype='Integer',
            indices=[],
            multivalued=False,
            required=False
        ))

        """
        LB Disk
        """
        Win32_DiskDrive_Caption = Field(**dict(
            name='Win32_DiskDrive_Caption',
            description='Win32_DiskDrive_Caption',
            alias='Win32_DiskDrive_Caption',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=False
        ))

        Win32_DiskDrive_Model = Field(**dict(
            name='Win32_DiskDrive_Model',
            description='Win32_DiskDrive_Model',
            alias='Win32_DiskDrive_Model',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=False
        ))

        Win32_DiskDrive_Size = Field(**dict(
            name='Win32_DiskDrive_Size',
            description='Win32_DiskDrive_Size',
            alias='Win32_DiskDrive_Size',
            datatype='Integer',
            indices=[],
            multivalued=False,
            required=False
        ))

        """
        GROUP Sistema Operacional
        """
        OperatingSystem_content = Content()
        OperatingSystem_content.append(OperatingSystem_Version)
        OperatingSystem_content.append(OperatingSystem_InstallDate)
        OperatingSystem_content.append(OperatingSystem_Caption)

        OperatingSystem_metadata = GroupMetadata(
            name='OperatingSystem',
            alias='OperatingSystem',
            description='OperatingSystem',
            multivalued=False
        )

        OperatingSystem = Group(
            metadata=OperatingSystem_metadata,
            content=OperatingSystem_content
        )

        """
        GROUP Bios
        """
        Win32_BIOS_content = Content()
        Win32_BIOS_content.append(Win32_BIOS_Manufacturer)
        Win32_BIOS_content.append(win32_bios_installdate)
        Win32_BIOS_content.append(win32_bios_releasedate)

        Win32_BIOS_metadata = GroupMetadata(
            name='Win32_BIOS',
            alias='Win32_BIOS',
            description='Win32_BIOS',
            multivalued=False
        )

        Win32_BIOS = Group(
            metadata = Win32_BIOS_metadata,
            content = Win32_BIOS_content
        )

        """
        GROUP Processador
        """
        Win32_Processor_content = Content()
        Win32_Processor_content.append(Win32_Processor_Manufacturer)
        Win32_Processor_content.append(Win32_Processor_NumberOfLogicalProcessors)
        Win32_Processor_content.append(Win32_Processor_Caption)
        Win32_Processor_content.append(Win32_Processor_MaxClockSpeed)
        Win32_Processor_content.append(Win32_Processor_Family)
        Win32_Processor_content.append(win32_processor_installdate)

        Win32_Processor_metadata = GroupMetadata(
            name='Win32_Processor',
            alias='Win32_Processor',
            description='Win32_Processor',
            multivalued = False
        )

        Win32_Processor = Group(
            metadata = Win32_Processor_metadata,
            content = Win32_Processor_content
        )

        """
        GROUP Physical Memory
        """
        Win32_PhysicalMemory_content = Content()
        Win32_PhysicalMemory_content.append(Win32_PhysicalMemory_Capacity)
        Win32_PhysicalMemory_content.append(Win32_PhysicalMemory_MemoryType)

        Win32_PhysicalMemory_metadata = GroupMetadata(
            name='Win32_PhysicalMemory',
            alias='Win32_PhysicalMemory',
            description='Win32_PhysicalMemory',
            multivalued=False
        )

        Win32_PhysicalMemory = Group(
            metadata=Win32_PhysicalMemory_metadata,
            content=Win32_PhysicalMemory_content
        )

        """
        GROUP Logical Disk
        """
        Win32_DiskDrive_content = Content()
        Win32_DiskDrive_content.append(Win32_DiskDrive_Caption)
        Win32_DiskDrive_content.append(Win32_DiskDrive_Model)
        Win32_DiskDrive_content.append(Win32_DiskDrive_Size)

        Win32_DiskDrive_metadata = GroupMetadata(
            name='Win32_DiskDrive',
            alias='Win32_DiskDrive',
            description='Win32_DiskDrive',
            multivalued=False
        )

        Win32_DiskDrive = Group(
            metadata=Win32_DiskDrive_metadata,
            content=Win32_DiskDrive_content
        )

        """
        Group BaseBoard
        """
        Win32_BaseBoard_content = Content()
        Win32_BaseBoard_content.append(win32_baseboard_installdate)

        Win32_BaseBoard_metadata = GroupMetadata(
            name='Win32_BaseBoard',
            alias='Win32_BaseBoard',
            description='Win32_BaseBoard',
            multivalued=False
        )

        Win32_BaseBoard = Group(
            metadata=Win32_BaseBoard_metadata,
            content=Win32_BaseBoard_content
        )


        base_metadata = BaseMetadata(
            name='orgaos_bk',
        )

        content_list = Content()
        content_list.append(data_coleta)
        content_list.append(Win32_Processor)
        content_list.append(OperatingSystem)
        content_list.append(Win32_BIOS)
        content_list.append(Win32_PhysicalMemory)
        content_list.append(Win32_DiskDrive)
        content_list.append(Win32_BaseBoard)
        content_list.append(SoftwareList)
        content_list.append(hash_machine)
        content_list.append(data_ultimo_acesso)
        content_list.append(mac)
        content_list.append(ip_computador)
        content_list.append(ip_rede)
        content_list.append(nome_rede)
        content_list.append(nome_orgao)

        lbbase = Base(
            metadata=base_metadata,
            content=content_list
        )

        return lbbase
예제 #32
0
    def lbbase(self):
        """
        Generate LB Base object
        :return:
        """
        location_name = Field(**dict(name='location_name',
                                     description='Location name',
                                     alias='Location name',
                                     datatype='Text',
                                     indices=['Textual'],
                                     multivalued=False,
                                     required=True))

        latitude = Field(**dict(name='latitude',
                                description='Latitude',
                                alias='Latitude',
                                datatype='Decimal',
                                indices=[],
                                multivalued=False,
                                required=True))

        longitude = Field(**dict(name='longitude',
                                 description='Longitude',
                                 alias='longitude',
                                 datatype='Decimal',
                                 indices=[],
                                 multivalued=False,
                                 required=True))

        location_type = Field(**dict(name='location_type',
                                     description='Location type',
                                     alias='Location type',
                                     datatype='Text',
                                     indices=['Textual'],
                                     multivalued=False,
                                     required=True))

        loc_origin = Field(**dict(name='loc_origin',
                                  description='Location origin',
                                  alias='Location origin',
                                  datatype='Text',
                                  indices=['Textual'],
                                  multivalued=False,
                                  required=True))

        city = Field(**dict(
            name='city',
            description=
            'Location that comes from social networks. Used in searches',
            alias='City',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True))

        base_metadata = BaseMetadata(**dict(
            name='location',
            description='Status location',
            idx_exp=True,
            idx_exp_url=self.es_url + '/location',
            idx_exp_time=300,
        ))

        content_list = Content()
        content_list.append(location_name)
        content_list.append(latitude)
        content_list.append(longitude)
        content_list.append(location_type)
        content_list.append(loc_origin)
        content_list.append(city)

        lbbase = Base(metadata=base_metadata, content=content_list)

        return lbbase
예제 #33
0
def attribute2lbfield(attr_name, attr_type, attr_value):
    """
    Convert object attributes to LB Field
    @param elm: Elm dictionary of attributes description
    @return: LB Field Object
    """

    try:
        content_list = Content()
        for group_elm in attr_value.__dict__.keys():
            # Now convert to field every group element
            content_list.append(attribute2lbfield(
                #attr_name + '_' + group_elm,
                group_elm,
                type(attr_value.__dict__.get(group_elm)),
                getattr(attr_value, group_elm)))
        group_metadata = GroupMetadata(
            name=attr_name,
            alias=attr_name,
            description=attr_name,
            multivalued=False)
        return Group(
            metadata=group_metadata,
            content=content_list)
    except:
        # Now proccess field regularly
        if attr_type == dict:
            # Consider it a group
            content_list = Content()
            for group_elm in attr_value.keys():
                content_list.append(attribute2lbfield(
                    #attr_name + '_' + group_elm,
                    group_elm,
                    type(attr_value[group_elm]),
                    attr_value[group_elm]))
            group_metadata = GroupMetadata(
                name=attr_name,
                alias=attr_name,
                description=attr_name,
                multivalued = False)
            return Group(
                metadata=group_metadata,
                content=content_list)

        elif attr_type == list:
            # Check for multivalued group
            lbtype = 'Text'
            if len(attr_value) > 0:
                lbtype = pytypes.pytype2lbtype(type(attr_value[0]))
                #print(type(attr_value[0]))
                try:
                    content_list = Content()
                    for group_elm in attr_value[0].__dict__.keys():
                        # Now convert to field every group element
                        content_list.append(attribute2lbfield(
                            #attr_name + '_' + group_elm,
                            group_elm,
                            type(attr_value[0].__dict__.get(group_elm)),
                            getattr(attr_value[0], group_elm)))
                    group_metadata = GroupMetadata(
                        name=attr_name,
                        alias=attr_name,
                        description=attr_name,
                        multivalued=True)
                    return Group(
                        metadata=group_metadata,
                        content=content_list)
                except:
                    # Now proccess field regularly
                    if type(attr_value[0]) == dict:
                        # Consider it a group
                        content_list = Content()
                        for group_elm in attr_value[0].keys():
                            content_list.append(attribute2lbfield(
                                #attr_name + '_' + group_elm,
                                group_elm,
                                type(attr_value[0][group_elm]),
                                attr_value[0][group_elm]))
                        group_metadata = GroupMetadata(
                            name=attr_name,
                            alias=attr_name,
                            description=attr_name,
                            multivalued = True)
                        return Group(
                            metadata=group_metadata,
                            content=content_list)

            #print(lbtype)
            return Field(
                name=attr_name,
                description=attr_name,
                alias=attr_name,
                datatype = lbtype,
                indices = ['Textual'],
                multivalued = True,
                required = False)
        else:
            return Field(
                name=attr_name,
                description=attr_name,
                alias=attr_name,
                datatype = pytypes.pytype2lbtype(attr_type) or 'Text',
                indices = ['Textual'],
                multivalued = False,
                required = False)
예제 #34
0
    def lbbase(self):
        """
        Generate LB Base object
        :return:
        """
        inclusion_date = Field(**dict(
            name='inclusion_date',
            description='Attribute inclusion date',
            alias='inclusion_date',
            datatype='Date',
            indices=['Ordenado'],
            multivalued=False,
            required=False
        ))

        inclusion_datetime = Field(**dict(
            name='inclusion_datetime',
            description='Attribute inclusion date',
            alias='inclusion_datetime',
            datatype='DateTime',
            indices=['Ordenado'],
            multivalued=False,
            required=False
        ))

        origin = Field(**dict(
            name='origin',
            alias='origin',
            description='Where this status came from',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        search_term = Field(**dict(
            name='search_term',
            alias='search_term',
            description='Term used on search',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        source = Field(**dict(
            name='source',
            alias='source',
            description='Original status source',
            datatype='Json',
            indices=['Textual', 'Unico'],
            multivalued=False,
            required=True
        ))

        text = Field(**dict(
            name='text',
            alias='text',
            description='Status original text',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=False
        ))

        tokens = Field(**dict(
            name='tokens',
            alias='tokens',
            description='Tokens extracted from Semantic Role Labeling',
            datatype='Text',
            indices=['Textual'],
            multivalued=True,
            required=False
        ))

        hashtags = Field(**dict(
            name='hashtags',
            alias='hashtags',
            description='Hashtags identified',
            datatype='Text',
            indices=['Textual'],
            multivalued=True,
            required=False
        ))

        arg_content_list = Content()

        arg_metadata = GroupMetadata(**dict(
            name='arg_structures',
            alias='arg_structures',
            description='SRL arg structures',
            multivalued=True
        ))

        predicate = Field(**dict(
            name='predicate',
            alias='predicate',
            description='Predicate for term in SRL',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=False
        ))

        arg_content_list.append(predicate)

        argument_metadata = GroupMetadata(**dict(
            name='argument',
            alias='argument',
            description='Argument for term in SRL',
            multivalued=True
        ))

        argument_list = Content()

        argument_name = Field(**dict(
            name='argument_name',
            alias='argument_name',
            description='Argument identification',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=False
        ))

        argument_list.append(argument_name)

        argument_value = Field(**dict(
            name='argument_value',
            alias='argument_value',
            description='Argument Value for SRL',
            datatype='Text',
            indices=['Textual'],
            multivalued=True,
            required=False
        ))

        argument_list.append(argument_value)

        argument = Group(
            metadata=argument_metadata,
            content=argument_list
        )

        arg_content_list.append(argument)

        arg_structures = Group(
            metadata=arg_metadata,
            content=arg_content_list
        )

        events_tokens = Field(**dict(
            name='events_tokens',
            alias='events_tokens',
            description='Identified Events tokens',
            datatype='Text',
            indices=['Textual'],
            multivalued=True,
            required=False
        ))

        selected_category = Field(**dict(
            name='selected_category',
            alias='selected_category',
            description='Manually selected category',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=False
        ))

        positives = Field(**dict(
            name='positives',
            alias='positives',
            description='Positive crime identification',
            datatype='Integer',
            indices=['Ordenado'],
            multivalued=False,
            required=False
        ))

        negatives = Field(**dict(
            name='negatives',
            alias='negatives',
            description='False positive on crime identification',
            datatype='Integer',
            indices=['Ordenado'],
            multivalued=False,
            required=False
        ))

        location_list = Content()

        id_location = Field(**dict(
            name='id_location',
            alias='ID Location',
            description='Location Identification',
            datatype='Integer',
            indices=[],
            multivalued=False,
            required=False
        ))

        location_list.append(id_location)

        latitude = Field(**dict(
            name='latitude',
            alias='Latitude',
            description='Latitude',
            datatype='Decimal',
            indices=[],
            multivalued=False,
            required=False
        ))

        location_list.append(latitude)

        longitude = Field(**dict(
            name='longitude',
            alias='Longitude',
            description='Longitude',
            datatype='Decimal',
            indices=[],
            multivalued=False,
            required=False
        ))

        location_list.append(longitude)

        city = Field(**dict(
            name='city',
            alias='City',
            description='City identified',
            datatype='Text',
            indices=[],
            multivalued=False,
            required=False
        ))

        location_list.append(city)

        loc_origin = Field(**dict(
            name='loc_origin',
            alias='Location Origin',
            description='Origin from location identificaton',
            datatype='Text',
            indices=[],
            multivalued=False,
            required=False
        ))

        location_list.append(loc_origin)

        location_metadata = GroupMetadata(**dict(
            name='location',
            alias='location',
            description='Status origin',
            multivalued=False
        ))

        location = Group(
            metadata=location_metadata,
            content=location_list
        )

        # Category
        category_list = Content()

        category_id_doc = Field(**dict(
            name='category_id_doc',
            alias='Category ID',
            description='id_doc for category in category base',
            datatype='Integer',
            indices=['Ordenado'],
            multivalued=False,
            required=False
        ))

        category_list.append(category_id_doc)

        category_probability = Field(**dict(
            name='category_probability',
            alias='Category Probability',
            description='Classification probability',
            datatype='Decimal',
            indices=[],
            multivalued=False,
            required=False
        ))

        category_list.append(category_probability)

        category_metadata = GroupMetadata(**dict(
            name='category',
            alias='Category',
            description='Category classification information',
            multivalued=False
        ))

        category = Group(
            metadata=category_metadata,
            content=category_list
        )

        # Brasil City
        city_list = Content()

        city_id = Field(**dict(
            name='city_id',
            alias='City ID',
            description='Id for city in LBGeo database',
            datatype='Integer',
            indices=[],
            multivalued=False,
            required=False
        ))

        city_list.append(city_id)

        city_name = Field(**dict(
            name='city_name',
            alias='City Name',
            description='City name in LBGeo database',
            datatype='Text',
            indices=[],
            multivalued=False,
            required=False
        ))

        city_list.append(city_name)

        city_state_id = Field(**dict(
            name='city_state_id',
            alias='City State ID',
            description='Id for state in LBGeo database',
            datatype='Integer',
            indices=[],
            multivalued=False,
            required=False
        ))

        city_list.append(city_state_id)

        state_name = Field(**dict(
            name='state_name',
            alias='State Name',
            description='State Name in LBGeo database',
            datatype='Text',
            indices=[],
            multivalued=False,
            required=False
        ))

        city_list.append(state_name)

        state_short_name = Field(**dict(
            name='state_short_name',
            alias='UF',
            description='UF in LBGeo database',
            datatype='Text',
            indices=[],
            multivalued=False,
            required=False
        ))

        city_list.append(state_short_name)

        state_slug = Field(**dict(
            name='state_slug',
            alias='Stte Slug',
            description='State Slug in LBGeo database',
            datatype='Text',
            indices=[],
            multivalued=False,
            required=False
        ))

        city_list.append(state_slug)

        city_slug = Field(**dict(
            name='city_slug',
            alias='City Slug',
            description='City Slug in LBGeo database',
            datatype='Text',
            indices=[],
            multivalued=False,
            required=False
        ))

        city_list.append(city_slug)

        city_lat = Field(**dict(
            name='city_lat',
            alias='City Latitude',
            description='City Latitude in LBGeo database',
            datatype='Decimal',
            indices=[],
            multivalued=False,
            required=False
        ))

        city_list.append(city_lat)

        city_lng = Field(**dict(
            name='city_lng',
            alias='City Longitude',
            description='City Longitude in LBGeo database',
            datatype='Decimal',
            indices=[],
            multivalued=False,
            required=False
        ))

        city_list.append(city_lng)

        city_distance = Field(**dict(
            name='city_distance',
            alias='City Distance',
            description='Distance from city in LBGeo database',
            datatype='Decimal',
            indices=[],
            multivalued=False,
            required=False
        ))

        city_list.append(city_distance)

        city_metadata = GroupMetadata(**dict(
            name='brasil_city',
            alias='City in Brasil',
            description='City in Brasil identified by LBGeo',
            multivalued=False
        ))

        brasil_city = Group(
            metadata=city_metadata,
            content=city_list
        )

        base_metadata = BaseMetadata(**dict(
            name=self.status_base,
            description='Status from social networks',
            password='******',
            idx_exp=False,
            idx_exp_url='index_url',
            idx_exp_time=300,
            file_ext=True,
            file_ext_time=300,
            color='#FFFFFF'
        ))

        content_list = Content()
        content_list.append(inclusion_date)
        content_list.append(inclusion_datetime)
        content_list.append(text)
        content_list.append(search_term)
        content_list.append(tokens)
        content_list.append(arg_structures)
        content_list.append(origin)
        content_list.append(source)
        content_list.append(events_tokens)
        content_list.append(selected_category)
        content_list.append(positives)
        content_list.append(negatives)
        content_list.append(location)
        content_list.append(hashtags)
        content_list.append(category)
        content_list.append(brasil_city)

        lbbase = Base(
            metadata=base_metadata,
            content=content_list
        )

        return lbbase
예제 #35
0
    def lbbase(self):
        """
        LB Base de Notify
        """
        orgao = Field(**dict(
            name='orgao',
            description='Órgão referente a notrificção',
            alias='orgao',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        data_coleta = Field(**dict(
            name='data_coleta',
            alias='data_coleta',
            description='data da coleta notificada',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        notify = Field(**dict(
            name='notify',
            alias='notify',
            description='tipo de notificação',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        coment = Field(**dict(
            name='coment',
            alias='coment',
            description='comentario',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        status = Field(**dict(
            name='status',
            alias='status',
            description='status da notificação',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        base_metadata = BaseMetadata(
            name='notify',
        )
        content_list = Content()
        content_list.append(orgao)
        content_list.append(data_coleta)
        content_list.append(notify)
        content_list.append(coment)
        content_list.append(status)

        lbbase = Base(
            metadata=base_metadata,
            content=content_list
        )

        return lbbase
예제 #36
0
    def lbbase(self):
        """
        Base no LB
        :return: LB Base object
        """
        tipo = Field(**dict(
            name='tipo',
            description='Tipo de atividade',
            alias='tipo',
            datatype='Text',
            indices=['Textual', 'Ordenado'],
            multivalued=False,
            required=True
        ))

        usuario = Field(**dict(
            name='usuario',
            description='Usuário que realizou a atividade',
            alias='usuario',
            datatype='Text',
            indices=['Textual', 'Ordenado'],
            multivalued=False,
            required=True
        ))

        descricao = Field(**dict(
            name='descricao',
            description='Descrição da atividade',
            alias='descricao',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        data = Field(**dict(
            name='data',
            description='Data de execução da tarefa',
            alias='data',
            datatype='Date',
            indices=['Ordenado'],
            multivalued=False,
            required=True
        ))

        data_hora = Field(**dict(
            name='data_hora',
            description='Data e Hora de execução da tarefa',
            alias='data_hora',
            datatype='DateTime',
            indices=['Ordenado'],
            multivalued=False,
            required=False
        ))

        content_list = Content()
        content_list.append(tipo)
        content_list.append(usuario)
        content_list.append(descricao)
        content_list.append(data)
        content_list.append(data_hora)

        base_metadata = BaseMetadata(
            name='atividade'
        )

        lbbase = Base(
            metadata=base_metadata,
            content=content_list
        )

        return lbbase
예제 #37
0
    def lbbase(self):
        """
        Generate LB Base object
        :return:
        """
        inclusion_date = Field(**dict(name='inclusion_date',
                                      description='Attribute inclusion date',
                                      alias='inclusion_date',
                                      datatype='Date',
                                      indices=['Ordenado'],
                                      multivalued=False,
                                      required=False))

        inclusion_datetime = Field(
            **dict(name='inclusion_datetime',
                   description='Attribute inclusion date',
                   alias='inclusion_datetime',
                   datatype='DateTime',
                   indices=['Ordenado'],
                   multivalued=False,
                   required=False))

        origin = Field(**dict(name='origin',
                              alias='origin',
                              description='Where this status came from',
                              datatype='Text',
                              indices=['Textual'],
                              multivalued=False,
                              required=True))

        search_term = Field(**dict(name='search_term',
                                   alias='search_term',
                                   description='Term used on search',
                                   datatype='Text',
                                   indices=['Textual'],
                                   multivalued=False,
                                   required=True))

        source = Field(**dict(name='source',
                              alias='source',
                              description='Original status source',
                              datatype='Json',
                              indices=['Textual', 'Unico'],
                              multivalued=False,
                              required=True))

        text = Field(**dict(name='text',
                            alias='text',
                            description='Status original text',
                            datatype='Text',
                            indices=['Textual'],
                            multivalued=False,
                            required=False))

        tokens = Field(
            **dict(name='tokens',
                   alias='tokens',
                   description='Tokens extracted from Semantic Role Labeling',
                   datatype='Text',
                   indices=['Textual'],
                   multivalued=True,
                   required=False))

        hashtags = Field(**dict(name='hashtags',
                                alias='hashtags',
                                description='Hashtags identified',
                                datatype='Text',
                                indices=['Textual'],
                                multivalued=True,
                                required=False))

        arg_content_list = Content()

        arg_metadata = GroupMetadata(**dict(name='arg_structures',
                                            alias='arg_structures',
                                            description='SRL arg structures',
                                            multivalued=True))

        predicate = Field(**dict(name='predicate',
                                 alias='predicate',
                                 description='Predicate for term in SRL',
                                 datatype='Text',
                                 indices=['Textual'],
                                 multivalued=False,
                                 required=False))

        arg_content_list.append(predicate)

        argument_metadata = GroupMetadata(
            **dict(name='argument',
                   alias='argument',
                   description='Argument for term in SRL',
                   multivalued=True))

        argument_list = Content()

        argument_name = Field(**dict(name='argument_name',
                                     alias='argument_name',
                                     description='Argument identification',
                                     datatype='Text',
                                     indices=['Textual'],
                                     multivalued=False,
                                     required=False))

        argument_list.append(argument_name)

        argument_value = Field(**dict(name='argument_value',
                                      alias='argument_value',
                                      description='Argument Value for SRL',
                                      datatype='Text',
                                      indices=['Textual'],
                                      multivalued=True,
                                      required=False))

        argument_list.append(argument_value)

        argument = Group(metadata=argument_metadata, content=argument_list)

        arg_content_list.append(argument)

        arg_structures = Group(metadata=arg_metadata, content=arg_content_list)

        events_tokens = Field(**dict(name='events_tokens',
                                     alias='events_tokens',
                                     description='Identified Events tokens',
                                     datatype='Text',
                                     indices=['Textual'],
                                     multivalued=True,
                                     required=False))

        selected_category = Field(
            **dict(name='selected_category',
                   alias='selected_category',
                   description='Manually selected category',
                   datatype='Text',
                   indices=['Textual'],
                   multivalued=False,
                   required=False))

        positives = Field(**dict(name='positives',
                                 alias='positives',
                                 description='Positive crime identification',
                                 datatype='Integer',
                                 indices=['Ordenado'],
                                 multivalued=False,
                                 required=False))

        negatives = Field(
            **dict(name='negatives',
                   alias='negatives',
                   description='False positive on crime identification',
                   datatype='Integer',
                   indices=['Ordenado'],
                   multivalued=False,
                   required=False))

        location_list = Content()

        id_location = Field(**dict(name='id_location',
                                   alias='ID Location',
                                   description='Location Identification',
                                   datatype='Integer',
                                   indices=[],
                                   multivalued=False,
                                   required=False))

        location_list.append(id_location)

        latitude = Field(**dict(name='latitude',
                                alias='Latitude',
                                description='Latitude',
                                datatype='Decimal',
                                indices=[],
                                multivalued=False,
                                required=False))

        location_list.append(latitude)

        longitude = Field(**dict(name='longitude',
                                 alias='Longitude',
                                 description='Longitude',
                                 datatype='Decimal',
                                 indices=[],
                                 multivalued=False,
                                 required=False))

        location_list.append(longitude)

        city = Field(**dict(name='city',
                            alias='City',
                            description='City identified',
                            datatype='Text',
                            indices=[],
                            multivalued=False,
                            required=False))

        location_list.append(city)

        loc_origin = Field(
            **dict(name='loc_origin',
                   alias='Location Origin',
                   description='Origin from location identificaton',
                   datatype='Text',
                   indices=[],
                   multivalued=False,
                   required=False))

        location_list.append(loc_origin)

        location_metadata = GroupMetadata(**dict(name='location',
                                                 alias='location',
                                                 description='Status origin',
                                                 multivalued=False))

        location = Group(metadata=location_metadata, content=location_list)

        # Category
        category_list = Content()

        category_id_doc = Field(
            **dict(name='category_id_doc',
                   alias='Category ID',
                   description='id_doc for category in category base',
                   datatype='Integer',
                   indices=['Ordenado'],
                   multivalued=False,
                   required=False))

        category_list.append(category_id_doc)

        category_probability = Field(
            **dict(name='category_probability',
                   alias='Category Probability',
                   description='Classification probability',
                   datatype='Decimal',
                   indices=[],
                   multivalued=False,
                   required=False))

        category_list.append(category_probability)

        category_metadata = GroupMetadata(
            **dict(name='category',
                   alias='Category',
                   description='Category classification information',
                   multivalued=False))

        category = Group(metadata=category_metadata, content=category_list)

        # Brasil City
        city_list = Content()

        city_id = Field(**dict(name='city_id',
                               alias='City ID',
                               description='Id for city in LBGeo database',
                               datatype='Integer',
                               indices=[],
                               multivalued=False,
                               required=False))

        city_list.append(city_id)

        city_name = Field(**dict(name='city_name',
                                 alias='City Name',
                                 description='City name in LBGeo database',
                                 datatype='Text',
                                 indices=[],
                                 multivalued=False,
                                 required=False))

        city_list.append(city_name)

        city_state_id = Field(
            **dict(name='city_state_id',
                   alias='City State ID',
                   description='Id for state in LBGeo database',
                   datatype='Integer',
                   indices=[],
                   multivalued=False,
                   required=False))

        city_list.append(city_state_id)

        state_name = Field(**dict(name='state_name',
                                  alias='State Name',
                                  description='State Name in LBGeo database',
                                  datatype='Text',
                                  indices=[],
                                  multivalued=False,
                                  required=False))

        city_list.append(state_name)

        state_short_name = Field(**dict(name='state_short_name',
                                        alias='UF',
                                        description='UF in LBGeo database',
                                        datatype='Text',
                                        indices=[],
                                        multivalued=False,
                                        required=False))

        city_list.append(state_short_name)

        state_slug = Field(**dict(name='state_slug',
                                  alias='Stte Slug',
                                  description='State Slug in LBGeo database',
                                  datatype='Text',
                                  indices=[],
                                  multivalued=False,
                                  required=False))

        city_list.append(state_slug)

        city_slug = Field(**dict(name='city_slug',
                                 alias='City Slug',
                                 description='City Slug in LBGeo database',
                                 datatype='Text',
                                 indices=[],
                                 multivalued=False,
                                 required=False))

        city_list.append(city_slug)

        city_lat = Field(**dict(name='city_lat',
                                alias='City Latitude',
                                description='City Latitude in LBGeo database',
                                datatype='Decimal',
                                indices=[],
                                multivalued=False,
                                required=False))

        city_list.append(city_lat)

        city_lng = Field(**dict(name='city_lng',
                                alias='City Longitude',
                                description='City Longitude in LBGeo database',
                                datatype='Decimal',
                                indices=[],
                                multivalued=False,
                                required=False))

        city_list.append(city_lng)

        city_distance = Field(
            **dict(name='city_distance',
                   alias='City Distance',
                   description='Distance from city in LBGeo database',
                   datatype='Decimal',
                   indices=[],
                   multivalued=False,
                   required=False))

        city_list.append(city_distance)

        city_metadata = GroupMetadata(
            **dict(name='brasil_city',
                   alias='City in Brasil',
                   description='City in Brasil identified by LBGeo',
                   multivalued=False))

        brasil_city = Group(metadata=city_metadata, content=city_list)

        base_metadata = BaseMetadata(
            **dict(name=self.status_base,
                   description='Status from social networks',
                   password='******',
                   idx_exp=False,
                   idx_exp_url='index_url',
                   idx_exp_time=300,
                   file_ext=True,
                   file_ext_time=300,
                   color='#FFFFFF'))

        content_list = Content()
        content_list.append(inclusion_date)
        content_list.append(inclusion_datetime)
        content_list.append(text)
        content_list.append(search_term)
        content_list.append(tokens)
        content_list.append(arg_structures)
        content_list.append(origin)
        content_list.append(source)
        content_list.append(events_tokens)
        content_list.append(selected_category)
        content_list.append(positives)
        content_list.append(negatives)
        content_list.append(location)
        content_list.append(hashtags)
        content_list.append(category)
        content_list.append(brasil_city)

        lbbase = Base(metadata=base_metadata, content=content_list)

        return lbbase
예제 #38
0
    def lbbase(self):
        """
        Generate LB Base object
        :return:
        """
        analysis_date = Field(**dict(
            name='analysis_date',
            description='Analysis date',
            alias='analysis_date',
            datatype='DateTime',
            indices=['Ordenado'],
            multivalued=False,
            required=True
        ))

        analysis_end_date = Field(**dict(
            name='analysis_end_date',
            description='Analysis end date',
            alias='analysis_date',
            datatype='DateTime',
            indices=[],
            multivalued=False,
            required=False
        ))
        
        total_status = Field(**dict(
            name='total_status',
            description='Total Status Analyzed',
            alias='total_status',
            datatype='Integer',
            indices=['Ordenado'],
            multivalued=False,
            required=True
        ))
        
        total_crimes = Field(**dict(
            name='total_crimes',
            description='Total Crimes Identified',
            alias='total_crimes',
            datatype='Integer',
            indices=['Ordenado'],
            multivalued=False,
            required=True
        ))

        total_positives = Field(**dict(
            name='total_positives',
            description='Total positive status',
            alias='total_positives',
            datatype='Integer',
            indices=['Ordenado'],
            multivalued=False,
            required=False
        ))

        # Add states analysis
        state_list = Content()

        state_uf = Field(**dict(
            name='state_uf',
            description='State UF',
            alias='UF',
            datatype='Text',
            indices=[],
            multivalued=False,
            required=False
        ))

        state_list.append(state_uf)

        state_name = Field(**dict(
            name='state_name',
            description='State Name',
            alias='Estado',
            datatype='Text',
            indices=[],
            multivalued=False,
            required=False
        ))

        state_list.append(state_name)

        category_list = Content()

        category_id_doc = Field(**dict(
            name='category_id_doc',
            description='Category ID',
            alias='ID Categoria',
            datatype='Integer',
            indices=[],
            multivalued=False,
            required=False
        ))

        category_list.append(category_id_doc)

        category_name = Field(**dict(
            name='category_name',
            description='Category Name',
            alias='Categoria',
            datatype='Text',
            indices=[],
            multivalued=False,
            required=False
        ))

        category_list.append(category_name)

        category_status = Field(**dict(
            name='category_status',
            description='Category Status Ocurrences',
            alias='Status',
            datatype='Integer',
            indices=[],
            multivalued=False,
            required=False
        ))

        category_list.append(category_status)

        category_metadata = GroupMetadata(**dict(
            name='category',
            alias='Categoria',
            description='Categories data',
            multivalued=True
        ))

        category = Group(
            metadata=category_metadata,
            content=category_list
        )

        # Add to state group
        state_list.append(category)

        state_metadata = GroupMetadata(**dict(
            name='state',
            alias='Estado',
            description='States Data',
            multivalued=True
        ))

        state = Group(
            metadata=state_metadata,
            content=state_list
        )
        
        status_list = Content()

        status_id_doc = Field(**dict(
            name='status_id_doc',
            description='Identified status id_doc',
            alias='status_id_doc',
            datatype='Integer',
            indices=['Ordenado', 'Unico'],
            multivalued=False,
            required=False
        ))

        status_list.append(status_id_doc)

        status_positives = Field(**dict(
            name='status_positives',
            description='Number of positives for status',
            alias='status_positives',
            datatype='Integer',
            indices=['Ordenado'],
            multivalued=False,
            required=False
        ))

        status_list.append(status_positives)

        status_negatives = Field(**dict(
            name='status_negatives',
            description='Number of negatives for status',
            alias='status_negatives',
            datatype='Integer',
            indices=['Ordenado'],
            multivalued=False,
            required=False
        ))

        status_list.append(status_negatives)

        status_metadata = GroupMetadata(**dict(
            name='status_crimes',
            alias='status_crimes',
            description='Status identified as crimes',
            multivalued=True
        ))

        status_crimes = Group(
            metadata=status_metadata,
            content=status_list
        )

        base_metadata = BaseMetadata(**dict(
            name='analytics',
            description='Criminal data analytics base',
            password='******',
            idx_exp=False,
            idx_exp_url='index_url',
            idx_exp_time=300,
            file_ext=True,
            file_ext_time=300,
            color='#FFFFFF'
        ))

        content_list = Content()
        content_list.append(analysis_date)
        content_list.append(analysis_end_date)
        content_list.append(total_status)
        content_list.append(total_crimes)
        content_list.append(status_crimes)
        content_list.append(total_positives)
        content_list.append(state)

        lbbase = Base(
            metadata=base_metadata,
            content=content_list
        )

        return lbbase
예제 #39
0
파일: model.py 프로젝트: lightbase/LBIndex
    def lbbase(self):
        """
        Generate LB Base object
        :return:
        """
        nm_base = Field(**dict(
            name='nm_base',
            description='Nome da base',
            alias='Base',
            datatype='Text',
            indices=['Ordenado'],
            multivalued=False,
            required=True
        ))

        dt_last_up_orig = Field(**dict(
            name='dt_last_up_orig',
            description='Data e Hora no formato DD/MM/AAAA - HH:MM:SS '
                        'da última atualização do registro que originou o erro.',
            alias='Data de Atualização',
            datatype='DateTime',
            indices=['Ordenado', 'Textual'],
            multivalued=False,
            required=True
        ))

        id_doc_orig = Field(**dict(
            name='id_doc_orig',
            description='ID do documento que originou o erro.',
            alias='Documento',
            datatype='Integer',
            indices=['Ordenado'],
            multivalued=False,
            required=True
        ))

        error_msg = Field(**dict(
            name='error_msg',
            description='Mensagem de erro',
            alias='Mensagem',
            datatype='Text',
            indices=[],
            multivalued=False,
            required=True
        ))

        dt_error = Field(**dict(
            name='dt_error',
            description='Data e Hora no formato DD/MM/AAAA - HH:MM:SS do erro',
            alias='Data do erro',
            datatype='DateTime',
            indices=['Textual', 'Ordenado'],
            multivalued=False,
            required=True
        ))

        content_list = Content()
        content_list.append(nm_base)
        content_list.append(dt_last_up_orig)
        content_list.append(id_doc_orig)
        content_list.append(error_msg)
        content_list.append(dt_error)

        base_metadata = BaseMetadata(**dict(
            name='log_lbindex',
            description='LightBase - Log de erros do LBIndex',
            password='******',
            idx_exp=False,
            idx_exp_url='rest_url',
            idx_exp_time=300,
            file_ext=False,
            file_ext_time=300,
            color='#000000'
        ))

        lbbase = Base(
            metadata=base_metadata,
            content=content_list
        )

        return lbbase
예제 #40
0
    def lbbase(self):
        """
        LB Base do órgão
        """
        nome = Field(**dict(name='nome',
                            description='Nome do órgão',
                            alias='nome',
                            datatype='Text',
                            indices=['Textual', 'Unico'],
                            multivalued=False,
                            required=True))

        pretty_name = Field(**dict(name='pretty_name',
                                   description='Nome do órgão',
                                   alias='pretty_name',
                                   datatype='Text',
                                   indices=['Textual'],
                                   multivalued=False,
                                   required=True))

        sigla = Field(**dict(name='sigla',
                             alias='sigla',
                             description='Sigla do órgão',
                             datatype='Text',
                             indices=['Textual', 'Unico'],
                             multivalued=False,
                             required=True))

        gestor = Field(**dict(name='gestor',
                              alias='gestor',
                              description='Nome do gestor',
                              datatype='Text',
                              indices=['Textual'],
                              multivalued=False,
                              required=True))

        cargo = Field(**dict(name='cargo',
                             alias='cargo',
                             description='Cargo do gestor',
                             datatype='Text',
                             indices=['Textual'],
                             multivalued=False,
                             required=True))

        telefone = Field(**dict(name='telefone',
                                alias='telefone',
                                description='Telefone do órgão',
                                datatype='Text',
                                indices=['Textual'],
                                multivalued=False,
                                required=True))

        email = Field(**dict(name='email',
                             alias='email',
                             description='E-mail do órgão',
                             datatype='Text',
                             indices=['Textual', 'Unico'],
                             multivalued=False,
                             required=True))

        endereco = Field(**dict(name='endereco',
                                alias='endereco',
                                description='Endereço do orgao',
                                datatype='Text',
                                indices=['Textual'],
                                multivalued=False,
                                required=True))

        coleta = Field(**dict(name='coleta',
                              alias='coleta',
                              description='Intervalo de coleta',
                              datatype='Integer',
                              indices=[],
                              multivalued=False,
                              required=False))

        url = Field(**dict(name='url',
                           alias='url',
                           description='Url da base de dados',
                           datatype='Text',
                           indices=['Textual'],
                           multivalued=False,
                           required=False))

        siorg = Field(**dict(name='siorg',
                             alias='siorg',
                             description='Código do SIORG',
                             datatype='Text',
                             indices=['Textual', 'Unico'],
                             multivalued=False,
                             required=False))

        habilitar_bot = Field(**dict(name='habilitar_bot',
                                     alias='habilitar_bot',
                                     description='Habilitar Bot',
                                     datatype='Boolean',
                                     indices=[],
                                     multivalued=False,
                                     required=False))

        api_key = Field(**dict(name='api_key',
                               alias='api_key',
                               description='Chave de API',
                               datatype='Text',
                               indices=[],
                               multivalued=False,
                               required=True))

        base_metadata = BaseMetadata(name='orgaos', )

        content_list = Content()
        content_list.append(nome)
        content_list.append(pretty_name)
        content_list.append(sigla)
        content_list.append(gestor)
        content_list.append(cargo)
        content_list.append(telefone)
        content_list.append(email)
        content_list.append(endereco)
        content_list.append(coleta)
        content_list.append(url)
        content_list.append(habilitar_bot)
        content_list.append(api_key)
        content_list.append(siorg)

        lbbase = Base(metadata=base_metadata, content=content_list)

        return lbbase
예제 #41
0
    def lbbase(self):

        """
        COnfiguração da Coleta
        """

        nome_orgao = Field(**dict(
            name='nome_orgao',
            description='Nome do Órgão',
            alias='nome_orgao',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        nome_relatorio = Field(**dict(
            name='nome_relatorio',
            description='Nome do Relatório',
            alias='nome_relatorio',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        data_coleta = Field(**dict(
            name='data_coleta',
            description='Data da Coleta',
            alias='data_coleta',
            datatype='DateTime',
            indices=['Ordenado'],
            multivalued=False,
            required=True
        ))

        total_computadores = Field(**dict(
            name='total_computadores',
            description='Total de Computadores',
            alias='total_computadores',
            datatype='Integer',
            indices=['Ordenado'],
            multivalued=False,
            required=True
        ))

        nome_item = Field(**dict(
            name='nome_item',
            description='Nome do Item',
            alias='nome_item',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))

        quantidade_item = Field(**dict(
            name='quantidade_item',
            description='Quantidades total do item',
            alias='quantidade_item',
            datatype='Integer',
            indices=['Ordenado'],
            multivalued=False,
            required=True
        ))

        descricao_item = Field(**dict(
            name='descricao_item',
            description='Descrição',
            alias='descricao_item',
            datatype='Text',
            indices=['Textual'],
            multivalued=False,
            required=True
        ))


        """
        GROUP Sistema Operacional
        """
        ItensGroup_content = Content()
        ItensGroup_content.append(nome_item)
        ItensGroup_content.append(quantidade_item)
        ItensGroup_content.append(descricao_item)

        ItensGroup_metadata = GroupMetadata(
            name='ItensGroup',
            alias='ItensGroup',
            description='Grupo de Itens',
            multivalued=True
        )

        ItensGroup = Group(
            metadata=ItensGroup_metadata,
            content=ItensGroup_content
        )

        base_metadata = BaseMetadata(
            name='all_reports'
        )

        content_list = Content()
        content_list.append(nome_orgao)
        content_list.append(nome_relatorio)
        content_list.append(data_coleta)
        content_list.append(total_computadores)
        content_list.append(ItensGroup)

        lbbase = Base(
            metadata=base_metadata,
            content=content_list
        )

        return lbbase