コード例 #1
0
ファイル: CModelMIRIAMInfo.cpp プロジェクト: jonasfoe/COPASI
void CMIRIAMInfo::load(const std::string& key)
{
  pdelete(mpRDFGraph);

  mKey = key;
  CCopasiObject * pCopasiObject = dynamic_cast< CCopasiObject * >(CCopasiRootContainer::getKeyFactory()->get(mKey));

  if (pCopasiObject != NULL)
    {
      const std::string * pMiriamAnnotation = NULL;

      CAnnotation * pAnnotation = CAnnotation::castObject(pCopasiObject);

      if (pAnnotation != NULL)
        {
          pMiriamAnnotation = &pAnnotation->getMiriamAnnotation();
        }

      if (pMiriamAnnotation && *pMiriamAnnotation != "")
        mpRDFGraph = CRDFParser::graphFromXml(*pMiriamAnnotation);
    }

  if (mpRDFGraph == NULL)
    mpRDFGraph = new CRDFGraph;

  // We make sure that we always have an about node.

  if (pCopasiObject != NULL)
    mTriplet.pObject = mpRDFGraph->createAboutNode(pCopasiObject->getKey());
  else
    mTriplet.pObject = mpRDFGraph->createAboutNode("");

  // Load the created date if set;
  CRDFPredicate::Path Path = mTriplet.pObject->getPath();
  std::set< CRDFTriplet > Triples =
    mTriplet.pObject->getDescendantsWithPredicate(CRDFPredicate::dcterms_created);

  if (Triples.size() > 0)
    mCreated = *Triples.begin();
  else
    mCreated = CRDFTriplet(); // This is an invalid triplet, i.e., !mCreated is true.

  loadCreators();
  loadReferences();
  loadModifications();
  loadBiologicalDescriptions();

  return;
}
コード例 #2
0
ファイル: CQMiriamWidget.cpp プロジェクト: PriKalra/COPASI
bool CQMiriamWidget::enterProtected()
{
  if (mKey == "")
    return false;

  CCopasiMessage::clearDeque();

  if (mKeyToCopy != "")
    {
      CAnnotation * pAnnotation = CAnnotation::castObject(dynamic_cast< CCopasiObject * >(CCopasiRootContainer::getKeyFactory()->get(mKeyToCopy)));

      std::string pMiriamAnnotation = pAnnotation->getMiriamAnnotation();

      pAnnotation = CAnnotation::castObject(mpObject);

      pAnnotation->setMiriamAnnotation(pMiriamAnnotation, mKey, mKeyToCopy);

      mKeyToCopy = "";
    }

  mpMIRIAMInfo->load(mKey);

  //Set Models for the 4 TableViews
  std::vector<CQTableView*>::const_iterator it = mWidgets.begin();
  std::vector<CQTableView*>::const_iterator end = mWidgets.end();

  std::vector<CQBaseDataModel*>::const_iterator itDM = mDMs.begin();
  std::vector<CQBaseDataModel*>::const_iterator endDM = mDMs.end();

  std::vector<CQSortFilterProxyModel*>::const_iterator itPDM = mProxyDMs.begin();
  std::vector<CQSortFilterProxyModel*>::const_iterator endPDM = mProxyDMs.end();

  for (; it != end && itDM != endDM && itPDM != endPDM; it++, itDM++, itPDM++)
    {
      (*itPDM)->setSourceModel(*itDM);
      (*it)->setModel(NULL);
      (*it)->setModel(*itPDM);
      (*it)->resizeColumnsToContents();
    }

  QDateTime DTCreated;

  if (mpMIRIAMInfo->getCreatedDT() != "")
    DTCreated = QDateTime::fromString(FROM_UTF8(mpMIRIAMInfo->getCreatedDT()), Qt::ISODate);

  if (DTCreated.isValid())
    mpDTCreated->setDateTime(DTCreated);
  else
    {
      mpDTCreated->setDateTime(QDateTime::currentDateTime());
    }

  if (CCopasiMessage::size() > 0)
    {
      mMessageType = CCopasiMessage::getHighestSeverity();
      mMessage = CCopasiMessage::getAllMessageText();
      CCopasiMessage::clearDeque();

      showEvent(NULL);
    }
  else
    {
      mMessageType = -1;
      mMessage = "";
    }

  return true;
}