-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[442] Add support for GenQuery2 API.
- Loading branch information
1 parent
ae2c8e9
commit 6a042b5
Showing
5 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
jargon-core/src/main/java/org/irods/jargon/core/packinstr/Genquery2Input.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package org.irods.jargon.core.packinstr; | ||
|
||
import org.irods.jargon.core.exception.JargonException; | ||
|
||
public class Genquery2Input extends AbstractIRODSPackingInstruction { | ||
|
||
public static final String PI_TAG = "Genquery2Input_PI"; | ||
|
||
public static final int GENQUERY2_API_NBR = 10221; | ||
|
||
private String queryString = ""; | ||
private String zone = ""; | ||
private int sqlOnly = 0; | ||
private int columnMappings = 0; | ||
|
||
public static Genquery2Input instance(final String queryString, final String zone) { | ||
Genquery2Input input = new Genquery2Input(); | ||
input.setApiNumber(GENQUERY2_API_NBR); | ||
input.queryString = queryString; | ||
input.zone = zone; | ||
return input; | ||
} | ||
|
||
public static Genquery2Input instanceForSqlOnly(final String queryString, final String zone) { | ||
Genquery2Input input = new Genquery2Input(); | ||
input.setApiNumber(GENQUERY2_API_NBR); | ||
input.queryString = queryString; | ||
input.zone = zone; | ||
input.sqlOnly = 1; | ||
return input; | ||
} | ||
|
||
public static Genquery2Input instanceForColumnMappings() { | ||
Genquery2Input input = new Genquery2Input(); | ||
input.setApiNumber(GENQUERY2_API_NBR); | ||
input.columnMappings = 1; | ||
return input; | ||
} | ||
|
||
public String getQueryString() { | ||
return queryString; | ||
} | ||
|
||
public String getZone() { | ||
return zone; | ||
} | ||
|
||
public int getSqlOnlyValue() { | ||
return sqlOnly; | ||
} | ||
|
||
public int getColumnMappingsValue() { | ||
return columnMappings; | ||
} | ||
|
||
@Override | ||
public Tag getTagValue() throws JargonException { | ||
return new Tag(PI_TAG, new Tag[] { | ||
new Tag("query_string", getQueryString()), | ||
new Tag("zone", getZone()), | ||
new Tag("sql_only", getSqlOnlyValue()), | ||
new Tag("column_mappings", getColumnMappingsValue()) | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
jargon-core/src/main/java/org/irods/jargon/core/pub/IRODSGenquery2Executor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.irods.jargon.core.pub; | ||
|
||
import org.irods.jargon.core.exception.JargonException; | ||
|
||
public interface IRODSGenquery2Executor extends IRODSAccessObject { | ||
|
||
String execute(final String queryString) throws JargonException; | ||
|
||
String execute(final String queryString, final String zone) throws JargonException; | ||
|
||
String getGeneratedSQL(final String queryString) throws JargonException; | ||
|
||
String getGeneratedSQL(final String queryString, final String zone) throws JargonException; | ||
|
||
String getColumnMappings() throws JargonException; | ||
|
||
} |
61 changes: 61 additions & 0 deletions
61
jargon-core/src/main/java/org/irods/jargon/core/pub/IRODSGenquery2ExecutorImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.irods.jargon.core.pub; | ||
|
||
import org.irods.jargon.core.connection.IRODSAccount; | ||
import org.irods.jargon.core.connection.IRODSSession; | ||
import org.irods.jargon.core.exception.JargonException; | ||
import org.irods.jargon.core.packinstr.Genquery2Input; | ||
import org.irods.jargon.core.packinstr.Tag; | ||
|
||
public class IRODSGenquery2ExecutorImpl extends IRODSGenericAO implements IRODSGenquery2Executor { | ||
|
||
public IRODSGenquery2ExecutorImpl(IRODSSession irodsSession, IRODSAccount irodsAccount) throws JargonException { | ||
super(irodsSession, irodsAccount); | ||
} | ||
|
||
@Override | ||
public String execute(String queryString) throws JargonException { | ||
return execute(queryString, getIRODSAccount().getZone()); | ||
} | ||
|
||
@Override | ||
public String execute(String queryString, String zone) throws JargonException { | ||
final Genquery2Input input = Genquery2Input.instance(queryString, zone); | ||
final Tag tag = getIRODSProtocol().irodsFunction(input); | ||
|
||
if (null == tag) { | ||
return null; | ||
} | ||
|
||
return tag.getTag("myStr").getStringValue(); | ||
} | ||
|
||
@Override | ||
public String getGeneratedSQL(String queryString) throws JargonException { | ||
return getGeneratedSQL(queryString, getIRODSAccount().getZone()); | ||
} | ||
|
||
@Override | ||
public String getGeneratedSQL(String queryString, String zone) throws JargonException { | ||
final Genquery2Input input = Genquery2Input.instanceForSqlOnly(queryString, zone); | ||
final Tag tag = getIRODSProtocol().irodsFunction(input); | ||
|
||
if (null == tag) { | ||
return null; | ||
} | ||
|
||
return tag.getTag("myStr").getStringValue(); | ||
} | ||
|
||
@Override | ||
public String getColumnMappings() throws JargonException { | ||
final Genquery2Input input = Genquery2Input.instanceForColumnMappings(); | ||
final Tag tag = getIRODSProtocol().irodsFunction(input); | ||
|
||
if (null == tag) { | ||
return null; | ||
} | ||
|
||
return tag.getTag("myStr").getStringValue(); | ||
} | ||
|
||
} |