示例#1
0
 def getOrCreatePeriod3(self, instant, session):
     period = GenericDao().getOneResult(Period,
                                        and_(Period.instant == instant),
                                        session,
                                        raiseNoResultFound=False)
     if (period is None):
         period = Period()
         period.instant = instant
         period.type = "INST"
         Dao().addObject(objectToAdd=period, session=session, doFlush=True)
     return period
 def doImport2(self):
     efvList = []
     self.processCache = self.initProcessCache3(self.filename, self.session)
     conceptElementList = self.getListFromElement(
         [self.conceptName], self.processCache[Constant.DOCUMENT_INS],
         False)
     for conceptElement in conceptElementList:
         conceptValue = self.getValueFromElement(['#text'], conceptElement,
                                                 False)
         contextRef = self.getValueFromElement(['@contextRef'],
                                               conceptElement, False)
         entity = self.getElementFromElement(
             [contextRef], self.processCache[Constant.ENTITY_DICT], False)
         segment = self.getElementFromElement(Constant.XBRL_SEGMENT, entity,
                                              False)
         explicitMemberElement = self.getObjectFromElement(
             Constant.XBRL_EXPLICIT_MEMBER, segment)
         if (explicitMemberElement is None
                 or isinstance(explicitMemberElement, dict)):
             explicitMemberValue = self.getValueFromElement(
                 ['#text'], explicitMemberElement, False)
             concept = ConceptEngine().getOrCreateConcept(
                 "EntityCommonStockSharesOutstanding", self.session)
             entityFact = EntityFactDao().getEntityFact(
                 concept.OID, 2803, 99, self.session)
             efv = EntityFactValue()
             efv.entityFact = entityFact
             efv.fileData = self.fileData
             if conceptValue is None:
                 efv.value = 0
             else:
                 efv.value = conceptValue
             efv.period = self.processCache[
                 Constant.PERIOD_DICT][contextRef]
             if (explicitMemberValue is None):
                 efv.explicitMember = GenericDao().getOneResult(
                     ExplicitMember, (ExplicitMember.explicitMemberValue
                                      == 'NO_EXPLICIT_MEMBER'),
                     self.session,
                     raiseNoResultFound=True)
             else:
                 efv.explicitMember = GenericDao().getOneResult(
                     ExplicitMember, (ExplicitMember.explicitMemberValue
                                      == explicitMemberValue),
                     self.session,
                     raiseNoResultFound=False)
                 if (efv.explicitMember is None):
                     em = ExplicitMember(
                         explicitMemberValue=explicitMemberValue, order_=99)
                     Dao().addObject(objectToAdd=em, session=self.session)
                     efv.explicitMember = em
             efvList.append(efv)
     Dao().addObjectList(objectList=efvList, session=self.session)
     return efvList
示例#3
0
 def getOrCreatePeriod(self, periodType, endDate, session):
     period = GenericDao().getOneResult(Period,
                                        and_(Period.endDate == endDate,
                                             Period.startDate.is_(None)),
                                        session,
                                        raiseNoResultFound=False)
     if (period is None):
         period = Period()
         period.endDate = endDate
         period.type = periodType
         Dao().addObject(objectToAdd=period, session=session, doFlush=True)
     return period
 def getEntityFact(self, conceptOID, reportOID, order_, session):
     return GenericDao().getOneResult(
         EntityFact,
         and_(EntityFact.conceptOID == conceptOID,
              EntityFact.reportOID == reportOID,
              EntityFact.order_ == order_),
         session,
         raiseNoResultFound=False)
示例#5
0
 def getFact(self, concept, fileData, session):
     return GenericDao().getOneResult(Fact,
                                      and_(Fact.concept == concept,
                                           Fact.fileData == fileData),
                                      session,
                                      raiseNoResultFound=False)
 def getCustomConcept(self, fillStrategy, session):
     #"COPY_CALCULATE"
     return GenericDao().getAllResult(objectClazz = CustomConcept, condition = (CustomConcept.fillStrategy == fillStrategy), session = session)
 def __init__(self, filename, replace):
     AbstractImporter.__init__(self, errorKey=Constant.ERROR_KEY_COPY, filename=filename, replace=replace, previousStatus=ConstantStatus.FACT_STATUS, 
                               actualStatus=ConstantStatus.COPY_STATUS)
     self.customConceptList = GenericDao().getAllResult(objectClazz=CustomConcept, condition=(or_(CustomConcept.fillStrategy == "COPY_CALCULATE", CustomConcept.fillStrategy == "COPY")), session=self.session)
 def getFileData(filename, session=None):
     return GenericDao().getOneResult(FileData, and_(FileData.fileName == filename), session, raiseNoResultFound=False)
 def getQuarterPeriod(self, quarterPeriodOID, session=None):
     return GenericDao().getOneResult(objectClazz=QuarterPeriod, condition=(QuarterPeriod.OID==quarterPeriodOID), session=session, raiseNoResultFound=True)
 def doImport2(self):
     customConceptList = GenericDao().getAllResult(objectClazz = CustomConcept, condition = (CustomConcept.fillStrategy == "COPY_CALCULATE"), session = self.session)
     customConceptListFilled= CustomFactDao().getCustomConceptFilled(self.fileData.OID, self.session)
     self.customConceptListMissing =[x for x in customConceptList if not x.conceptName in customConceptListFilled]
     self.customConceptListResult = CustomFactEngine().calculateMissingQTDValues2(fileData = self.fileData, customConceptList = self.customConceptListMissing, session=self.session)
     return self.customConceptListResult
 def getExpressionList(self, session=None):
     return GenericDao().getAllResult(objectClazz=Expression,
                                      session=session)
 def getTicker(self, ticker, session):
     return GenericDao().getOneResult(Ticker,
                                      Ticker.ticker.__eq__(ticker),
                                      session,
                                      raiseNoResultFound=False)
 def getCompany2(self, CIK, session):
     return GenericDao().getOneResult(Company,
                                      Company.CIK.__eq__(CIK),
                                      session,
                                      raiseNoResultFound=False)