public void doStuff() { Session session = Db.getSession(); session.beginTransaction(); User user = new User(new Person("Pascal", "Mazars"), "pma", "cacaprout"); System.out.println("Hello " + user); ID<User> id = user.save(); System.out.println("Persisted with id " + id); System.out.println( "Persisted with id " + new User(new Person("Daddy", "Longleg"), "dlg", "cacaprout").save()); // User foundUser = UserFinder.getInstance().findUnique("from app.core.User where // person.firstName = 'Pascal'"); // System.out.println("Found unique with firstName = 'Pascal': " + foundUser.toString()); // User foundUser2 = new IDFinder<User>().get(id); // System.out.println("Found with id " + id + ": " + foundUser2.toString()); // foundUser2.getPerson().setDateOfBirth(new Date()); // User foundUser3 = foundUser2.getPerson().getUser(); // System.out.println("Found with getPerson().getUser(): " + foundUser3.toString()); List<User> userList = User.findAll(); // find("from app.core.User"); System.out.println("List<app.core.User>: \n" + ORMUtils.toResultString(userList)); System.out.println("Db dump: " + Db.dump()); session.flush(); throw ApplicationError.somethingWentTerriblyWrong(); }
/** * Updates the cached lastDdlTime for the given table. The lastDdlTime is used during the metadata * refresh() operations to determine if there have been any external (outside of Impala) * modifications to the table. */ public void updateLastDdlTime(TTableName tblName, long ddlTime) { Db db = getDb(tblName.getDb_name()); if (db == null) return; Table tbl = db.getTable(tblName.getTable_name()); if (tbl == null) return; tbl.updateLastDdlTime(ddlTime); }
protected final void doActionPerformed(ActionEvent evt) { try { ApplicationDiagram diag = (ApplicationDiagram) (ApplicationContext.getFocusManager().getFocusObject()); Point clickPosition = getDiagramLocation(evt); if (clickPosition == null) clickPosition = GraphicUtil.rectangleGetCenter(diag.getMainView().getViewRect()); java.awt.Image image = SRSystemClipboard.getClipboardImage(); if (image == null) return; DbObject diagGo = diag.getDiagramGO(); Db db = diagGo.getDb(); ImageIcon icon = new ImageIcon(image); int imageHeigth = icon.getIconHeight(); int imageWidth = icon.getIconWidth(); db.beginTrans(Db.WRITE_TRANS, LocaleMgr.action.getString("pasteDiagramImage")); DbObject imageGo = diagGo.createComponent(DbGraphic.fImageGoDiagramImage.getMetaClass()); imageGo.set(DbGraphic.fImageGoDiagramImage, image); imageGo.set( DbGraphic.fGraphicalObjectRectangle, new Rectangle( clickPosition.x - (imageWidth / 2), clickPosition.y - (imageHeigth / 2), imageWidth, imageHeigth)); db.commitTrans(); } catch (Exception e) { org.modelsphere.jack.util.ExceptionHandler.processUncatchedException( ApplicationContext.getDefaultMainFrame(), e); } }
public ArrayList getAll() { ArrayList<Recipe> list = new ArrayList<Recipe>(); db.open(); Cursor cursor = db.fetchAll(KEY_TABLE_NAME); if (cursor == null || cursor.getCount() < 1) return null; cursor.moveToFirst(); /*Get column IDs*/ int col_name = cursor.getColumnIndex(KEY_NAME); int col_category = cursor.getColumnIndex(KEY_CATEGORY); int col_ingredients = cursor.getColumnIndex(KEY_INGREDIENTS); int col_instructions = cursor.getColumnIndex(KEY_INSTRUCTIONS); int col__id = cursor.getColumnIndex(KEY__ID); do { Recipe recipe = new Recipe(); recipe.name = cursor.getString(col_name); recipe.category = cursor.getString(col_category); recipe.ingredients = cursor.getString(col_ingredients); recipe.instructions = cursor.getString(col_instructions); recipe._id = cursor.getInt(col__id); Log.e("Test:RECIPE - id", cursor.getInt(col__id) + ""); list.add(recipe); } while (cursor.moveToNext()); db.close(); return list; }
public static NavData[] getAll() { Connection con = null; PreparedStatement ps; ResultSet rs; ArrayList<NavData> alfaq = new ArrayList<NavData>(); try { con = Db.getConnection(); String ssql = "select * from navdata order by navdataid desc"; ps = con.prepareStatement(ssql, Statement.RETURN_GENERATED_KEYS); rs = ps.executeQuery(); while (rs.next()) { NavData faq = new NavData(); faq.fromResultSet(rs); alfaq.add(faq); } rs.close(); ps.close(); } catch (Exception e) { log.error("", e); } finally { Db.releaseConnection(con); } NavData[] ret = new NavData[alfaq.size()]; alfaq.toArray(ret); return (ret); }
/** * Adds a table with the given name to the catalog and returns the new table, loading the metadata * if needed. */ public Table addTable(String dbName, String tblName) throws TableNotFoundException { Db db = getDb(dbName); if (db == null) return null; Table incompleteTable = IncompleteTable.createUninitializedTable(getNextTableId(), db, tblName); incompleteTable.setCatalogVersion(incrementAndGetCatalogVersion()); db.addTable(incompleteTable); return db.getTable(tblName); }
/** * Removes a database from the metadata cache and returns the removed database, or null if the * database did not exist in the cache. Used by DROP DATABASE statements. */ @Override public Db removeDb(String dbName) { Db removedDb = super.removeDb(dbName); if (removedDb != null) { removedDb.setCatalogVersion(incrementAndGetCatalogVersion()); } return removedDb; }
@Override public TodoItem call(Cursor cursor) { long id = Db.getLong(cursor, ID); long listId = Db.getLong(cursor, LIST_ID); String description = Db.getString(cursor, DESCRIPTION); boolean complete = Db.getBoolean(cursor, COMPLETE); return new AutoParcel_TodoItem(id, listId, description, complete); }
private void insertProjects(SrVector children, Db db) throws DbException { db.beginTrans(Db.READ_TRANS); DbObject parent = db.getRoot(); DbEnumeration dbEnum = parent.getComponents().elements(DbProject.metaClass); while (dbEnum.hasMoreElements()) children.addElement(createPrimaryNode(parent, dbEnum.nextElement())); dbEnum.close(); db.commitTrans(); }
public final DynamicNode getDynamicNode(DbObject dbo, int which, boolean load) throws DbException { SrVector path = new SrVector(10); Db db = dbo.getDb(); db.beginTrans(Db.READ_TRANS); while (dbo != null && !(dbo instanceof DbRoot)) { path.addElement(dbo); dbo = getDbParent(dbo, which); } if (db instanceof DbRAM) { if (DB_RAM != ((DynamicNode) getRoot()).getUserObject()) path.addElement(DB_RAM); } else path.addElement(db); DynamicNode nodeFound = (DynamicNode) getRoot(); for (int i = path.size(); --i >= 0; ) { if (load) loadChildren(nodeFound); Object userObj = path.elementAt(i); dbo = null; DbObject dbParent = null; GroupParams group = GroupParams.defaultGroupParams; DynamicNode groupNode = null; DynamicNode node = null; if (userObj instanceof DbObject) { dbo = (DbObject) userObj; dbParent = getDbParent(dbo, which); group = getGroupParams(dbParent, dbo); } if (group.name == null) { node = getDynamicNode(nodeFound, userObj, 0); } else { groupNode = getGroupNode(nodeFound, group, 0); if (groupNode != null) node = getDynamicNode(groupNode, userObj, 0); } if (node == null && nodeFound.hasLoaded() && !nodeFound.isLeaf() && which == Db.NEW_VALUE) { SemanticalModel model = ApplicationContext.getSemanticalModel(); boolean visible = model.isVisibleOnScreen(dbParent, dbo, Explorer.class); if (visible) { node = createPrimaryNode(dbParent, dbo); if (group.name == null) { insertNodeInto(node, nodeFound, getInsertionIndex(dbParent, dbo, nodeFound, node)); } else { if (groupNode == null) { groupNode = createGroupNode(group); insertNodeInto(groupNode, nodeFound, getSortedIndex(nodeFound, groupNode)); } insertNodeInto(node, groupNode, getInsertionIndex(dbParent, dbo, groupNode, node)); } } } nodeFound = node; if (nodeFound == null) break; } db.commitTrans(); return nodeFound; }
public int atacar(int naves) throws InterruptedException { Db db = new Db(); for (Espionaje es : db.getEspionaje()) { if (naves > 0) { naves -= es.getNaves(); if (setAtaque(es.getPlaneta(), es.getNaves())) db.deleteEspionaje(es.getId()); } } return naves; }
/** * Removes a table from the catalog and increments the catalog version. Returns the removed Table, * or null if the table or db does not exist. */ public Table removeTable(String dbName, String tblName) { Db parentDb = getDb(dbName); if (parentDb == null) return null; Table removedTable = parentDb.removeTable(tblName); if (removedTable != null) { removedTable.setCatalogVersion(incrementAndGetCatalogVersion()); } return removedTable; }
/** * Adds a function from the catalog, incrementing the catalog version. Returns true if the add was * successful, false otherwise. */ @Override public boolean addFunction(Function fn) { Db db = getDb(fn.getFunctionName().getDb()); if (db == null) return false; if (db.addFunction(fn)) { fn.setCatalogVersion(incrementAndGetCatalogVersion()); return true; } return false; }
public long insert() { ContentValues cv = new ContentValues(); db.open(); cv.put(KEY_NAME, name); cv.put(KEY_CATEGORY, category); cv.put(KEY_INGREDIENTS, ingredients); cv.put(KEY_INSTRUCTIONS, instructions); long id = db.insert(KEY_TABLE_NAME, cv); db.close(); return id; }
@Override protected void runJob() throws Exception { Controller controller = getController(); // is invoked head less? DefaultMainFrame mainFrame = ApplicationContext.getDefaultMainFrame(); boolean headless = (mainFrame == null); Db db = null; try { if (!headless) { // create new project, if it was not specific by the user m_project = m_params.getOutputProject(); if (m_project == null) { m_project = (DbSMSProject) mainFrame.createDefaultProject(db); } db = m_project.getDb(); db.beginWriteTrans(LocaleMgr.misc.getString("ImportJavaBytecode")); // create class model m_classModel = new DbJVClassModel(m_project); } // import Java classes files (jobDone 0% to 80%) DbJVPackage topMostPackage = importFiles(controller, 0, 80); // show success/failure message if (controller.getErrorsCount() == 0) { controller.println(LocaleMgr.misc.getString("Success")); } else { controller.println(LocaleMgr.misc.getString("Failed")); } // end if // create and reveal diagram ((jobDone 80% to 100%) if (!headless) { if ((topMostPackage != null) && (m_params.createDiagrams)) { createAndRevealDiagram(mainFrame, topMostPackage, controller, 80, 100); } db.commitTrans(); } // end if controller.checkPoint(100); } catch (DbException ex) { controller.println(ex.toString()); controller.cancel(); } // end try } // end runJob()
/** * Renames a table. Equivalent to an atomic drop + add of the table. Returns the new Table object * with an incremented catalog version or null if operation was not successful. */ public Table renameTable(TTableName oldTableName, TTableName newTableName) throws CatalogException { // Ensure the removal of the old table and addition of the new table happen // atomically. catalogLock_.writeLock().lock(); try { // Remove the old table name from the cache and add the new table. Db db = getDb(oldTableName.getDb_name()); if (db != null) db.removeTable(oldTableName.getTable_name()); return addTable(newTableName.getDb_name(), newTableName.getTable_name()); } finally { catalogLock_.writeLock().unlock(); } }
/** * Test routine * * @param args * @throws ClassNotFoundException * @throws SQLException */ public static void main(String[] args) throws ClassNotFoundException, SQLException { if (args.length != 11) { System.err.println( " args are: srcSystem srcDbName srcDbType srcUserId srcPasswd destSystem destDbName destDbType destUserId destPasswd tableName"); System.exit(1); } String srcSystem = args[0]; String srcDbName = args[1]; String srcDbType = args[2]; String srcUserId = args[3]; String srcPasswd = args[4]; String destSystem = args[5]; String destDbName = args[6]; String destDbType = args[7]; String destUserId = args[8]; String destPasswd = args[9]; String tableName = args[10]; Db srcDb = null; switch (srcDbType) { case "as400": srcDb = new DbAS400(); break; case "postgres": srcDb = new DbPostgres(); break; } Db destDb = null; switch (destDbType) { case "as400": destDb = new DbAS400(); break; case "postgres": destDb = new DbPostgres(); break; } if (srcDb == null || destDb == null) { System.err.println("Couldn't instance one or both databases"); System.exit(1); } if (srcDb != null && destDb != null) { srcDb.connect(srcSystem, null, srcDbName, null, srcUserId, srcPasswd); destDb.connect(destSystem, null, destDbName, null, destUserId, destPasswd); } TableReplicator tr = newTableReplicator(srcDb, destDb, tableName); tr.replicate(); // tr.closeAll(); }
// Called at the end of a cell edition, to process the edition result. public final void valueForPathChanged(TreePath path, Object newValue) { DynamicNode node = (DynamicNode) path.getLastPathComponent(); Object obj = node.getRealObject(); if (obj instanceof DbObject) { boolean editable = false; try { Db db = ((DbObject) obj).getDb(); if (db.isValid()) { db.beginReadTrans(); MetaField editableMetaField = getEditableMetaField((DbObject) obj); if (editableMetaField == null) editable = ApplicationContext.getSemanticalModel() .isNameEditable((DbObject) obj, Explorer.class); else editable = ApplicationContext.getSemanticalModel() .isEditable(editableMetaField, (DbObject) obj, Explorer.class); db.commitTrans(); } } catch (DbException ex) { org.modelsphere.jack.util.ExceptionHandler.processUncatchedException( ApplicationContext.getDefaultMainFrame(), ex); editable = false; } if (!editable) return; } else { return; } DbObject semObj = (DbObject) obj; try { MetaField editableMetaField = getEditableMetaField(semObj); String transName = (editableMetaField == null ? LocaleMgr.action.getString("rename") : MessageFormat.format(kUpdate0, new Object[] {editableMetaField.getGUIName()})); semObj.getDb().beginTrans(Db.WRITE_TRANS, transName); if (editableMetaField == null) { if (semObj.getTransStatus() == Db.OBJ_REMOVED) return; semObj.setName((String) newValue); } else semObj.set(editableMetaField, (String) newValue); semObj.getDb().commitTrans(); nodeChanged(node); // in case it is a secondary node (only the // primary node is updated by the refresh // listener). } catch (Exception ex) { org.modelsphere.jack.util.ExceptionHandler.processUncatchedException( ApplicationContext.getDefaultMainFrame(), ex); } }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View v = inflater.inflate(R.layout.tab_fragment7, container, false); ImageView emptyimg = (ImageView) v.findViewById(R.id.imageView10); int vid = values.plan_day_id; int vtab = values.tab_number; int vday = values.plan_day_num; ListView ag = (ListView) v.findViewById(R.id.listView4); final Db k = new Db(v.getContext()); final String g[], z[], q[]; g = k.getAll11(vid, 7); z = k.getAll12(vid, 7); q = k.getAll13(vid, 7); Log.e("----->>" + String.valueOf(vid), "tab7 id"); Log.e("----->>" + String.valueOf(vtab), "tab7 tab num"); ArrayList<HashMap<String, String>> get; get = new ArrayList<>(); if (g.length != 0) { for (int i = 0; i < g.length; i++) { HashMap<String, String> get2 = new HashMap<>(); get2.put("y", g[i]); get2.put("s", z[i]); get2.put("w", q[i]); get.add(get2); } ListAdapter liasatp = new SimpleAdapter( v.getContext(), get, R.layout.listview_day, new String[] {"y", "s", "w"}, new int[] {R.id.time_start, R.id.time_end, R.id.day_command}); ag.setAdapter(liasatp); Log.e("Empty", "Listview NOT is empty"); emptyimg.setVisibility(View.INVISIBLE); ag.setVisibility(View.VISIBLE); } else { Log.e("Empty", "Listview is empty"); emptyimg.setVisibility(View.VISIBLE); ag.setVisibility(View.INVISIBLE); } return v; }
public static int runMaintenance() throws ServiceException { if (!(Db.getInstance() instanceof MySQL)) { ZimbraLog.mailbox.warn("Table maintenance only supported for MySQL."); return 0; } int numTables = 0; DbResults results = DbUtil.executeQuery( "SELECT table_schema, table_name " + "FROM INFORMATION_SCHEMA.TABLES " + "WHERE table_schema = 'zimbra' " + "OR table_schema LIKE '" + DbMailbox.DB_PREFIX_MAILBOX_GROUP + "%'"); while (results.next()) { String dbName = results.getString("TABLE_SCHEMA"); String tableName = results.getString("TABLE_NAME"); String sql = String.format("ANALYZE TABLE %s.%s", dbName, tableName); ZimbraLog.mailbox.info("Running %s", sql); DbUtil.executeUpdate(sql); numTables++; } return numTables; }
/** * Returns all user defined functions (aggregate and scalar) in the specified database. Functions * are not returned in a defined order. */ public List<Function> getFunctions(String dbName) throws DatabaseNotFoundException { Db db = getDb(dbName); if (db == null) { throw new DatabaseNotFoundException("Database does not exist: " + dbName); } // Contains map of overloaded function names to all functions matching that name. HashMap<String, List<Function>> dbFns = db.getAllFunctions(); List<Function> fns = new ArrayList<Function>(dbFns.size()); for (List<Function> fnOverloads : dbFns.values()) { for (Function fn : fnOverloads) { fns.add(fn); } } return fns; }
protected final void loadChildren(DynamicNode node) throws DbException { if (node.hasLoaded() || node.isLeaf()) return; node.setHasLoaded(); Object userObject = node.getUserObject(); if (userObject == ROOT) return; SrVector children = new SrVector(10); boolean isSorted = true; DbObject dbParent = null; if (userObject == DB_RAM) { Db[] dbs = Db.getDbs(); for (int i = 0; i < dbs.length; i++) { if (dbs[i] instanceof DbRAM) insertProjects(children, dbs[i]); } } else if (userObject instanceof Db) { insertProjects(children, (Db) userObject); } else { dbParent = (DbObject) userObject; dbParent.getDb().beginTrans(Db.READ_TRANS); insertComponents(children, dbParent); isSorted = childrenAreSorted(dbParent); dbParent.getDb().commitTrans(); } if (isSorted) { children.sort(getComparator(dbParent)); } ArrayList groupNodeList = new ArrayList(); DynamicNode groupNode = null; Enumeration enumeration = children.elements(); while (enumeration.hasMoreElements()) { DynamicNode childNode = (DynamicNode) enumeration.nextElement(); GroupParams group = childNode.getGroupParams(); if (group.name == null) { node.add(childNode); } else { if (groupNode == null) { groupNode = createGroupNode(group); node.add(groupNode); groupNodeList.add(groupNode); } else if (!groupNode.toString().equals(group.name)) { boolean groupFound = false; for (int i = 0; i < groupNodeList.size(); i++) { groupNode = (DynamicNode) groupNodeList.get(i); if (groupNode.toString().equals(group.name)) { groupFound = true; break; } } if (!groupFound) { groupNode = createGroupNode(group); node.add(groupNode); groupNodeList.add(groupNode); } } groupNode.add(childNode); } } groupNodeList.clear(); }
/** * If CS application, create a root node with 2 subnodes: RAM and repository; the RAM subnode * contains the list of RAM projects as subnodes. If RAM application, create a root node with the * list of projects as subnodes. */ private DynamicNode createRootNode() { DynamicNode rootNode = null; DynamicNode RAMNode = null; try { RAMNode = new DynamicNode(DB_RAM); RAMNode.setDisplayText(DbRAM.DISPLAY_NAME); RAMNode.setIcon(kLocalIcon); loadChildren(RAMNode); Db[] dbs = Db.getDbs(); for (int i = 0; i < dbs.length; i++) { if (dbs[i] instanceof DbRAM) continue; if (rootNode == null) { rootNode = new DynamicNode(ROOT); rootNode.setHasLoaded(); rootNode.add(RAMNode); } DynamicNode dbNode = new DynamicNode(dbs[i]); dbNode.setDisplayText(dbs[i].getDBMSName()); dbNode.setIcon(kRepositoryIcon); rootNode.add(dbNode); loadChildren(dbNode); } } catch (DbException ex) { org.modelsphere.jack.util.ExceptionHandler.processUncatchedException( ApplicationContext.getDefaultMainFrame(), ex); } return (rootNode != null ? rootNode : RAMNode); }
public void test() throws Exception { new Plant(); try { Path dbPath = Paths.get("vcow.db"); Files.deleteIfExists(dbPath); int maxRootBlockSize = 1000; try (Db db = new Db(new BaseRegistry(), dbPath, maxRootBlockSize)) { Files.deleteIfExists(dbPath); db.registerTransaction("SecondaryTran", SecondaryTran.class); db.open(true); String timestampId = db.update("SecondaryTran").call(); } } finally { Plant.close(); } }
/** Adds the partition to its HdfsTable. Returns the table with an updated catalog version. */ public Table addPartition(HdfsPartition partition) throws CatalogException { Preconditions.checkNotNull(partition); HdfsTable hdfsTable = partition.getTable(); Db db = getDb(hdfsTable.getDb().getName()); // Locking the catalog here because this accesses the hdfsTable's partition list and // updates its catalog version. // TODO: Fix this locking pattern. catalogLock_.writeLock().lock(); try { hdfsTable.addPartition(partition); hdfsTable.setCatalogVersion(incrementAndGetCatalogVersion()); db.addTable(hdfsTable); } finally { catalogLock_.writeLock().unlock(); } return hdfsTable; }
@Override public void onResume() { super.onResume(); Log.i("onResume", "onResume"); ImageView emptyimg = (ImageView) getActivity().findViewById(R.id.imageView10); int vid = values.plan_day_id; int vtab = values.tab_number; int vday = values.plan_day_num; ListView ag = (ListView) getActivity().findViewById(R.id.listView8); final Db k = new Db(getActivity().getApplicationContext()); final String g[], z[], q[]; g = k.getAll11(vid, 7); z = k.getAll12(vid, 7); q = k.getAll13(vid, 7); Log.e("----->>" + String.valueOf(vid), "tab7 id"); Log.e("----->>" + String.valueOf(vtab), "tab7 tab num"); ArrayList<HashMap<String, String>> get; get = new ArrayList<>(); if (g.length != 0) { for (int i = 0; i < g.length; i++) { HashMap<String, String> get2 = new HashMap<>(); get2.put("y", g[i]); get2.put("s", z[i]); get2.put("w", q[i]); get.add(get2); } ListAdapter liasatp = new SimpleAdapter( getActivity().getApplicationContext(), get, R.layout.listview_day, new String[] {"y", "s", "w"}, new int[] {R.id.time_start, R.id.time_end, R.id.day_command}); ag.setAdapter(liasatp); Log.e("Empty", "Listview NOT is empty"); emptyimg.setVisibility(View.INVISIBLE); ag.setVisibility(View.VISIBLE); } else { Log.e("Empty", "Listview is empty"); emptyimg.setVisibility(View.VISIBLE); ag.setVisibility(View.INVISIBLE); } }
/** * Set up a table replicator from the minimum. * * <p>Generates its own result set and metadata * * <p>Will either fetch the primary key from the source or generate an arbitrary primary key. * * @param tableName target table * @param srcdB source db * @param destDb dest db * @return the new instance ready to rock and roll * @throws SQLException */ public static TableReplicator newTableReplicator(Db srcdB, Db destDb, String tableName) throws SQLException { ResultSet rs = srcdB.selectStarFrom( tableName, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSetMetaData rsmd = rs.getMetaData(); TableReplicator tr = new TableReplicator(srcdB, rs, rsmd, destDb, tableName); return tr; }
public Coll( String name, Class<E> entityClass, Db db, Plugin plugin, boolean lazy, boolean creative, boolean lowercasing, Comparator<? super String> idComparator, Comparator<? super E> entityComparator) { // Setup the name and the parsed parts this.name = name; String[] nameParts = this.name.split("\\@"); this.basename = nameParts[0]; if (nameParts.length > 1) { this.universe = nameParts[1]; } else { this.universe = null; } // WHAT DO WE HANDLE? this.entityClass = entityClass; this.lazy = lazy; this.creative = creative; this.lowercasing = lowercasing; // SUPPORTING SYSTEM this.plugin = plugin; this.db = db; this.collDriverObject = db.getCollDriverObject(this); // STORAGE this.ids = new ConcurrentSkipListSet<String>(idComparator); this.id2entity = new ConcurrentSkipListMap<String, E>(idComparator); this.entity2id = new ConcurrentSkipListMap<E, String>(entityComparator); // IDENTIFIED CHANGES this.localAttachIds = new ConcurrentSkipListSet<String>(idComparator); this.localDetachIds = new ConcurrentSkipListSet<String>(idComparator); this.changedIds = new ConcurrentSkipListSet<String>(idComparator); // SYNCLOG this.lastMtime = new ConcurrentSkipListMap<String, Long>(idComparator); this.lastRaw = new ConcurrentSkipListMap<String, JsonElement>(idComparator); this.lastDefault = new ConcurrentSkipListSet<String>(idComparator); final Coll<E> me = this; this.tickTask = new Runnable() { @Override public void run() { me.onTick(); } }; }
private void initPool() { PoolConfig pconfig = Db.getInstance().getPoolConfig(); int poolSize = Db.supports(Capability.ROW_LEVEL_LOCKING) ? pconfig.mPoolSize : 1; // if no row lock, we need serial access to the underlying db file // still need external synchronization for now since other connections to zimbra.db can occur // through DbPool mConnectionPool = new GenericObjectPool(null, poolSize, GenericObjectPool.WHEN_EXHAUSTED_BLOCK, -1, poolSize); ConnectionFactory cfac = ZimbraConnectionFactory.getConnectionFactory(pconfig); boolean defAutoCommit = false, defReadOnly = false; new PoolableConnectionFactory(cfac, mConnectionPool, null, null, defReadOnly, defAutoCommit); try { PoolingDataSource pds = new PoolingDataSource(mConnectionPool); pds.setAccessToUnderlyingConnectionAllowed(true); Db.getInstance().startup(pds, pconfig.mPoolSize); mDataSource = pds; } catch (SQLException e) { ZimbraLog.system.error("failed to initialize offline db pool", e); } }
public Explorer() { super(new DynamicNode(ROOT)); PropertiesSet preferences = PropertiesManager.getPreferencePropertiesSet(); if (preferences != null) { preferences.addPrefixPropertyChangeListener( DisplayToolTipsOptionGroup.class, DisplayToolTipsOptionGroup.TOOLTIPS_FIELD_VISIBILITY_PREFIX, new PreferencesListener()); Db.addDbListener(dbslistener); tooltipsFields.addAll(Arrays.asList(DisplayToolTipsOptionGroup.getAvailableMetaFields())); } }