Ejemplo n.º 1
0
        self._permissionSet = PermissionSet()
        for rule in self.rules:
            for s in rule.subjects:
                for r in rule.resources:
                    for a in rule.actions:
                        p = Permission(s, a, r, rule)
                        self._permissionSet.permissions.add(p)
                        rule.permissions.append(p)

    def __str__(self):
        return '\n'.join([str(r) for r in self.rules])


METAMODEL = Metamodel(
    id='pe',  # other model could be registered
    label='permission',
    extension='.pes',
    modelClass=UCPermissionModel)
MetamodelDependency(
    sourceId='pe',
    targetId='gl',
    optional=True,
    multiple=True,
)
MetamodelDependency(
    sourceId='pe',
    targetId='us',
    optional=False,
    multiple=False,
)
MetamodelDependency(
Ejemplo n.º 2
0
        Association.__init__(self,
                             name=name,
                             model=model,
                             kind='associationclass',
                             lineNo=lineNo,
                             docComment=docComment,
                             eolComment=eolComment)
        # But register the association class apart and only once, to avoid
        # confusion and the duplicate in the associations and classes lists
        del self.model.classNamed[name]
        del self.model.associationNamed[name]
        self.model.associationClassNamed[name] = self


METAMODEL = Metamodel(id='cl',
                      label='class',
                      extension='.cls',
                      modelClass=ClassModel)

MetamodelDependency(
    sourceId='cl',
    targetId='gl',
    optional=True,
    multiple=True,
)

# http://pythex.org
# TODO
#   (self\.[\w.]+ |\w +::\w + |\$\w +\.\w + [\w.] * | \$\w +: \w +)
# model

# class ExpressionPath(object):
Ejemplo n.º 3
0
            raise NotImplementedError()
        return '%s: %s' % (
            _,
            SAR.__str__(self))


class AccessModel(Model):

    def __init__(self, permissionSet=None):
        super(AccessModel, self).__init__()
        self.accessSet=AccessSet(permissionSet=permissionSet) #type:AccessSet


METAMODEL = Metamodel(
    id='ac',
    label='access',
    extension='.acs',
    modelClass=AccessModel
)
MetamodelDependency(
    sourceId='ac',
    targetId='gl',
    optional=True,
    multiple=True,
)
MetamodelDependency(
    sourceId='ac',
    targetId='us',
    optional=False,
    multiple=False,
)
MetamodelDependency(
Ejemplo n.º 4
0
            self.actors.append(actor)

    # def check(self):
    #     if not Symbol.is_CamlCase(self.name):
    #         ModelElementIssue(
    #             modelElement=self,
    #             level=Levels.Warning,
    #             message=(
    #                 '"%s" should be in CamlCase.'
    #                 % self.name))
    #     if len(self.actors)==0:
    #         ModelElementIssue(
    #             modelElement=self,
    #             level=Levels.Warning,
    #             message='No actor performs "%s".' %
    #                     self.name
    #         )


METAMODEL = Metamodel(id='us',
                      label='usecase',
                      extension='.uss',
                      modelClass=UsecaseModel,
                      modelKinds=('', 'preliminary', 'detailled'))
MetamodelDependency(
    sourceId='us',
    targetId='gl',
    optional=True,
    multiple=True,
)
Ejemplo n.º 5
0
    def __init__(self, domain, mainTerm, alternativeTerms=(), lineNo=None):
        super(Entry, self).__init__(model=domain.glossaryModel,
                                    name=None,
                                    lineNo=lineNo)
        # TODO: check, unique main/alternative(?) term
        self.domain = domain
        #type: Domain

        self.domain.entryNamed[mainTerm] = self

        self.mainTerm = mainTerm
        #type: Text

        self.alternativeTerms = list(alternativeTerms)
        #type: List[Text]

        self.occurrences = []
        #type: List['Occurrence']


METAMODEL = Metamodel(id='gl',
                      label='glossary',
                      extension='.gls',
                      modelClass=GlossaryModel)
# MetamodelDependency(
#     sourceId='gl',
#     targetId='gl',
#     optional=True,
#     multiple=True,
# )
Ejemplo n.º 6
0
        ScenarioTopLevelElement.__init__(self,
                                         model=model,
                                         name=name,
                                         code=code,
                                         lineNo=lineNo,
                                         docComment=docComment,
                                         eolComment=eolComment)

        self.system = system
        # type: System
        self.scenario.systemInstance = self


METAMODEL = Metamodel(id='sc',
                      label='scenario',
                      extension='.scs',
                      modelClass=ScenarioModel,
                      modelKinds=('', 'informal', 'preliminary', 'detailed'))
MetamodelDependency(
    sourceId='sc',
    targetId='gl',
    optional=True,
    multiple=True,
)
MetamodelDependency(
    sourceId='sc',
    targetId='cl',
    optional=True,
    multiple=False,
)
MetamodelDependency(
Ejemplo n.º 7
0
            state=state,
            classifier=classifier,
            objects=objects,
        )
        # remove it from the list of objects just changed
        state.links = [l for l in state.links if l!=self]

        state.linkObjects.append(self)

    def delete(self):
        #TODO:  implement delete operation on link objects
        raise NotImplementedError('Delete operation on link object is not implemented')

METAMODEL = Metamodel(
    id='ob',
    label='object',
    extension='.obs',
    modelClass=ObjectModel
)
MetamodelDependency(
    sourceId='ob',
    targetId='gl',
    optional=True,
    multiple=True,
)
MetamodelDependency(
    sourceId='ob',
    targetId='ob',
    optional=True,
    multiple=True,
)
MetamodelDependency(
Ejemplo n.º 8
0
                b = os.path.basename(filename)
                raise ValueError('No metamodel available for %s' % b)
            try:
                factory = mm.sourceClass
            except NotImplementedError:
                raise ValueError('No parser available for %s' % mm.name)
            else:
                return factory(filename)

    @classmethod
    def displayModel(cls, model, config=None):
        printer = model.metamodel.modelPrinterClass(theModel=model,
                                                    config=config)
        printer.display()

    @classmethod
    def displaySource(cls, source, config=None):
        printer = source.metamodel.sourcePrinterClass(theSource=source,
                                                      config=config)
        printer.display()

    @classmethod
    def displayModelDiagram(cls, model, config=None):
        raise NotImplementedError()


METAMODEL = Metamodel(id='mg',
                      label='megamodel',
                      extension='.mgs',
                      modelClass=Megamodel)