Skip to content

Commit

Permalink
TEIIDDES-1941: Stop unreleased server versions being targeted by default
Browse files Browse the repository at this point in the history
* The value of the 'default server version' is derived from the servers
  configured then a set preference and finally an algorithm based on
  runtime plugins installed.

* The latter algorithm simply found the highest version that the installed
  runtimes were compatible with and displayed returned accordingly. However,
  the introduction of adding in unreleased teiid versions has meant the
  display of versions like 8.9.x which looks silly to the user.

* Algorithm modified to only display the highest version compatible if
  less than or equal to the last tested version, ie. 8.4.x. The user is
  free to set it higher if they wish but at that point they should know
  what they are doing!!
  • Loading branch information
Paul Richardson committed Nov 27, 2013
1 parent c1d6fdc commit 8ed9286
Showing 1 changed file with 63 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,25 +118,33 @@ else if(tokens.length == 2) {
* @return {@link ITeiidServerVersion} default version
*/
public static ITeiidServerVersion deriveUltimateDefaultServerVersion() {
ITeiidServerVersion lastGaspDefault = TeiidServerVersion.DEFAULT_TEIID_SERVER;
ITeiidServerVersion lastTestedDefault = TeiidServerVersion.DEFAULT_TEIID_SERVER;

Collection<ITeiidServerVersion> serverVersions = null;
try {
serverVersions = TeiidRuntimeRegistry.getInstance().getRegisteredServerVersions();
} catch (Exception ex) {
DesignerSPIPlugin.log(ex);
return lastGaspDefault;
return lastTestedDefault;
}

if (serverVersions == null || serverVersions.isEmpty())
return lastGaspDefault;
return lastTestedDefault;

if (serverVersions.size() == 1)
return serverVersions.iterator().next();

// Find the latest server version by sorting the registered client runtime versions
List<String> items = new ArrayList<String>(serverVersions.size());
for (ITeiidServerVersion serverVersion : serverVersions) {
/*
* Do not offer unreleased and untested versions by default.
* Does not stop the user choosing such versions but avoids
* displaying them up-front.
*/
if (serverVersion.isGreaterThan(lastTestedDefault))
continue;

items.add(serverVersion.toString());
}
Collections.sort(items, Collections.reverseOrder());
Expand Down Expand Up @@ -226,47 +234,63 @@ public boolean isSevenServer() {

@Override
public boolean isGreaterThan(ITeiidServerVersion otherVersion) {
int myMajor = Integer.parseInt(getMajor());
int otherMajor = Integer.parseInt(otherVersion.getMajor());
if (myMajor < otherMajor)
return false;

if (hasWildCards() || otherVersion.hasWildCards())
return false;

int myMinor = Integer.parseInt(getMinor());
int otherMinor = Integer.parseInt(otherVersion.getMinor());
if (myMinor < otherMinor)
return false;

int myMicro = Integer.parseInt(getMicro());
int otherMicro = Integer.parseInt(otherVersion.getMicro());
if (myMicro < otherMicro)
return false;
try {
int myMajor = Integer.parseInt(getMajor());
int otherMajor = Integer.parseInt(otherVersion.getMajor());
if (myMajor > otherMajor)
return true;

if (getMinor().equals(WILDCARD) || otherVersion.getMinor().equals(WILDCARD))
return false;

int myMinor = Integer.parseInt(getMinor());
int otherMinor = Integer.parseInt(otherVersion.getMinor());
if (myMinor > otherMinor)
return true;

if (getMicro().equals(WILDCARD) || otherVersion.getMicro().equals(WILDCARD))
return false;

int myMicro = Integer.parseInt(getMicro());
int otherMicro = Integer.parseInt(otherVersion.getMicro());
if (myMicro > otherMicro)
return true;
}
catch (Exception ex) {
DesignerSPIPlugin.log(ex);
}

return true;
return false;
}

@Override
public boolean isLessThan(ITeiidServerVersion otherVersion) {
int myMajor = Integer.parseInt(getMajor());
int otherMajor = Integer.parseInt(otherVersion.getMajor());
if (myMajor > otherMajor)
return false;

if (hasWildCards() || otherVersion.hasWildCards())
return false;

int myMinor = Integer.parseInt(getMinor());
int otherMinor = Integer.parseInt(otherVersion.getMinor());
if (myMinor > otherMinor)
return false;

int myMicro = Integer.parseInt(getMicro());
int otherMicro = Integer.parseInt(otherVersion.getMicro());
if (myMicro > otherMicro)
return false;
try {
int myMajor = Integer.parseInt(getMajor());
int otherMajor = Integer.parseInt(otherVersion.getMajor());
if (myMajor < otherMajor)
return true;

if (getMinor().equals(WILDCARD) || otherVersion.getMinor().equals(WILDCARD))
return false;

int myMinor = Integer.parseInt(getMinor());
int otherMinor = Integer.parseInt(otherVersion.getMinor());
if (myMinor < otherMinor)
return true;

if (getMicro().equals(WILDCARD) || otherVersion.getMicro().equals(WILDCARD))
return false;

int myMicro = Integer.parseInt(getMicro());
int otherMicro = Integer.parseInt(otherVersion.getMicro());
if (myMicro < otherMicro)
return true;
}
catch (Exception ex) {
DesignerSPIPlugin.log(ex);
}

return true;
return false;
}
}

0 comments on commit 8ed9286

Please sign in to comment.