Insert a new Bundle into the Database.

@return ID of the new Bundle
559141
private Instance insertNewBundle()
    {
        Instance ret = null;
        try {
            final Insert insert = new Insert(DBPropertiesUpdate.TYPE_PROPERTIES_BUNDLE);
            insert.add("Name", this.bundlename);
            insert.add("UUID", this.bundeluuid);
            insert.add("Sequence", this.bundlesequence);
            insert.add("CacheOnStart", this.cacheOnStart);
            insert.executeWithoutAccessCheck();
            ret = insert.getInstance();
            insert.close();
        } catch (final EFapsException e) {
            DBPropertiesUpdate.LOG.error("insertNewBundle()", e);
        }
        return ret;
    }
76808
public function init()
    {

        // initialize the prepared statements
        $this->bundleOptionStmt =
            $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::BUNDLE_OPTION));
    }
138866
public void start(BundleContext context) throws Exception {
    	Util.getLogger().info("Starting Jdbc bundle");
        
        //xthis.setProperty(BundleActivatorModel.PACKAGE_NAME, Util.getPackageName(JdbcDatabase.class.getName()));
        //x this.setProperty(BundleService.INTERFACE, BaseDatabase.class.getName());
        this.setProperty(BundleConstants.TYPE, DBParams.JDBC);
        
        super.start(context);
    }
1080961
public function bundle()
    {
        $bundle = new Bundle();
        $this->bundleBins($bundle);

        $autoload = $this->package->getAutoload();
        $this->bundlePsr0($bundle, $autoload);
        $this->bundleClassmap($bundle, $autoload);
        $this->bundleFiles($bundle, $autoload);

        return $bundle;
    }
596044
def get_bundle_by_id(self, bundle_id):
        # type: (int) -> Union[Bundle, Framework]
        
        if bundle_id == 0:
            # "System bundle"
            return self

        with self.__bundles_lock:
            if bundle_id not in self.__bundles:
                raise BundleException("Invalid bundle ID {0}".format(bundle_id))

            return self.__bundles[bundle_id]
556572
private String newStorageID() {
    String newID = null;
    while (newID == null) {
      newID = "DS" + Integer.toString(r.nextInt());
      if (datanodeMap.get(newID) != null) {
        newID = null;
      }
    }
    return newID;
  }
374098
private void putId() {
        // note: name and info may be null
        super.put("Provider.id name", String.valueOf(name));
        super.put("Provider.id version", String.valueOf(version));
        super.put("Provider.id info", String.valueOf(info));
        super.put("Provider.id className", this.getClass().getName());
    }
1204326
private function createEntitiesSchema(BundleInterface $bundle, $force = false)
    {
        if (!is_dir($entityDir = $this->getBundleEntityDir($bundle))) {
            return [];
        }

        $bundleEntityManager = $bundle->getEntityManager();
        $bundleEntityManager
            ->getConfiguration()
            ->getMetadataDriverImpl()
            ->addPaths([
                $entityDir,
            ])
        ;

        $metadata = $bundleEntityManager->getMetadataFactory()->getAllMetadata();
        $schemaTool = new SchemaTool($bundleEntityManager);
        $sqls = $schemaTool->getCreateSchemaSql($metadata);
        if (true === $force) {
            $schemaTool->createSchema($metadata);
        }

        return $sqls;
    }
1352413
@Override
	public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload)
			throws IllegalAccessException, InstantiationException, IOException {

		String bundleName = toBundleName(baseName, locale);
		ResourceBundle bundle = null;
		if (format.equals("java.class")) {
			try {
				@SuppressWarnings("unchecked")
				Class<? extends ResourceBundle> bundleClass = (Class<? extends ResourceBundle>) loader
						.loadClass(bundleName);

				// If the class isn't a ResourceBundle subclass, throw a
				// ClassCastException.
				if (ResourceBundle.class.isAssignableFrom(bundleClass)) {
					bundle = bundleClass.newInstance();
				} else {
					throw new ClassCastException(bundleClass.getName() + " cannot be cast to ResourceBundle");
				}
			} catch (ClassNotFoundException e) {
			}
		} else if (format.equals("java.properties")) {
			final String resourceName = toResourceName(bundleName, "properties");
			final ClassLoader classLoader = loader;
			final boolean reloadFlag = reload;
			InputStream stream = null;
			Reader rd = null;
			try {
				stream = AccessController.doPrivileged(new PrivilegedExceptionAction<InputStream>() {
					public InputStream run() throws IOException {
						InputStream is = null;
						if (reloadFlag) {
							URL url = classLoader.getResource(resourceName);
							if (url != null) {
								URLConnection connection = url.openConnection();
								if (connection != null) {
									// Disable caches to get fresh
									// data for
									// reloading.
									connection.setUseCaches(false);
									is = connection.getInputStream();
								}
							}
						} else {
							is = classLoader.getResourceAsStream(resourceName);
						}
						return is;
					}
				});
			} catch (PrivilegedActionException e) {
				throw (IOException) e.getException();
			}
			if (stream != null) {
				try {
					rd = new InputStreamReader(stream, charset);
					bundle = new PropertyResourceBundle(rd);
				} finally {
					IOUtils.close(rd);
					IOUtils.close(stream);
				}
			}
		} else {
			throw new IllegalArgumentException("unknown format: " + format);
		}
		return bundle;
	}
147339
function insert() {
		if ($this->id)
			return $this->update();
		$db=$this->db;
		$now=microtime(TRUE);
		while (($id=uniqid(NULL,TRUE)) &&
			($data=&$db->read($this->file)) && isset($data[$id]) &&
			!connection_aborted())
			usleep(mt_rand(0,100));
		$this->id=$id;
		$pkey=['_id'=>$this->id];
		if (isset($this->trigger['beforeinsert']) &&
			\Base::instance()->call($this->trigger['beforeinsert'],
				[$this,$pkey])===FALSE)
			return $this->document;
		$data[$id]=$this->document;
		$db->write($this->file,$data);
		$db->jot('('.sprintf('%.1f',1e3*(microtime(TRUE)-$now)).'ms) '.
			$this->file.' [insert] '.json_encode($this->document));
		if (isset($this->trigger['afterinsert']))
			\Base::instance()->call($this->trigger['afterinsert'],
				[$this,$pkey]);
		$this->load(['@_id=?',$this->id]);
		return $this->document;
	}
935231
public static String bundleToString(Bundle bundle) {
    if (bundle == null) {
      return "null";
    }

    StringBuilder b = new StringBuilder(128);
    b.append("Bundle[{");
    bundleToShortString(bundle, b);
    b.append("}]");
    return b.toString();
  }
1086257
public static SharedPreferencesItem newInstance(@NonNull Bundle bundle) {
		SharedPreferencesItem sharedPreferencesItem = new SharedPreferencesItem();
		sharedPreferencesItem.setArguments(bundle);
		return sharedPreferencesItem;
	}
1249014
static FacebookSettings newInstance(Bundle bundle) {
        FacebookSettings settings = null;

        int destinationId = bundle.getInt(BUNDLE_KEY_DESTINATION_ID);
        String accountName = bundle.getString(BUNDLE_KEY_ACCOUNT_NAME);
        String albumName = bundle.getString(BUNDLE_KEY_ALBUM_NAME);
        String albumGraphPath = bundle.getString(BUNDLE_KEY_ALBUM_GRAPH_PATH);
        String pageAccessToken = bundle.getString(BUNDLE_KEY_PAGE_ACCESS_TOKEN);
        String photoPrivacy = bundle.getString(BUNDLE_KEY_PHOTO_PRIVACY);

        if (!TextUtils.isEmpty(accountName) && !TextUtils.isEmpty(albumName) && !TextUtils.isEmpty(albumGraphPath)) {
            if (destinationId == FacebookEndpoint.DestinationId.PROFILE) {
                settings = new FacebookSettings(destinationId, accountName, albumName, albumGraphPath, pageAccessToken, photoPrivacy);
            } else if ((destinationId == FacebookEndpoint.DestinationId.PAGE || destinationId == FacebookEndpoint.DestinationId.PAGE_ALBUM)
                    && !TextUtils.isEmpty(pageAccessToken)) {
                settings = new FacebookSettings(destinationId, accountName, albumName, albumGraphPath, pageAccessToken, photoPrivacy);
            }
        }

        return settings;
    }
555178
@NonNull
    public static PutResult newInsertResult(
            long insertedId,
            @NonNull Set<String> affectedTables,
            @Nullable String... affectedTags
    ) {
        return newInsertResult(insertedId, affectedTables, nonNullSet(affectedTags));
    }
1097401
private function insert() {
        if ($this->isPersistent()) throw new RuntimeException('Cannot insert already persistent '.$this);

        // pre-processing hook
        if ($this->beforeInsert() !== true)
            return $this;

        $mapping = $this->dao()->getMapping();

        // collect column values
        $values = [];
        foreach ($mapping['columns'] as $column => $property) {
            $values[$column] = $this->getPhysicalValue($column);
        };

        // perform insertion
        $id = $this->doInsert($values);
        $this->_modified = false;

        // assign the returned identity value
        $idName = $mapping['identity']['name'];
        if ($this->$idName === null)
            $this->$idName = $id;

        // post-processing hook
        $this->afterInsert();
        return $this;
    }
1260141
public function insertId ($name = null)
		{
			if ($name === null) {
				return $this->database->lastInsertId();
			} else {
				return $this->database->lastInsertId($name);
			}
		}
913521
private Instance getExistingBundle(final String _uuid)
    {
        Instance ret = null;
        try {
            final QueryBuilder queryBldr = new QueryBuilder(Type.get(DBPropertiesUpdate.TYPE_PROPERTIES_BUNDLE));
            queryBldr.addWhereAttrEqValue("UUID", _uuid);
            final InstanceQuery query = queryBldr.getQuery();
            query.executeWithoutAccessCheck();
            if (query.next()) {
                ret = query.getCurrentValue();
            }
        } catch (final EFapsException e) {
            DBPropertiesUpdate.LOG.error("getExistingBundle(String)", e);
        }
        return ret;
    }