Пример #1
0
void
CustomerMaster::slotRenameData()
{
    int row = _extra->currentRow();
    if (row == -1) return;

    Id extra_id = _extra->cellValue(row, 0).toId();
    if (extra_id == INVALID_ID) return;

    Extra extra;
    if (!_quasar->db()->lookup(extra_id, extra)) {
        QMessageBox::critical(this, tr("Error"), tr("Data lookup failed."));
        return;
    }

    bool ok = false;
    QString message = tr("Enter the new name for %1:").arg(extra.name());
    QString text = QInputDialog::getText(tr("Rename Data"), message,
                                         QLineEdit::Normal, QString::null,
                                         &ok, this);
    if (!ok || text.isEmpty()) return;

    Extra orig = extra;
    extra.setName(text);
    if (!_quasar->db()->update(orig, extra)) {
        QMessageBox::critical(this, tr("Error"), tr("Renaming data failed."));
        return;
    }

    _extra->setCellValue(row, 0, extra.id());
}
Пример #2
0
void
CustomerMaster::slotDeleteData()
{
    int row = _extra->currentRow();
    if (row == -1) return;

    Id extra_id = _extra->cellValue(row, 0).toId();
    if (extra_id == INVALID_ID) return;

    Extra extra;
    if (!_quasar->db()->lookup(extra_id, extra)) {
        QMessageBox::critical(this, tr("Error"), tr("Data lookup failed."));
        return;
    }

    QString message = tr("Are you sure you want to delete the\n"
                         "%1 data?  It will be removed from\nall items.").arg(extra.name());
    int choice = QMessageBox::warning(this, tr("Delete?"), message,
                                      QMessageBox::No, QMessageBox::Yes);
    if (choice != QMessageBox::Yes)
        return;

    if (!_quasar->db()->remove(extra)) {
        QMessageBox::critical(this, tr("Error"), tr("Deleting data failed."));
        return;
    }

    _extra->deleteRow(row);
}
Пример #3
0
QString
ExtraLookup::lookupById(Id extra_id)
{
    Extra extra;
    if (extra_id != INVALID_ID && _quasar->db()->lookup(extra_id, extra))
	return extra.name();
    return "";
}
Пример #4
0
NamespaceDetails::Extra* NamespaceDetails::allocExtra(OperationContext* txn,
        StringData ns,
        NamespaceIndex& ni,
        int nindexessofar) {
    // Namespace details must always be changed under an exclusive DB lock
    const NamespaceString nss(ns);
    invariant(txn->lockState()->isDbLockedForMode(nss.db(), MODE_X));

    int i = (nindexessofar - NIndexesBase) / NIndexesExtra;
    verify(i >= 0 && i <= 1);

    Namespace fullns(ns);
    Namespace extrans(fullns.extraName(i));  // throws UserException if ns name too long

    massert(10350, "allocExtra: base ns missing?", this);
    massert(10351, "allocExtra: extra already exists", ni.details(extrans) == 0);

    Extra temp;
    temp.init();

    ni.add_ns(txn, extrans, reinterpret_cast<NamespaceDetails*>(&temp));
    Extra* e = reinterpret_cast<NamespaceDetails::Extra*>(ni.details(extrans));

    long ofs = e->ofsFrom(this);
    if (i == 0) {
        verify(_extraOffset == 0);
        *txn->recoveryUnit()->writing(&_extraOffset) = ofs;
        verify(extra() == e);
    } else {
        Extra* hd = extra();
        verify(hd->next(this) == 0);
        hd->setNext(txn, ofs);
    }
    return e;
}
Пример #5
0
 IndexDetails& NamespaceDetails::idx(int idxNo, bool missingExpected) {
     if( idxNo < NIndexesBase ) {
         IndexDetails& id = _indexes[idxNo];
         return id;
     }
     Extra *e = extra();
     if ( ! e ) {
         if ( missingExpected )
             throw MsgAssertionException( 13283 , "Missing Extra" );
         massert(14045, "missing Extra", e);
     }
     int i = idxNo - NIndexesBase;
     if( i >= NIndexesExtra ) {
         e = e->next(this);
         if ( ! e ) {
             if ( missingExpected )
                 throw MsgAssertionException( 14823 , "missing extra" );
             massert(14824, "missing Extra", e);
         }
         i -= NIndexesExtra;
     }
     return e->details[i];
 }
Пример #6
0
void
CustomerMaster::slotCreateData()
{
    bool ok = false;
    QString message = tr("Enter the new data name:");
    QString text = QInputDialog::getText(tr("Create Data"), message,
                                         QLineEdit::Normal, QString::null,
                                         &ok, this);
    if (!ok || text.isEmpty()) return;

    Extra extra;
    extra.setTable("Customer");
    extra.setName(text);
    if (!_quasar->db()->create(extra)) {
        QMessageBox::critical(this, tr("Error"),
                              tr("Creating new data failed."));
        return;
    }

    VectorRow* row = new VectorRow(_extra->columns());
    row->setValue(0, extra.id());
    row->setValue(1, "");
    _extra->appendRow(row);
}
Пример #7
0
 // must be called when renaming a NS to fix up extra
 void NamespaceDetails::copyingFrom( OperationContext* txn,
                                     const StringData& thisns,
                                     NamespaceIndex& ni,
                                     NamespaceDetails* src) {
     _extraOffset = 0; // we are a copy -- the old value is wrong.  fixing it up below.
     Extra *se = src->extra();
     int n = NIndexesBase;
     if( se ) {
         Extra *e = allocExtra(txn, thisns, ni, n);
         while( 1 ) {
             n += NIndexesExtra;
             e->copy(this, *se);
             se = se->next(src);
             if( se == 0 ) break;
             Extra *nxt = allocExtra(txn, thisns, ni, n);
             e->setNext( txn, nxt->ofsFrom(this) );
             e = nxt;
         }
         verify( _extraOffset );
     }
 }
Пример #8
0
Extra* Extra::createExtra(CCTexture2D* aTexture)
{
	Extra* pExtra = new Extra();
	pExtra->initWithTexture(aTexture);
	pExtra->setTextureRect(CCRectMake(EXTRA_RECT.x, 0, EXTRA_RECT.x, EXTRA_RECT.y));
	pExtra->setScale(BRICK_SCALE_FACTOR);
	pExtra->autorelease();

	CCTexture2D* texture = CCTextureCache::sharedTextureCache()->addImage("gfx/bricks.png");
	CCSprite* pShadow = new CCSprite();
	pShadow->initWithTexture(texture, CCRectMake(6*EXTRA_RECT.x, 0, EXTRA_RECT.x, EXTRA_RECT.y));
	//CCSprite* pShadow= CCSprite::create("gfx/bricks.png", CCRectMake(6*EXTRA_RECT.x, 0, EXTRA_RECT.x, EXTRA_RECT.y));
	if (pShadow)
	{
		pShadow->setScale(0.8f);
		pExtra->addChild(pShadow, TagShadow);
		pShadow->autorelease();
		pShadow->setPosition(ccp(20, -10));
	}

	return pExtra;
}
Пример #9
0
 // XXX - this method should go away
 NamespaceDetails *NamespaceDetails::writingWithExtra( OperationContext* txn ) {
     for( Extra *e = extra(); e; e = e->next( this ) ) {
         txn->recoveryUnit()->writing( e );
     }
     return writingWithoutExtra( txn );
 }
Пример #10
0
//=============================================================================
// Main execution
//=============================================================================
StatusCode B2DMuNu::execute() {
  
  if (msgLevel(MSG::DEBUG)) debug() << "==> Execute" << endmsg;
  StatusCode sc = StatusCode::SUCCESS;
  
  //### Extract Run number and Event number ###//
  const LHCb::ODIN* odin = get<LHCb::ODIN>(LHCb::ODINLocation::Default);
  const unsigned int runNum = odin->runNumber(), evNum = odin->eventNumber();
  debug() << "Run number is " << runNum << " and Event ID is " << evNum
          << " at time " << odin->eventTime() << endmsg; //odin->gpsTime() << endmsg;
  counter("EventID")++;
  debug() << "### Processing event number " << counter("EventID").nEntries() << " in job ###" << endmsg;
  
  setFilterPassed(true); // Mandatory. Set to true if event is accepted.

  //### Only run on MC data if requested ###//
  if (m_runMC==1)
  {
    //### Test MC data to see if event warrants reconstruction (Require B0/B- OR B0~/B+ both decaying to muons) ###//
    m_passEvent = 0;
    debug() << "Performing Analysis on MC data" << endmsg;
    sc = loopOnMC();
    if (!sc) return sc;
  }
  
  if (m_passEvent==1) 
  {
    debug() << "### Event number " << counter("EventID").nEntries() << " accepted for analysis buddy ###" << endmsg;
    counter("EventPasses")++;
    
    debug() << "Extracting daughters..." << endmsg;
    LHCb::Particle::ConstVector daughters = this->i_particles();

    if (daughters.size()!=0)
    {
      debug() << "### There are " << daughters.size() << " possible Muons in this event (EventID "
              << counter("EventID").nEntries() << ") ###" << endmsg;
      counter("MuonsPresent")++;
      
      //### Extract muon hits and muon misid if requested ###//
      if (m_muHits) {
        const std::string& strExtra = "Extra";
        Extra* extra = new Extra(strExtra, m_local);
        Tuple fakeTuple = nTuple("fakeMuonTuple");
        sc = extra->fakeMuon(daughters, fakeTuple);
        Tuple hitTuple = nTuple("muonHitTuple");
        sc = extra->muonChamberHits(hitTuple);
        delete extra;
        if (!sc) return sc;
      }

      //### Test - Call loopOnRec ###//
      const std::string& strRec = "Rec";
      Rec* rec = new Rec(strRec, m_local);
      Tuple recAllTuple=nTuple("recAllTuple"), hitDistTuple=nTuple("muHitDistTuple"), motherTuple=nTuple("motherTuple"), 
        candTuple=nTuple("candidateTuple");
      const LHCb::RecVertex::Range prims = this->primaryVertices();
      LHCb::Particle::Vector mothers = 
        rec->loopOnRec(daughters, prims, m_motherID, recAllTuple, hitDistTuple, motherTuple, candTuple, m_runMC);
      
      delete rec;
      if (!sc) return sc;
    }
    else debug() << "### There are no possible muons in the event!! ###" << endmsg;
    debug() << "### Finishing analysis for Event number " << counter("EventID").nEntries() << " ###" << endmsg;
  }
  else
  {
    debug() << "Event rejected" << endmsg;
    counter("EventFails")++;
  }
  
  debug() << "Event fully analysed." << endmsg;
  return StatusCode::SUCCESS;
}