Пример #1
0
 def addSentencesTrueByRulesDifferentially(cls, sentencesByForm, domainModel, reasoner):
     """ generated source for method addSentencesTrueByRulesDifferentially """
     model = domainModel
     constantForms = model.getConstantSentenceForms()
     # Find the part of the dependency graph dealing only with the constant forms.
     dependencySubgraph = Multimaps.filterKeys(model.getDependencyGraph(), Predicates.in_(constantForms))
     dependencySubgraph = Multimaps.filterValues(model.getDependencyGraph(), Predicates.in_(constantForms))
     dependencySubgraph = ImmutableMultimap.copyOf(dependencySubgraph)
     ordering = DependencyGraphs.toposortSafe(constantForms, dependencySubgraph)
     for stratum in ordering:
         #  One non-differential pass, collecting the changes
         for form in stratum:
             for rule in model.getRules(form):
                 if not reasoner.isSubsetOf(sentencesByForm, ruleResults):
                     sentencesByForm = reasoner.getUnion(sentencesByForm, ruleResults)
                     newlyTrueSentences = reasoner.getUnion(newlyTrueSentences, ruleResults)
         #  Now a lot of differential passes to deal with recursion efficiently
         while somethingChanged:
             somethingChanged = False
             for form in stratum:
                 for rule in model.getRules(form):
                     if not reasoner.isSubsetOf(sentencesByForm, ruleResults):
                         somethingChanged = True
                         newStuffInThisPass = reasoner.getUnion(newStuffInThisPass, ruleResults)
             sentencesByForm = reasoner.getUnion(sentencesByForm, newStuffInThisPass)
             newlyTrueSentences = newStuffInThisPass
Пример #2
0
def cleanup_default_tenants(context):
    """ Cleans up a previously created default tenants. """
    print "### Cleaning up tenants ###"
    admin = context.getAdministrationService()
    enterprises = admin.listEnterprises(Predicates.not(EnterprisePredicates.name("Abiquo")))
    for enterprise in enterprises:
        # This will remove the enterprise and all users (if none of them is a Cloud Admin)
        print "Removing enterprise %s and all users..." % enterprise.getName()
        enterprise.delete()
Пример #3
0
def cleanup_default_tenants(config, context):
    """ Cleans up a previously created default tenants """
    log.info("### Cleaning up tenants ###")
    admin = context.getAdministrationService()
    enterprises = admin.listEnterprises(
            Predicates.not(EnterprisePredicates.name("Abiquo")))
    for enterprise in enterprises:
        # This will remove the enterprise and all users
        # (if none of them is a Cloud Admin)
        log.info("Removing enterprise %s and all users..."  \
                % enterprise.getName())
        enterprise.delete()

    rolefilter = Predicates.not(Predicates.or(
        RolePredicates.name("CLOUD_ADMIN"),
        RolePredicates.name("ENTERPRISE_ADMIN"),
        RolePredicates.name("USER")))
    roles = admin.listRoles(rolefilter)
    # This will remove all non default roles
    for role in roles:
        log.info("Removing role %s..." % role.getName())
        role.delete()
Пример #4
0
 def createWithForwardChaining(cls, model):
     """ generated source for method createWithForwardChaining """
     reasoner = GdlChainingReasoner.create(model)
     sentencesByForm = reasoner.getConstantSentences()
     addSentencesTrueByRulesDifferentially(sentencesByForm, model, reasoner)
     return ImmutableConstantChecker.create(model, Multimaps.filterKeys(sentencesByForm.getSentences(), Predicates.in_(model.getConstantSentenceForms())))
Пример #5
0
 def getConstantSentenceForms(cls, sentenceForms, dependencyGraph):
     """ generated source for method getConstantSentenceForms """
     augmentedGraph = augmentGraphWithLanguageRules(dependencyGraph, sentenceForms)
     changingSentenceForms = DependencyGraphs.getMatchingAndDownstream(sentenceForms, augmentedGraph, Predicates.or_(SentenceForms.TRUE_PRED, SentenceForms.DOES_PRED))
     return ImmutableSet.copyOf(Sets.difference(sentenceForms, changingSentenceForms))