Java Code Examples for org.kie.api.builder.ReleaseId#getArtifactId()

The following examples show how to use org.kie.api.builder.ReleaseId#getArtifactId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KieRepositoryImpl.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
synchronized KieModule remove(ReleaseId releaseId) {
    KieModule removedKieModule = null;
    String ga = releaseId.getGroupId() + ":" + releaseId.getArtifactId();
    ComparableVersion comparableVersion = new ComparableVersion(releaseId.getVersion());

    NavigableMap<ComparableVersion, KieModule> artifactMap = kieModules.get(ga);
    if (artifactMap != null) {
        removedKieModule = artifactMap.remove(comparableVersion);
        if (artifactMap.isEmpty()) {
            kieModules.remove(ga);
        }
        oldKieModules.remove(releaseId);
    }

    return removedKieModule;
}
 
Example 2
Source File: KieRepositoryImpl.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
synchronized void store(KieModule kieModule) {
    ReleaseId releaseId = kieModule.getReleaseId();
    String ga = releaseId.getGroupId() + ":" + releaseId.getArtifactId();
    ComparableVersion comparableVersion = new ComparableVersion(releaseId.getVersion());

    NavigableMap<ComparableVersion, KieModule> artifactMap = kieModules.get(ga);
    if( artifactMap == null ) {
        artifactMap = createNewArtifactMap();
        kieModules.put(ga, artifactMap);
    }

    KieModule oldReleaseIdKieModule = oldKieModules.get(releaseId);
    // variable used in order to test race condition
    if (oldReleaseIdKieModule == null) {
        KieModule oldKieModule = artifactMap.get(comparableVersion);
        if (oldKieModule != null) {
            oldKieModules.put( releaseId, oldKieModule );
        }
    }
    artifactMap.put( comparableVersion, kieModule );
}
 
Example 3
Source File: ReleaseIdImpl.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
public static ReleaseId adapt(ReleaseId r ) {
    if (r instanceof ReleaseId) {
        return ( ReleaseId ) r;
    }
    final ReleaseIdImpl newReleaseIdImpl = new ReleaseIdImpl(r.getGroupId(), r.getArtifactId(), r.getVersion(), ((ReleaseIdImpl) r).getType());
    if (r.isSnapshot()) {
        newReleaseIdImpl.setSnapshotVersion(r.getVersion());
    }
    return newReleaseIdImpl;
}
 
Example 4
Source File: KieFileSystemScannerTest.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
private File write( InternalKieModule kModule, Path tempDir, ReleaseId releaseId) {
    String fileName = releaseId.getArtifactId() + "-" + releaseId.getVersion() + ".jar";
    File file = new File(tempDir.toString(), fileName);
    try (FileOutputStream fos = new FileOutputStream(file)) {
        fos.write(kModule.getBytes());
        fos.flush();
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
    return file;
}
 
Example 5
Source File: KieFileSystemScannerTest.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
private String getPom(ReleaseId releaseId, ReleaseId... dependencies) {
    return
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
        "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
        "         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n" +
        "  <modelVersion>4.0.0</modelVersion>\n" +
        "\n" +
        "  <groupId>" + releaseId.getGroupId() + "</groupId>\n" +
        "  <artifactId>" + releaseId.getArtifactId() + "</artifactId>\n" +
        "  <version>" + releaseId.getVersion() + "</version>\n" +
        "\n" +
        "</project>";
}
 
Example 6
Source File: GAV.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
public static GAV from(ReleaseId rel) {
    return new GAV(rel.getGroupId(),
                             rel.getArtifactId(),
                             rel.getVersion());
}
 
Example 7
Source File: KieRepositoryImpl.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
synchronized KieModule load(InternalKieScanner kieScanner, ReleaseId releaseId, VersionRange versionRange) {
    String ga = releaseId.getGroupId() + ":" + releaseId.getArtifactId();

    NavigableMap<ComparableVersion, KieModule> artifactMap = kieModules.get(ga);
    if ( artifactMap == null || artifactMap.isEmpty() ) {
        return null;
    }
    KieModule kieModule = artifactMap.get(new ComparableVersion(releaseId.getVersion()));

    if (versionRange.fixed) {
        if ( kieModule != null && releaseId.isSnapshot() ) {
            String oldSnapshotVersion = ((ReleaseIdImpl)kieModule.getReleaseId()).getSnapshotVersion();
            if ( oldSnapshotVersion != null ) {
                String currentSnapshotVersion = kieScanner.getArtifactVersion(releaseId);
                if (currentSnapshotVersion != null &&
                    new ComparableVersion(currentSnapshotVersion).compareTo(new ComparableVersion(oldSnapshotVersion)) > 0) {
                    // if the snapshot currently available on the maven repo is newer than the cached one
                    // return null to enforce the building of this newer version
                    return null;
                }
            }
        }
        return kieModule;
    }

    Map.Entry<ComparableVersion, KieModule> entry =
            versionRange.upperBound == null ?
            artifactMap.lastEntry() :
            versionRange.upperInclusive ?
                artifactMap.floorEntry(new ComparableVersion(versionRange.upperBound)) :
                artifactMap.lowerEntry(new ComparableVersion(versionRange.upperBound));

    if ( entry == null ) {
        return null;
    }

    if ( versionRange.lowerBound == null ) {
        return entry.getValue();
    }

    int comparison = entry.getKey().compareTo(new ComparableVersion(versionRange.lowerBound));
    return comparison > 0 || (comparison == 0 && versionRange.lowerInclusive) ? entry.getValue() : null;
}
 
Example 8
Source File: ReleaseIdImpl.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
public static String getPomXmlPath(ReleaseId releaseId) {
    return "META-INF/maven/" + releaseId.getGroupId() + "/" + releaseId.getArtifactId() + "/pom.xml";
}
 
Example 9
Source File: ReleaseIdImpl.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
public static String getPomPropertiesPath(ReleaseId releaseId) {
    return "META-INF/maven/" + releaseId.getGroupId() + "/" + releaseId.getArtifactId() + "/pom.properties";
}