Example #1
0
def popup_patternRationale():
    patternUri = request.form.get('pattern', '')
    newWindowPath = request.form.get('newWindowPath', '')

    structure = explanationGenerator.getRationaleOfArchitecture(patternUri)

    allEntities = structure.entities
    side_bar_diagram_file_paths = {
        diagram: 'static/images/' +
        explanationHelper.diagramUriToFileName(diagram) + '.png'
        for entity in allEntities for diagram in set(entity.diagrams)
    }

    explanation = {}
    explanation['popup_pattern_rationale'] = {
        'description':
        explanationTemplates.generateRationaleSummary(patternUri, structure),
        'newWindowPath':
        newWindowPath
    }

    return render_template(
        'popupInteractiveDiagram.html',
        side_bar_diagram_file_paths=side_bar_diagram_file_paths,
        explanations=explanation,
        newWindowPath=newWindowPath)
Example #2
0
def getManualExplanation():
    types = request.form.getlist('types[]')
    relations = request.form.getlist('relations[]')

    parsedTypes = [json.loads(entityType) for entityType in types]
    parsedRelations = [json.loads(relation) for relation in relations]

    if (parsedTypes):
        structure = explanationGenerator.getManualExplanation(
            parsedTypes, parsedRelations)
        explanation = explanationTemplates.generateGeneralManualExplanation(
            structure)
        sideBardiagram_file_paths = {
            diagram: 'static/images/' +
            explanationHelper.diagramUriToFileName(diagram) + '.png'
            for entity in structure.entities
            for diagram in set(entity.diagrams)
        }

        return render_template(
            'childtemplate.html',
            diagram_path='static/ClusteringGraph.js',
            side_bar_diagram_file_paths=sideBardiagram_file_paths,
            entityData={
                'overview': {
                    'tab_id': 'overview_view_tab',
                    'tab_name': 'Overview',
                    'entity_structure': json.dumps(structure.toDict()),
                    'explanation': explanation
                }
            })
    return ''
Example #3
0
def q1(feature):
    fileName = 'q1_' + feature
    if os.path.isfile('static\\saved_data\\' + fileName + '.pkl'):
        data = loadExplanation(fileName)
        structure = data['structure']
        explanation = data['explanation']
        sideBardiagram_file_paths = data['diagram_paths']
    else:
        structure = explanationGenerator.getFeatureRole(baseUri + feature)
        explanation = explanationTemplates.generateFeatureRoleSummary(
            baseUri + feature, structure)
        sideBardiagram_file_paths = {
            diagram: 'static/images/' +
            explanationHelper.diagramUriToFileName(diagram) + '.png'
            for entity in structure.entities
            for diagram in set(entity.diagrams)
        }
        saveExplanation(fileName, structure, explanation,
                        sideBardiagram_file_paths)

    return render_template(
        'childtemplate.html',
        diagram_path='static/ClusteringGraph.js',
        side_bar_diagram_file_paths=sideBardiagram_file_paths,
        entityData={
            'functional': {
                'tab_id': 'feature_role_tab',
                'tab_name': 'Feature role',
                'entity_structure': json.dumps(structure.toDict()),
                'explanation': explanation,
                'background': '#fff6f4'
            }
        })
Example #4
0
def popup_diagram():
    figureUriList = request.form.getlist('figure[]')
    explanation = {}

    for figureUri in figureUriList:
        explanation[explanationHelper.diagramUriToFileName(figureUri)] = {
            'diagramFilePath':
            '/static/images/' +
            explanationHelper.diagramUriToFileName(figureUri) + '.png',
            'description':
            explanationTemplates.generatePopupFigureDescription(
                figureUri).toDict(),
            'newWindowPath':
            '/static/something.html'
        }

    return render_template('popupImageDiagram.html', explanations=explanation)
    def generatePopupFigureDescription(self, figureUri):
        figureEntity = ontologyStructureModel.Entity(figureUri)

        template = explanationHelper.openText(
            'static/explanationTemplates/FigureSummary.txt')

        relatedEntityUris = [
            ontologyStructureModel.Entity(entity[1])
            for entity in self.informationRetriever.getRelations(
                figureUri, self.baseUri + 'models')
        ]
        summary = template.format(
            classes=self.classesToText(relatedEntityUris))
        question = {'sub': 'View diagrams', 'orginial': ''}

        figureid = 'popup_' + explanationHelper.diagramUriToFileName(
            explanationHelper.getNameFromUri(figureUri))
        figuretitle = explanationHelper.getNameOfEntity(figureEntity)
        figureSummary = ''

        entityid = 'popup_entity_overview_' + explanationHelper.diagramUriToFileName(
            explanationHelper.getNameFromUri(figureUri))
        entitySummary = ''

        relatedEntities = relatedEntityUris
        figureSection = sectionModel.Section(
            figureid,
            figuretitle,
            figureSummary,
            priority=5,
            sectionTextContent=[
                (explanationHelper.getNameFromUri(content[0]), content[1])
                for content in figureEntity.dataTypeProperties
            ])
        entitySection = self.createSection(relatedEntities, entityid,
                                           'Entities related to diagram',
                                           entitySummary)

        template = sectionModel.Template(question, summary)
        template.addSection(figureSection.toDict())
        template.addSection(entitySection.toDict())

        return template
Example #6
0
def popup_featureBehavior():
    featureUri = request.form.get('feature', '')
    newWindowPath = request.form.get('newWindowPath', '')

    funcStructure = explanationGenerator.getFunctionalBehaviorOfFeature(
        featureUri)
    logStructure = explanationGenerator.getLogicalBehaviorOfFeature(featureUri)
    devStructure = explanationGenerator.getDevelopmentBehaviorOfFeature(
        featureUri)
    uiStructure = explanationGenerator.getUIBehaviorOfFeature(featureUri)

    allEntities = funcStructure.entities + logStructure.entities + devStructure.entities + uiStructure.entities
    side_bar_diagram_file_paths = {
        diagram: 'static/images/' +
        explanationHelper.diagramUriToFileName(diagram) + '.png'
        for entity in allEntities for diagram in set(entity.diagrams)
    }

    explanation = {}

    explanation['popup_func_feature_behavior'] = {
        'description':
        explanationTemplates.generateBehaviorSummary(featureUri, funcStructure,
                                                     'functional'),
        'newWindowPath':
        newWindowPath
    }
    explanation['popup_log_feature_behavior'] = {
        'description':
        explanationTemplates.generateBehaviorSummary(featureUri, logStructure,
                                                     'logical'),
        'newWindowPath':
        newWindowPath
    }
    explanation['popup_dev_feature_behavior'] = {
        'description':
        explanationTemplates.generateBehaviorSummary(featureUri, devStructure,
                                                     'development'),
        'newWindowPath':
        newWindowPath
    }
    explanation['popup_ui_feature_behavior'] = {
        'description':
        explanationTemplates.generateBehaviorSummary(featureUri, uiStructure,
                                                     'ui'),
        'newWindowPath':
        newWindowPath
    }

    return render_template(
        'popupInteractiveDiagram.html',
        side_bar_diagram_file_paths=side_bar_diagram_file_paths,
        explanations=explanation,
        newWindowPath=newWindowPath)
Example #7
0
def popup_featureImplementation():
    featureUri = request.form.get('feature', '')
    newWindowPath = request.form.get('newWindowPath', '')

    overviewStructure = explanationGenerator.getOverviewFeatureToImplementationMap(
        featureUri)
    overviewExplanation = explanationTemplates.generateOverviewFeatureImplementationSummary(
        featureUri, overviewStructure)

    detailedStructure = explanationGenerator.getDetailedFeatureToImplementationMap(
        featureUri)
    detailedExplanation = explanationTemplates.generateDetailedFeatureImplementationSummary(
        featureUri, detailedStructure)

    implementationEntityUris = [
        implementation.uri for implementation in list(
            filter(lambda x: baseUri + 'ImplementationClass' in x.supertypes,
                   detailedStructure.entities))
    ]

    patternStructure = explanationGenerator.getImplementationToArchitecturalPatternMap(
        implementationEntityUris)
    patternExplanation = explanationTemplates.generatePatternFeatureImplementationSummary(
        featureUri, patternStructure)

    allEntities = overviewStructure.entities + detailedStructure.entities + patternStructure.entities
    side_bar_diagram_file_paths = {
        diagram: 'static/images/' +
        explanationHelper.diagramUriToFileName(diagram) + '.png'
        for entity in allEntities for diagram in set(entity.diagrams)
    }

    explanation = {}

    explanation['popup_overview_feature_implementation'] = {
        'description': overviewExplanation,
        'newWindowPath': newWindowPath
    }
    explanation['popup_detailed_feature_implementation'] = {
        'description': detailedExplanation,
        'newWindowPath': newWindowPath
    }
    explanation['popup_pattern_implementation'] = {
        'description': patternExplanation,
        'newWindowPath': newWindowPath
    }

    return render_template(
        'popupInteractiveDiagram.html',
        side_bar_diagram_file_paths=side_bar_diagram_file_paths,
        explanations=explanation,
        newWindowPath=newWindowPath)
Example #8
0
def popup_patternImplementation():
    patternUri = request.form.get('pattern', '')
    newWindowPath = request.form.get('newWindowPath', '')
    pattern = ontologyStructureModel.Entity(patternUri)

    overviewStructure = explanationGenerator.getOverviewPatternArchitecture(
        patternUri)
    physicalStructure = explanationGenerator.getFullPhyPatternArchitecture(
        patternUri)
    developmentStructure = explanationGenerator.getFullDevPatternArchitecture(
        patternUri)

    allEntities = overviewStructure.entities + physicalStructure.entities + developmentStructure.entities
    side_bar_diagram_file_paths = {
        diagram: 'static/images/' +
        explanationHelper.diagramUriToFileName(diagram) + '.png'
        for entity in allEntities for diagram in set(entity.diagrams)
    }

    explanation = {}
    explanation['popup_overview_pattern'] = {
        'description':
        explanationTemplates.generateSystemPatternsOverviewSummary(
            overviewStructure, pattern),
        'newWindowPath':
        newWindowPath
    }
    explanation['popup_physical_pattern'] = {
        'description':
        explanationTemplates.generateSpecificSystemPatternsDetailedSummary(
            physicalStructure, pattern),
        'newWindowPath':
        newWindowPath
    }
    explanation['popup_development_pattern'] = {
        'description':
        explanationTemplates.generateSpecificSystemPatternsDetailedSummary(
            developmentStructure, pattern),
        'newWindowPath':
        newWindowPath
    }

    return render_template(
        'popupInteractiveDiagram.html',
        side_bar_diagram_file_paths=side_bar_diagram_file_paths,
        explanations=explanation,
        newWindowPath=newWindowPath)
Example #9
0
def q4(architecturalPattern):
    fileName = 'q4_' + architecturalPattern
    if os.path.isfile('static\\saved_data\\' + fileName + '.pkl'):
        data = loadExplanation(fileName)
        architecturalStructure = data['structure']
        pattern_explanation = data['explanation']
        sideBardiagram_file_paths = data['diagram_paths']
    else:
        architecturalStructure = explanationGenerator.getRationaleOfArchitecture(
            baseUri + architecturalPattern)
        pattern_explanation = explanationTemplates.generateRationaleSummary(
            baseUri + architecturalPattern, architecturalStructure)
        sideBardiagram_file_paths = {
            diagram: 'static/images/' +
            explanationHelper.diagramUriToFileName(diagram) + '.png'
            for entity in architecturalStructure.entities
            for diagram in set(entity.diagrams)
        }

        saveExplanation(fileName, architecturalStructure, pattern_explanation,
                        sideBardiagram_file_paths)

    return render_template(
        'childtemplate.html',
        diagram_path='static/ClusteringGraph.js',
        side_bar_diagram_file_paths=sideBardiagram_file_paths,
        entityData={
            'rationale': {
                'tab_id': 'rationale_view_tab',
                'tab_name': 'Rationale of architectural pattern',
                'entity_structure':
                json.dumps(architecturalStructure.toDict()),
                'explanation': pattern_explanation,
                'background': '#fff6f4'
            }
        })
Example #10
0
def q2(feature):
    fileName = 'q2_' + feature
    if os.path.isfile('static\\saved_data\\' + fileName + '.pkl'):
        data = loadExplanation(fileName)

        structure = data['structure']
        overviewStructure = structure['overview']
        detailedStructure = structure['detailed']
        patternStructure = structure['pattern']

        explanation = data['explanation']
        overviewExplanation = explanation['overview']
        detailedExplanation = explanation['detailed']
        patternExplanation = explanation['pattern']

        sideBardiagram_file_paths = data['diagram_paths']
    else:
        structure = {}
        explanation = {}

        overviewStructure = structure[
            'overview'] = explanationGenerator.getOverviewFeatureToImplementationMap(
                baseUri + feature)
        overviewExplanation = explanation[
            'overview'] = explanationTemplates.generateOverviewFeatureImplementationSummary(
                baseUri + feature, overviewStructure)

        detailedStructure = structure[
            'detailed'] = explanationGenerator.getDetailedFeatureToImplementationMap(
                baseUri + feature)
        detailedExplanation = explanation[
            'detailed'] = explanationTemplates.generateDetailedFeatureImplementationSummary(
                baseUri + feature, detailedStructure)
        implementationEntityUris = [
            implementation.uri for implementation in list(
                filter(
                    lambda x: baseUri + 'ImplementationClass' in x.supertypes,
                    detailedStructure.entities))
        ]

        patternStructure = structure[
            'pattern'] = explanationGenerator.getImplementationToArchitecturalPatternMap(
                implementationEntityUris)
        patternExplanation = explanation[
            'pattern'] = explanationTemplates.generatePatternFeatureImplementationSummary(
                baseUri + feature, patternStructure)

        allEntities = []
        allEntities += detailedStructure.entities
        allEntities += overviewStructure.entities
        allEntities += patternStructure.entities

        sideBardiagram_file_paths = {
            diagram: 'static/images/' +
            explanationHelper.diagramUriToFileName(diagram) + '.png'
            for entity in allEntities for diagram in set(entity.diagrams)
        }

        saveExplanation(fileName, structure, explanation,
                        sideBardiagram_file_paths)

    return render_template(
        'childtemplate.html',
        diagram_path='static/ClusteringGraph.js',
        side_bar_diagram_file_paths=sideBardiagram_file_paths,
        entityData={
            'overview': {
                'tab_id': 'overview_view_tab',
                'tab_name': 'Overview',
                'entity_structure': json.dumps(overviewStructure.toDict()),
                'explanation': overviewExplanation
            },
            'logical': {
                'tab_id': 'logical_view_tab',
                'tab_name': 'Detailed view',
                'entity_structure': json.dumps(detailedStructure.toDict()),
                'explanation': detailedExplanation
            },
            'pattern': {
                'tab_id': 'pattern_view_tab',
                'tab_name': 'Pattern view',
                'entity_structure': json.dumps(patternStructure.toDict()),
                'explanation': patternExplanation
            }
        })
Example #11
0
def q7(architecturalPattern):
    fileName = 'q7_' + architecturalPattern
    if os.path.isfile('static\\saved_data\\' + fileName + '.pkl'):
        data = loadExplanation(fileName)
        structure = data['structure']
        overviewStructure = structure['overview']
        devStructure = structure['development']
        phyStructure = structure['physical']

        explanation = data['explanation']
        overviewExplanation = explanation['overview']
        devExplanation = explanation['development']
        phyExplanation = explanation['physical']

        sideBardiagram_file_paths = data['diagram_paths']
    else:
        structure = {}
        patternEntity = ontologyStructureModel.Entity(baseUri +
                                                      architecturalPattern)
        overviewStructure = structure[
            'overview'] = explanationGenerator.getOverviewPatternArchitecture(
                baseUri + architecturalPattern)
        devStructure = structure[
            'development'] = explanationGenerator.getFullDevPatternArchitecture(
                baseUri + architecturalPattern)
        phyStructure = structure[
            'physical'] = explanationGenerator.getFullPhyPatternArchitecture(
                baseUri + architecturalPattern)

        explanation = {}
        overviewExplanation = explanation[
            'overview'] = explanationTemplates.generateSystemPatternsOverviewSummary(
                overviewStructure, patternEntity)
        devExplanation = explanation[
            'development'] = explanationTemplates.generateSpecificSystemPatternsDetailedSummary(
                devStructure, patternEntity)
        phyExplanation = explanation[
            'physical'] = explanationTemplates.generateSpecificSystemPatternsDetailedSummary(
                phyStructure, patternEntity)

        allEntities = list(
            set(phyStructure.entities + devStructure.entities +
                overviewStructure.entities))
        sideBardiagram_file_paths = {
            diagram: 'static/images/' +
            explanationHelper.diagramUriToFileName(diagram) + '.png'
            for entity in allEntities for diagram in set(entity.diagrams)
        }

        saveExplanation(fileName, structure, explanation,
                        sideBardiagram_file_paths)

    return render_template(
        'childtemplate.html',
        diagram_path='static/ClusteringGraph.js',
        side_bar_diagram_file_paths=sideBardiagram_file_paths,
        entityData={
            'overview': {
                'tab_id': 'overview_view_tab',
                'tab_name': 'Overview',
                'entity_structure': json.dumps(overviewStructure.toDict()),
                'explanation': overviewExplanation
            },
            'physical': {
                'tab_id': 'physical_view_tab',
                'tab_name': 'Physical view',
                'entity_structure': json.dumps(phyStructure.toDict()),
                'explanation': phyExplanation
            },
            'development': {
                'tab_id': 'development_view_tab',
                'tab_name': 'Development view',
                'entity_structure': json.dumps(devStructure.toDict()),
                'explanation': devExplanation
            },
        })
Example #12
0
def q3(feature):

    fileName = 'q3_' + feature
    if os.path.isfile('static\\saved_data\\' + fileName + '.pkl'):
        data = loadExplanation(fileName)
        structure = data['structure']
        funcBehaviorStructure = structure['functional']
        devBehaviorStructure = structure['development']
        logBehaviorStructure = structure['logical']
        UIBehaviorStructure = structure['ui']

        explanation = data['explanation']
        func_explanation = explanation['functional']
        development_explanation = explanation['development']
        logical_explanation = explanation['logical']
        ui_explanation = explanation['ui']

        sideBardiagram_file_paths = data['diagram_paths']
    else:
        structure = {}
        funcBehaviorStructure = structure[
            'functional'] = explanationGenerator.getFunctionalBehaviorOfFeature(
                baseUri + feature)
        devBehaviorStructure = structure[
            'development'] = explanationGenerator.getDevelopmentBehaviorOfFeature(
                baseUri + feature)
        logBehaviorStructure = structure[
            'logical'] = explanationGenerator.getLogicalBehaviorOfFeature(
                baseUri + feature)
        UIBehaviorStructure = structure[
            'ui'] = explanationGenerator.getUIBehaviorOfFeature(baseUri +
                                                                feature)

        explanation = {}
        func_explanation = explanation[
            'functional'] = explanationTemplates.generateFunctionalBehaviorSummary(
                baseUri + feature, funcBehaviorStructure)
        ui_explanation = explanation[
            'ui'] = explanationTemplates.generateBehaviorSummary(
                baseUri + feature, UIBehaviorStructure, 'ui')
        development_explanation = explanation[
            'development'] = explanationTemplates.generateBehaviorSummary(
                baseUri + feature, devBehaviorStructure, 'development')
        logical_explanation = explanation[
            'logical'] = explanationTemplates.generateBehaviorSummary(
                baseUri + feature, logBehaviorStructure, 'logical')

        allEntities = funcBehaviorStructure.entities + devBehaviorStructure.entities + logBehaviorStructure.entities + UIBehaviorStructure.entities
        sideBardiagram_file_paths = {
            diagram: 'static/images/' +
            explanationHelper.diagramUriToFileName(diagram) + '.png'
            for entity in allEntities for diagram in set(entity.diagrams)
        }
        saveExplanation(fileName, structure, explanation,
                        sideBardiagram_file_paths)

    return render_template(
        'childtemplate.html',
        diagram_path='static/ClusteringGraph.js',
        side_bar_diagram_file_paths=sideBardiagram_file_paths,
        entityData={
            'functional': {
                'tab_id': 'functional_view_tab',
                'tab_name': 'Functional viewpoint',
                'entity_structure': json.dumps(funcBehaviorStructure.toDict()),
                'explanation': func_explanation
            },
            'logical': {
                'tab_id': 'logical_view_tab',
                'tab_name': 'Logical viewpoint',
                'entity_structure': json.dumps(logBehaviorStructure.toDict()),
                'explanation': logical_explanation
            },
            'development': {
                'tab_id': 'development_view_tab',
                'tab_name': 'Development viewpoint',
                'entity_structure': json.dumps(devBehaviorStructure.toDict()),
                'explanation': development_explanation
            },
            'ui': {
                'tab_id': 'ui_view_tab',
                'tab_name': 'UI viewpoint',
                'entity_structure': json.dumps(UIBehaviorStructure.toDict()),
                'explanation': ui_explanation
            }
        })