예제 #1
0
파일: TaskDAO.py 프로젝트: we45/cairis
    def convert_props(self, real_props=None, fake_props=None):
        new_props = []
        if real_props is not None:
            if len(real_props) > 0:
                for real_prop in real_props:
                    assert isinstance(real_prop, TaskEnvironmentProperties)
                    del real_prop.theCodes
                    ptList = []
                    for ptc in real_prop.personas():
                        ptList.append(
                            PersonaTaskCharacteristics(ptc[0], ptc[1], ptc[2],
                                                       ptc[3], ptc[4]))
                    real_prop.thePersonas = ptList
                    gcaList = []
                    for gca in real_prop.concernAssociations():
                        gcaList.append(
                            ConcernAssociationModel(gca[0], gca[1], gca[2],
                                                    gca[3], gca[4]))
                    real_prop.theConcernAssociations = gcaList
                    new_props.append(real_prop)
        elif fake_props is not None:
            if len(fake_props) > 0:
                for fake_prop in fake_props:
                    check_required_keys(
                        fake_prop, TaskEnvironmentPropertiesModel.required)
                    ptList = []
                    for ptc in fake_prop['thePersonas']:
                        ptList.append([
                            ptc['thePersona'], ptc['theDuration'],
                            ptc['theFrequency'], ptc['theDemands'],
                            ptc['theGoalConflict']
                        ])
                    fake_prop['thePersonas'] = ptList
                    gcaList = []
                    for gca in fake_prop['theConcernAssociations']:
                        gcaList.append([
                            gca['theSource'], gca['theSourceNry'],
                            gca['theLinkVerb'], gca['theTarget'],
                            gca['theTargetNry']
                        ])
                    fake_prop['theConcernAssociations'] = gcaList

                    new_prop = TaskEnvironmentProperties(
                        environmentName=fake_prop['theEnvironmentName'],
                        deps=fake_prop['theDependencies'],
                        personas=fake_prop['thePersonas'],
                        assets=fake_prop['theAssets'],
                        concs=fake_prop['theConcernAssociations'],
                        narrative=fake_prop['theNarrative'],
                        consequences=fake_prop['theConsequences'],
                        benefits=fake_prop['theBenefits'],
                        tCodes=[])
                    new_props.append(new_prop)
        else:
            self.close()
            raise MissingParameterHTTPError(
                param_names=['real_props', 'fake_props'])
        return new_props
예제 #2
0
  def convert_properties(self, real_props=None, fake_props=None):
    new_props = []
    if real_props is not None:
      for real_prop in real_props:
        assert isinstance(real_prop, GoalEnvironmentProperties)
        del real_prop.theLabel
        new_concern_assocs = []
        for concern_assoc in real_prop.theConcernAssociations:
          new_concern_assocs.append(ConcernAssociationModel(concern_assoc[0],concern_assoc[1],concern_assoc[2],concern_assoc[3],concern_assoc[4]))

        new_goal_refinements = []
        for gr in real_prop.theGoalRefinements:
          new_goal_refinements.append(RefinementModel(gr[0],gr[1],gr[2],gr[3],gr[4]))

        new_subgoal_refinements = []
        for sgr in real_prop.theSubGoalRefinements:
          new_subgoal_refinements.append(RefinementModel(sgr[0],sgr[1],sgr[2],sgr[3],sgr[4]))

        real_prop.theConcernAssociations = new_concern_assocs
        real_prop.theGoalRefinements = new_goal_refinements
        real_prop.theSubGoalRefinements = new_subgoal_refinements
        new_props.append(real_prop)
    elif fake_props is not None:
      for fake_prop in fake_props:
        check_required_keys(fake_prop, GoalEnvironmentPropertiesModel.required)

        new_concern_assocs = []
        for concern_assoc in fake_prop['theConcernAssociations']:
          new_concern_assocs.append([concern_assoc['theSource'],concern_assoc['theSourceNry'],concern_assoc['theLinkVerb'],concern_assoc['theTarget'],concern_assoc['theTargetNry']])

        new_goal_refinements = []
        for gr in fake_prop['theGoalRefinements']:
          new_goal_refinements.append((gr['theEndName'],gr['theEndType'],gr['theRefType'],gr['isAlternate'],gr['theRationale']))

        new_subgoal_refinements = []
        for sgr in fake_prop['theSubGoalRefinements']:
          new_subgoal_refinements.append((sgr['theEndName'],sgr['theEndType'],sgr['theRefType'],sgr['isAlternate'],sgr['theRationale']))

        new_prop = GoalEnvironmentProperties(
          environmentName=fake_prop['theEnvironmentName'],
          lbl='',
          definition=fake_prop['theDefinition'],
          category=fake_prop['theCategory'],
          priority=fake_prop['thePriority'],
          fitCriterion=fake_prop['theFitCriterion'],
          issue=fake_prop['theIssue'],
          goalRefinements=new_goal_refinements,
          subGoalRefinements=new_subgoal_refinements,
          concs=fake_prop['theConcerns'],
          cas=new_concern_assocs)
        new_props.append(new_prop)
    else:
      self.close()
      raise MissingParameterHTTPError(param_names=['real_props', 'fake_props'])

    return new_props
예제 #3
0
  def setUp(self):
    # region Class fields
    self.logger = logging.getLogger(__name__)

    self.existing_task_name = 'Upload data'
    self.existing_environment_name = 'Psychosis'
    self.existing_direct_flag=False
    self.existing_personas=[PersonaTaskCharacteristics('Claire','Medium','Medium','Low','Medium')]
    self.existing_assets=['Clinical data','Portal','Client workstation']
    self.existing_concern_associations=[ConcernAssociationModel('Portal','1','connects','Client workstation','1')]
    self.existing_narrative='Claire wants to analyse a data set, in relation to other data sets on NeuroGrid.  She anonymises her data to the extent that as much personalised data is removed as possible, but not to the extent that her analysis software will fail.  She then uploads this data, tagging this as available only to members of her exemplar.'
    self.existing_consequences='None'
    self.existing_benefits='None'
    self.existing_codes=[]

    task_class = Task.__module__+'.'+Task.__name__