예제 #1
0
파일: base.py 프로젝트: NCPP/NCPP
 def insert(self,session):
     container = db.Container(session,self)
     for idx,variable_name in enumerate(self.variables):
         clean_units = db.get_or_create(session,db.CleanUnits,**self.clean_units[idx])
         clean_variable = db.get_or_create(session,db.CleanVariable,**self.clean_variable[idx])
         rv = db.Field(self,container,variable_name,clean_units,clean_variable)
         session.add(rv)
     session.commit()
예제 #2
0
파일: base.py 프로젝트: NCPP/NCPP
 def insert(self,session):
     dc = db.get_or_create(session,db.DatasetCategory,**self.dataset_category)
     qq = session.query(db.Field).join(db.Container).join(db.Uri)
     uris = []
     variables = []
     for f in self.fields:
         uris += f().uri
         variables += f.variables
     qq = qq.filter(db.Uri.value.in_(uris))
     qq = qq.filter(db.Field.name.in_(variables))
     assert(qq.count() == len(self.fields))
     dp = db.DataPackage(field=qq.all(),name=self.name,description=self.description,dataset_category=dc)
     session.add(dp)
     session.commit()