Search in sources :

Example 1 with Version

use of org.osgi.framework.Version in project dbeaver by serge-rider.

the class FireBirdUtils method getViewSourceWithHeader.

public static String getViewSourceWithHeader(DBRProgressMonitor monitor, GenericTable view, String source) throws DBException {
    Version version = getFireBirdServerVersion(view.getDataSource());
    StringBuilder sql = new StringBuilder();
    sql.append("CREATE ");
    if (version.getMajor() > 2 || (version.getMajor() == 2 && version.getMinor() >= 5)) {
        sql.append("OR ALTER ");
    }
    sql.append("VIEW ").append(view.getName()).append(" ");
    Collection<GenericTableColumn> columns = view.getAttributes(monitor);
    if (columns != null) {
        sql.append("(");
        boolean first = true;
        for (GenericTableColumn column : columns) {
            if (!first) {
                sql.append(", ");
            }
            first = false;
            sql.append(DBUtils.getQuotedIdentifier(column));
        }
        sql.append(")\n");
    }
    sql.append("AS\n").append(source);
    return sql.toString();
}
Also used : Version(org.osgi.framework.Version)

Example 2 with Version

use of org.osgi.framework.Version in project dbeaver by serge-rider.

the class FireBirdUtils method getFireBirdServerVersion.

public static Version getFireBirdServerVersion(DBPDataSource dataSource) {
    String versionInfo = dataSource.getInfo().getDatabaseProductVersion();
    Matcher matcher = VERSION_PATTERN.matcher(versionInfo);
    if (matcher.matches()) {
        return new Version(matcher.group(1));
    }
    return new Version(0, 0, 0);
}
Also used : Matcher(java.util.regex.Matcher) Version(org.osgi.framework.Version)

Example 3 with Version

use of org.osgi.framework.Version in project tesb-studio-se by Talend.

the class DependencyVersionPart method getVersion.

/**
	 * Gets the version.
	 * 
	 * @return the version
	 */
public String getVersion() {
    if (fIsRanged) {
        // if versions are equal they must be inclusive for a range to be
        // valid
        // blindly set for the user
        String minV = getMinVersion();
        String maxV = getMaxVersion();
        boolean minI = getMinInclusive();
        boolean maxI = getMaxInclusive();
        if (minV.equals(maxV))
            minI = maxI = true;
        VersionRange versionRange = new VersionRange(new Version(minV), minI, new Version(maxV), maxI);
        if (!versionRange.equals(VersionRange.emptyRange)) {
            return versionRange.toString();
        }
    } else {
        String singleversion = extractSingleVersionFromText();
        if (!singleversion.isEmpty()) {
            Version versionBean = new Version(singleversion);
            if (!versionBean.equals(Version.emptyVersion)) {
                return versionBean.toString();
            }
        }
    }
    return null;
}
Also used : Version(org.osgi.framework.Version) VersionRange(org.eclipse.osgi.service.resolver.VersionRange)

Example 4 with Version

use of org.osgi.framework.Version in project EnrichmentMapApp by BaderLab.

the class Em21Handler method isEM21Installed.

private static boolean isEM21Installed(BundleContext bc) {
    for (Bundle bundle : bc.getBundles()) {
        String name = bundle.getSymbolicName();
        Version version = bundle.getVersion();
        if (name.equals("org.baderlab.csplugins.enrichmentmap") && version.equals(new Version(2, 1, 0))) {
            return true;
        }
    }
    return false;
}
Also used : Version(org.osgi.framework.Version) Bundle(org.osgi.framework.Bundle)

Example 5 with Version

use of org.osgi.framework.Version in project aries by apache.

the class ApplicationMetadataImpl method setup.

/**
   * setup the application metadata from the appManifest
   * @param appManifest     application.mf manifest
   */
private void setup(Manifest appManifest) {
    Map<String, String> appMap = readManifestIntoMap(appManifest);
    // configure the appSymbolicName and appVersion
    this.appSymbolicName = appMap.get(AppConstants.APPLICATION_SYMBOLIC_NAME);
    this.appVersion = new Version(appMap.get(AppConstants.APPLICATION_VERSION));
    this.appName = appMap.get(AppConstants.APPLICATION_NAME);
    this.appScope = this.appSymbolicName + "_" + this.appVersion.toString();
    if (this.appSymbolicName == null || this.appVersion == null) {
        throw new IllegalArgumentException("Failed to create ApplicationMetadataImpl object from Manifest " + appManifest);
    }
    // configure appContents
    // use parseImportString as we don't allow appContents to be duplicate
    String applicationContents = appMap.get(AppConstants.APPLICATION_CONTENT);
    Map<String, Map<String, String>> appContentsMap = ManifestHeaderProcessor.parseImportString(applicationContents);
    for (Map.Entry<String, Map<String, String>> e : appContentsMap.entrySet()) {
        this.appContents.add(new ContentImpl(e.getKey(), e.getValue()));
    }
    String useBundleStr = appMap.get(AppConstants.APPLICATION_USE_BUNDLE);
    if (useBundleStr != null) {
        Map<String, Map<String, String>> useBundleMap = ManifestHeaderProcessor.parseImportString(useBundleStr);
        for (Map.Entry<String, Map<String, String>> e : useBundleMap.entrySet()) {
            this.useBundle.add(new ContentImpl(e.getKey(), e.getValue()));
        }
    }
    String allServiceImports = appMap.get(AppConstants.APPLICATION_IMPORT_SERVICE);
    List<String> serviceImports = ManifestHeaderProcessor.split(allServiceImports, ",");
    for (String s : serviceImports) {
        try {
            ServiceDeclaration dec = new ServiceDeclarationImpl(s);
            importServices.add(dec);
        } catch (InvalidSyntaxException ise) {
            _logger.warn("APPUTILS0013E", new Object[] { s, appSymbolicName });
        }
    }
    String allServiceExports = appMap.get(AppConstants.APPLICATION_EXPORT_SERVICE);
    List<String> serviceExports = ManifestHeaderProcessor.split(allServiceExports, ",");
    for (String s : serviceExports) {
        try {
            ServiceDeclaration dec = new ServiceDeclarationImpl(s);
            exportServices.add(dec);
        } catch (InvalidSyntaxException ise) {
            _logger.warn("APPUTILS0014E", new Object[] { s, appSymbolicName });
        }
    }
}
Also used : ServiceDeclaration(org.apache.aries.application.ServiceDeclaration) Version(org.osgi.framework.Version) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Version (org.osgi.framework.Version)165 Test (org.junit.Test)30 Bundle (org.osgi.framework.Bundle)26 ArrayList (java.util.ArrayList)22 Capability (org.osgi.resource.Capability)19 File (java.io.File)17 HashMap (java.util.HashMap)16 Resource (org.osgi.resource.Resource)14 IOException (java.io.IOException)13 InputStream (java.io.InputStream)11 Manifest (java.util.jar.Manifest)11 Map (java.util.Map)9 HashSet (java.util.HashSet)8 Content (org.apache.aries.application.Content)8 AriesApplication (org.apache.aries.application.management.AriesApplication)8 VersionRange (org.apache.felix.utils.version.VersionRange)8 BundleRevision (org.osgi.framework.wiring.BundleRevision)8 List (java.util.List)7 BundleWiring (org.osgi.framework.wiring.BundleWiring)7 ResourceBuilder (aQute.bnd.osgi.resource.ResourceBuilder)6