Ejemplo n.º 1
0
 void DBConfig::enableSharding() {
     if ( _shardingEnabled )
         return;
     scoped_lock lk( _lock );
     _shardingEnabled = true;
     _save();
 }
Ejemplo n.º 2
0
void
ModelEditor::on__model_editor_tab_tabCloseRequested (int index)
{
  if (index < 0)
    return;
  ModelInfo mi = _models->value (index);
  if (!mi.init ())
    {
      if (mi.dirty ())
	{
	  QMessageBox::StandardButton res = QMessageBox::question (
	      this, "Save",
	      QString ("Save changes to file ") + mi.name () + QString ("?"),
	      QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
	  if (res == QMessageBox::Save)
	    {
	      _save (index);
	    }
	  else if (res == QMessageBox::Cancel)
	    {
	      return;
	    }
	}
    }
  else
    {
      mi.setInit (false);
      _models->replace (index, mi);
    }
  _delete (index);
}
Ejemplo n.º 3
0
    ChunkManagerPtr DBConfig::shardCollection( const string& ns , ShardKeyPattern fieldsAndOrder , bool unique ) {
        uassert( 8042 , "db doesn't have sharding enabled" , _shardingEnabled );

        scoped_lock lk( _lock );

        CollectionInfo& ci = _collections[ns];
        uassert( 8043 , "collection already sharded" , ! ci.isSharded() );

        log() << "enable sharding on: " << ns << " with shard key: " << fieldsAndOrder << endl;

        // From this point on, 'ns' is going to be treated as a sharded collection. We assume this is the first
        // time it is seen by the sharded system and thus create the first chunk for the collection. All the remaining
        // chunks will be created as a by-product of splitting.
        ci.shard( ns , fieldsAndOrder , unique );
        ChunkManagerPtr cm = ci.getCM();
        uassert( 13449 , "collections already sharded" , (cm->numChunks() == 0) );
        cm->createFirstChunk( getPrimary() );
        _save();

        try {
            cm->maybeChunkCollection();
        }
        catch ( UserException& e ) {
            // failure to chunk is not critical enough to abort the command (and undo the _save()'d configDB state)
            log() << "couldn't chunk recently created collection: " << ns << " " << e << endl;
        }

        return cm;
    }
Ejemplo n.º 4
0
    bool DBConfig::_load(){
        ScopedDbConnection conn( configServer.modelServer() );
        
        BSONObj o = conn->findOne( ShardNS::database , BSON( "_id" << _name ) );


        if ( o.isEmpty() ){
            conn.done();
            return false;
        }
        
        if ( unserialize( o ) )
            _save();
        
        BSONObjBuilder b;
        b.appendRegex( "_id" , (string)"^" + _name + "." );
        

        auto_ptr<DBClientCursor> cursor = conn->query( ShardNS::collection ,b.obj() );
        assert( cursor.get() );
        while ( cursor->more() ){
            BSONObj o = cursor->next();
            _collections[o["_id"].String()] = CollectionInfo( this , o );
        }
        
        conn.done();        

        return true;
    }
Ejemplo n.º 5
0
    ChunkManagerPtr DBConfig::shardCollection( const string& ns , ShardKeyPattern fieldsAndOrder , bool unique ){
        uassert( 8042 , "db doesn't have sharding enabled" , _shardingEnabled );
        
        scoped_lock lk( _lock );

        CollectionInfo& ci = _collections[ns];
        uassert( 8043 , "collection already sharded" , ! ci.isSharded() );

        log() << "enable sharding on: " << ns << " with shard key: " << fieldsAndOrder << endl;

        // mark the collection as sharded and save metadata before trying to chunk, which may throw
        // TODO undo _collections state if ci.shard() or _save() fails
        ci.shard( this , ns , fieldsAndOrder , unique );
        _save();

        try {
            ci.getCM()->maybeChunkCollection();
        }
        catch ( UserException& e ){
            // failure to chunk is not critical enough to abort the command (and undo the _save()'d configDB state)
            log() << "couldn't chunk recently created collection: " << ns << " " << e << endl;
        }

        return ci.getCM();
    }
Ejemplo n.º 6
0
    void DBConfig::enableSharding() {
        if ( _shardingEnabled )
            return;
        
        assert( _name != "config" );

        scoped_lock lk( _lock );
        _shardingEnabled = true;
        _save();
    }
Ejemplo n.º 7
0
djvImageIoPrefs::~djvImageIoPrefs()
{
    //DJV_DEBUG("djvImageIoPrefs::~djvImageIoPrefs");

    const QList<djvPlugin *> & plugins = _context->imageIoFactory()->plugins();
    
    for (int i = 0; i < plugins.count(); ++i)
    {
        if (djvImageIo * plugin = dynamic_cast<djvImageIo *>(plugins[i]))
        {
            _save(plugin);
        }
    }
}
bool Subtitle::Parser::save(const Subtitle &sub, const QString &fileName) {
	QString content;
	if (!_save(content, sub))
		return false;
	QFile file(fileName);
	if (!file.open(QFile::WriteOnly | QFile::Truncate))
		return false;
	QTextCodec *codec = QTextCodec::codecForName(m_enc.toLocal8Bit());
	if (!codec)
		return false;
	if (file.write(codec->fromUnicode(content)) < 0)
		return false;
	file.close();
	return true;
}
Ejemplo n.º 9
0
bool MgRecordShape::save(MgStorage* s) const
{
    int i = 0;
    bool ret = true;
    
    s->writeInt("refid", _sid);
    for (ITEMS::const_iterator it = _items.begin(); ret && it != _items.end(); ++it) {
        ret = s->writeNode("p", i, false);
        if (ret) {
            s->writeInt("type", (*it)->type());
            ret = (*it)->save(s);
            s->writeNode("p", i++, true);
        }
    }
    return ret && _save(s);
}
Ejemplo n.º 10
0
    ChunkManagerPtr DBConfig::shardCollection( const string& ns , ShardKeyPattern fieldsAndOrder , bool unique ){
        uassert( 8042 , "db doesn't have sharding enabled" , _shardingEnabled );
        
        scoped_lock lk( _lock );

        CollectionInfo& ci = _collections[ns];
        uassert( 8043 , "already sharded" , ! ci.isSharded() );

        log() << "enable sharding on: " << ns << " with shard key: " << fieldsAndOrder << endl;

        ci.shard( this , ns , fieldsAndOrder , unique );
        ci.getCM()->maybeChunkCollection();

        _save();
        return ci.getCM();
    }
Ejemplo n.º 11
0
void Rsdic::save(std::ostream& os) const
{
    os.write((const char*)&_num, sizeof(_num));
    os.write((const char*)&_one_num, sizeof(_one_num));
    _save(os, _bits);
    _save(os, _pointer_blocks);
    _save(os, _rank_blocks);
    _save(os, _select_one_inds);
    _save(os, _select_zero_inds);
    _save(os, _rank_small_blocks);
}
Ejemplo n.º 12
0
    //-----------------------------------------------------------------------
    void PagingLandScapeData2D::unload()
    {
        if (mIsLoaded)
        {
            if (mIsModified)
                _save ();
            delete[] mHeightData;
            mHeightData = 0;
	        _unload();
	        mIsLoaded = false;
            mIsModified = false;
            mIsRectModified = false;
            #ifndef _MAPSPLITTER
                resetDeformationRectangle ();
            #endif
        }
    }
Ejemplo n.º 13
0
QString SnapshotsFile::save( const QString& sessionId, const QString& snapshotType,
                const QString& snapName, const QString saveStr ){
    QString result;
    QString fullName = snapName;
    if ( !snapName.endsWith( SUFFIX ) ){
        fullName = fullName + SUFFIX;
    }
    QString rootDir = _getRootDir( sessionId );
    QString filePath = rootDir + QDir::separator();
    if ( snapshotType.length() > 0 ){
        filePath = filePath + snapshotType + QDir::separator();
    }
    filePath = filePath + fullName;
    bool saved = _save( filePath, saveStr );
    if ( !saved ){
        result = "There was a problem saving the "+snapshotType+" snapshot "+snapName;
    }
    return result;
}
Ejemplo n.º 14
0
    bool DBConfig::removeSharding( const string& ns ) {
        if ( ! _shardingEnabled ) {
            return false;
        }

        scoped_lock lk( _lock );

        Collections::iterator i = _collections.find( ns );

        if ( i == _collections.end() )
            return false;

        CollectionInfo& ci = _collections[ns];
        if ( ! ci.isSharded() )
            return false;

        ci.unshard();
        _save();
        return true;
    }
Ejemplo n.º 15
0
gboolean magick_make_webimage(struct data *data, 
                              struct image *image,
                              const gchar *uri,
                              gint image_h)
{
    MagickWand *wand;
    struct image_size *img_size = NULL;
    GnomeVFSResult result;
    GnomeVFSFileInfo *info;

    g_debug("in magick_make_webimage");

    wand = _generate_webimage(data, image, image_h, &img_size);
    if (wand == NULL) 
        return FALSE;

    /* save the image to a file */
    if (!_save(data, wand, uri)) {
        DestroyMagickWand(wand);
        g_free(img_size);
        return FALSE;
    }
    
    DestroyMagickWand(wand);

    /* get file size */
    info = gnome_vfs_file_info_new();
    result = gnome_vfs_get_file_info(uri, info,
                                     GNOME_VFS_FILE_INFO_DEFAULT | 
                                     GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
    if (result == GNOME_VFS_OK) {
        img_size->size = info->size / 1024;
    } else {
        img_size->size = 0;
    }
    
    image->sizes = g_slist_append(image->sizes, img_size);
    gnome_vfs_file_info_unref(info);

    return TRUE;
}
Ejemplo n.º 16
0
StorageRegister::~StorageRegister() { _save(); }
Ejemplo n.º 17
0
bool MgBaseShape::save(MgStorage* s) const {
    return _save(s);
}
Ejemplo n.º 18
0
 void DBConfig::setPrimary( string s ) {
     scoped_lock lk( _lock );
     _primary.reset( s );
     _save();
 }
	void Configuration::save(rapidjson::Value &json, rapidjson::Document &document) const
	{
		_save(json, document);
	}
Ejemplo n.º 20
0
void Settings::accept() { if(_save()) hide(); }
Ejemplo n.º 21
0
void Settings::apply() { _save(); }
Ejemplo n.º 22
0
gboolean magick_make_thumbnail(struct data *data, 
                               struct image *image,
                               const gchar *uri)
{
    MagickWand *wand;
    gdouble scale;

    g_assert(data != NULL);
    g_assert(image != NULL);
    
    g_debug("in magick_make_thumbnail");

    wand = NewMagickWand();
    g_return_val_if_fail( wand, FALSE );

    /* load image from file */
    if (!_load_image(data, wand, image)) {
        DestroyMagickWand(wand);
        return FALSE;
    }

    /* apply modifications, if nomodify is not checked */
    if (!image->nomodify) {
        if (!_apply_modifications(data, wand, image)) {
            DestroyMagickWand(wand);
            return FALSE;
        }
    }
    
    /* calculate width and height for the thumbnail */
    image->thumb_w = data->gal->thumb_w;
    switch( image->rotate ) 
    {
    case 0:
    case 180:
        scale = (gdouble)image->height / (gdouble)image->width;
        break;
    case 90:
    case 270:
        scale = (gdouble)image->width / (gdouble)image->height;
        break;
        /* FIXME: just to get some values.. */
    default:
        scale = (gdouble)image->width / (gdouble)image->height;
        break;
    }
    image->thumb_h = (gint)(image->thumb_w * scale);

    /* resize the thumbnail */
    if (!_resize(data, wand, image, image->thumb_w, image->thumb_h)) {
        DestroyMagickWand(wand);
        return FALSE;
    }

    
    /* save the thumbnail to a file */
    if (!_save(data, wand, uri)) {
        DestroyMagickWand(wand);
        return FALSE;
    }
    
    DestroyMagickWand(wand);

    return TRUE;
}
Ejemplo n.º 23
0
void ChamadaForm::_initialize(){
	Wt::Dbo::Transaction transaction(_dbSession);

	Wt::WText* title = new Wt::WText("<h3>Diario de Classe: " + Wt::WDate::currentDate().toString("dd/MM/yyyy").toUTF8() + "</h3> <br></br><br></br>");

		addWidget(title);
		Wt::WPushButton* fazerChamada = new Wt::WPushButton("Percorrer turma", this);

		fazerChamada->setStyleClass("btn btn-primary");

		fazerChamada->clicked().connect(std::bind([=](){
			new AutoChamada(_dbSession, sortList);
		}));

		fazerChamada->setMargin(20, Wt::Bottom);
		_list =  new Wt::WTable(this);


		Wt::WPushButton* save = new Wt::WPushButton("Salvar", this);
		save->setStyleClass("btn btn-success");
		save->setMargin(10, Wt::Right);
		save->clicked().connect(std::bind([=](){
			_save();
			delete this;
		}));

		Wt::WPushButton* cancel = new Wt::WPushButton("Cancelar", this);
		cancel->setStyleClass("btn btn-primary");
		cancel->clicked().connect(std::bind([=](){
			delete this;
		}));

	_list->setWidth(Wt::WLength("100%"));
	_list->addStyleClass("table-striped table-hover");
	_list->setMargin(50, Wt::Bottom);
	new Wt::WText("Aluno", _list->elementAt(0,0));
	new Wt::WText("Presente", _list->elementAt(0,1));
	_list->setHeaderCount(1);


	for(auto i : _disciplina->turma()->alunos()){
		Wt::WCheckBox* checkbox = new Wt::WCheckBox();
		sortList.push_back(std::make_pair(checkbox, i));
	}

	auto sortAlg = [](std::pair<Wt::WCheckBox*, Wt::Dbo::ptr<SiconfModel::Aluno>> par1, std::pair<Wt::WCheckBox*, Wt::Dbo::ptr<SiconfModel::Aluno>>par2){
		return par1.second->usuario()->nome() < par2.second->usuario()->nome();
	};

	std::sort(std::begin(sortList), std::end(sortList), sortAlg);

	for(auto i : sortList){
		int row = _list->rowCount();
		Wt::WText* name = new Wt::WText(i.second->usuario()->nome() + " " + i.second->usuario()->sobrenome(), _list->elementAt(row, 0));
		name->setMargin(10, Wt::Right);
		_list->elementAt(row, 1)->addWidget(i.first);
		_list->elementAt(row, 1)->setHeight(40);
		_list->elementAt(row, 1)->setWidth(100);

	}
}