id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
---|---|---|---|---|---|---|---|---|---|---|---|
160,200 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/table/TableUtils.java
|
TableUtils.createTable
|
public static <T> int createTable(ConnectionSource connectionSource, Class<T> dataClass) throws SQLException {
Dao<T, ?> dao = DaoManager.createDao(connectionSource, dataClass);
return doCreateTable(dao, false);
}
|
java
|
public static <T> int createTable(ConnectionSource connectionSource, Class<T> dataClass) throws SQLException {
Dao<T, ?> dao = DaoManager.createDao(connectionSource, dataClass);
return doCreateTable(dao, false);
}
|
[
"public",
"static",
"<",
"T",
">",
"int",
"createTable",
"(",
"ConnectionSource",
"connectionSource",
",",
"Class",
"<",
"T",
">",
"dataClass",
")",
"throws",
"SQLException",
"{",
"Dao",
"<",
"T",
",",
"?",
">",
"dao",
"=",
"DaoManager",
".",
"createDao",
"(",
"connectionSource",
",",
"dataClass",
")",
";",
"return",
"doCreateTable",
"(",
"dao",
",",
"false",
")",
";",
"}"
] |
Issue the database statements to create the table associated with a class.
@param connectionSource
Associated connection source.
@param dataClass
The class for which a table will be created.
@return The number of statements executed to do so.
|
[
"Issue",
"the",
"database",
"statements",
"to",
"create",
"the",
"table",
"associated",
"with",
"a",
"class",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/table/TableUtils.java#L53-L56
|
160,201 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/table/TableUtils.java
|
TableUtils.createTable
|
public static <T> int createTable(ConnectionSource connectionSource, DatabaseTableConfig<T> tableConfig)
throws SQLException {
Dao<T, ?> dao = DaoManager.createDao(connectionSource, tableConfig);
return doCreateTable(dao, false);
}
|
java
|
public static <T> int createTable(ConnectionSource connectionSource, DatabaseTableConfig<T> tableConfig)
throws SQLException {
Dao<T, ?> dao = DaoManager.createDao(connectionSource, tableConfig);
return doCreateTable(dao, false);
}
|
[
"public",
"static",
"<",
"T",
">",
"int",
"createTable",
"(",
"ConnectionSource",
"connectionSource",
",",
"DatabaseTableConfig",
"<",
"T",
">",
"tableConfig",
")",
"throws",
"SQLException",
"{",
"Dao",
"<",
"T",
",",
"?",
">",
"dao",
"=",
"DaoManager",
".",
"createDao",
"(",
"connectionSource",
",",
"tableConfig",
")",
";",
"return",
"doCreateTable",
"(",
"dao",
",",
"false",
")",
";",
"}"
] |
Issue the database statements to create the table associated with a table configuration.
@param connectionSource
connectionSource Associated connection source.
@param tableConfig
Hand or spring wired table configuration. If null then the class must have {@link DatabaseField}
annotations.
@return The number of statements executed to do so.
|
[
"Issue",
"the",
"database",
"statements",
"to",
"create",
"the",
"table",
"associated",
"with",
"a",
"table",
"configuration",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/table/TableUtils.java#L88-L92
|
160,202 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/table/TableUtils.java
|
TableUtils.dropTable
|
public static <T, ID> int dropTable(ConnectionSource connectionSource, Class<T> dataClass, boolean ignoreErrors)
throws SQLException {
Dao<T, ID> dao = DaoManager.createDao(connectionSource, dataClass);
return dropTable(dao, ignoreErrors);
}
|
java
|
public static <T, ID> int dropTable(ConnectionSource connectionSource, Class<T> dataClass, boolean ignoreErrors)
throws SQLException {
Dao<T, ID> dao = DaoManager.createDao(connectionSource, dataClass);
return dropTable(dao, ignoreErrors);
}
|
[
"public",
"static",
"<",
"T",
",",
"ID",
">",
"int",
"dropTable",
"(",
"ConnectionSource",
"connectionSource",
",",
"Class",
"<",
"T",
">",
"dataClass",
",",
"boolean",
"ignoreErrors",
")",
"throws",
"SQLException",
"{",
"Dao",
"<",
"T",
",",
"ID",
">",
"dao",
"=",
"DaoManager",
".",
"createDao",
"(",
"connectionSource",
",",
"dataClass",
")",
";",
"return",
"dropTable",
"(",
"dao",
",",
"ignoreErrors",
")",
";",
"}"
] |
Issue the database statements to drop the table associated with a class.
<p>
<b>WARNING:</b> This is [obviously] very destructive and is unrecoverable.
</p>
@param connectionSource
Associated connection source.
@param dataClass
The class for which a table will be dropped.
@param ignoreErrors
If set to true then try each statement regardless of {@link SQLException} thrown previously.
@return The number of statements executed to do so.
|
[
"Issue",
"the",
"database",
"statements",
"to",
"drop",
"the",
"table",
"associated",
"with",
"a",
"class",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/table/TableUtils.java#L170-L174
|
160,203 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/table/TableUtils.java
|
TableUtils.dropTable
|
public static <T, ID> int dropTable(Dao<T, ID> dao, boolean ignoreErrors) throws SQLException {
ConnectionSource connectionSource = dao.getConnectionSource();
Class<T> dataClass = dao.getDataClass();
DatabaseType databaseType = connectionSource.getDatabaseType();
if (dao instanceof BaseDaoImpl<?, ?>) {
return doDropTable(databaseType, connectionSource, ((BaseDaoImpl<?, ?>) dao).getTableInfo(), ignoreErrors);
} else {
TableInfo<T, ID> tableInfo = new TableInfo<T, ID>(databaseType, dataClass);
return doDropTable(databaseType, connectionSource, tableInfo, ignoreErrors);
}
}
|
java
|
public static <T, ID> int dropTable(Dao<T, ID> dao, boolean ignoreErrors) throws SQLException {
ConnectionSource connectionSource = dao.getConnectionSource();
Class<T> dataClass = dao.getDataClass();
DatabaseType databaseType = connectionSource.getDatabaseType();
if (dao instanceof BaseDaoImpl<?, ?>) {
return doDropTable(databaseType, connectionSource, ((BaseDaoImpl<?, ?>) dao).getTableInfo(), ignoreErrors);
} else {
TableInfo<T, ID> tableInfo = new TableInfo<T, ID>(databaseType, dataClass);
return doDropTable(databaseType, connectionSource, tableInfo, ignoreErrors);
}
}
|
[
"public",
"static",
"<",
"T",
",",
"ID",
">",
"int",
"dropTable",
"(",
"Dao",
"<",
"T",
",",
"ID",
">",
"dao",
",",
"boolean",
"ignoreErrors",
")",
"throws",
"SQLException",
"{",
"ConnectionSource",
"connectionSource",
"=",
"dao",
".",
"getConnectionSource",
"(",
")",
";",
"Class",
"<",
"T",
">",
"dataClass",
"=",
"dao",
".",
"getDataClass",
"(",
")",
";",
"DatabaseType",
"databaseType",
"=",
"connectionSource",
".",
"getDatabaseType",
"(",
")",
";",
"if",
"(",
"dao",
"instanceof",
"BaseDaoImpl",
"<",
"?",
",",
"?",
">",
")",
"{",
"return",
"doDropTable",
"(",
"databaseType",
",",
"connectionSource",
",",
"(",
"(",
"BaseDaoImpl",
"<",
"?",
",",
"?",
">",
")",
"dao",
")",
".",
"getTableInfo",
"(",
")",
",",
"ignoreErrors",
")",
";",
"}",
"else",
"{",
"TableInfo",
"<",
"T",
",",
"ID",
">",
"tableInfo",
"=",
"new",
"TableInfo",
"<",
"T",
",",
"ID",
">",
"(",
"databaseType",
",",
"dataClass",
")",
";",
"return",
"doDropTable",
"(",
"databaseType",
",",
"connectionSource",
",",
"tableInfo",
",",
"ignoreErrors",
")",
";",
"}",
"}"
] |
Issue the database statements to drop the table associated with a dao.
@param dao
Associated dao.
@return The number of statements executed to do so.
|
[
"Issue",
"the",
"database",
"statements",
"to",
"drop",
"the",
"table",
"associated",
"with",
"a",
"dao",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/table/TableUtils.java#L183-L193
|
160,204 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/table/TableUtils.java
|
TableUtils.dropTable
|
public static <T, ID> int dropTable(ConnectionSource connectionSource, DatabaseTableConfig<T> tableConfig,
boolean ignoreErrors) throws SQLException {
DatabaseType databaseType = connectionSource.getDatabaseType();
Dao<T, ID> dao = DaoManager.createDao(connectionSource, tableConfig);
if (dao instanceof BaseDaoImpl<?, ?>) {
return doDropTable(databaseType, connectionSource, ((BaseDaoImpl<?, ?>) dao).getTableInfo(), ignoreErrors);
} else {
tableConfig.extractFieldTypes(databaseType);
TableInfo<T, ID> tableInfo = new TableInfo<T, ID>(databaseType, tableConfig);
return doDropTable(databaseType, connectionSource, tableInfo, ignoreErrors);
}
}
|
java
|
public static <T, ID> int dropTable(ConnectionSource connectionSource, DatabaseTableConfig<T> tableConfig,
boolean ignoreErrors) throws SQLException {
DatabaseType databaseType = connectionSource.getDatabaseType();
Dao<T, ID> dao = DaoManager.createDao(connectionSource, tableConfig);
if (dao instanceof BaseDaoImpl<?, ?>) {
return doDropTable(databaseType, connectionSource, ((BaseDaoImpl<?, ?>) dao).getTableInfo(), ignoreErrors);
} else {
tableConfig.extractFieldTypes(databaseType);
TableInfo<T, ID> tableInfo = new TableInfo<T, ID>(databaseType, tableConfig);
return doDropTable(databaseType, connectionSource, tableInfo, ignoreErrors);
}
}
|
[
"public",
"static",
"<",
"T",
",",
"ID",
">",
"int",
"dropTable",
"(",
"ConnectionSource",
"connectionSource",
",",
"DatabaseTableConfig",
"<",
"T",
">",
"tableConfig",
",",
"boolean",
"ignoreErrors",
")",
"throws",
"SQLException",
"{",
"DatabaseType",
"databaseType",
"=",
"connectionSource",
".",
"getDatabaseType",
"(",
")",
";",
"Dao",
"<",
"T",
",",
"ID",
">",
"dao",
"=",
"DaoManager",
".",
"createDao",
"(",
"connectionSource",
",",
"tableConfig",
")",
";",
"if",
"(",
"dao",
"instanceof",
"BaseDaoImpl",
"<",
"?",
",",
"?",
">",
")",
"{",
"return",
"doDropTable",
"(",
"databaseType",
",",
"connectionSource",
",",
"(",
"(",
"BaseDaoImpl",
"<",
"?",
",",
"?",
">",
")",
"dao",
")",
".",
"getTableInfo",
"(",
")",
",",
"ignoreErrors",
")",
";",
"}",
"else",
"{",
"tableConfig",
".",
"extractFieldTypes",
"(",
"databaseType",
")",
";",
"TableInfo",
"<",
"T",
",",
"ID",
">",
"tableInfo",
"=",
"new",
"TableInfo",
"<",
"T",
",",
"ID",
">",
"(",
"databaseType",
",",
"tableConfig",
")",
";",
"return",
"doDropTable",
"(",
"databaseType",
",",
"connectionSource",
",",
"tableInfo",
",",
"ignoreErrors",
")",
";",
"}",
"}"
] |
Issue the database statements to drop the table associated with a table configuration.
<p>
<b>WARNING:</b> This is [obviously] very destructive and is unrecoverable.
</p>
@param connectionSource
Associated connection source.
@param tableConfig
Hand or spring wired table configuration. If null then the class must have {@link DatabaseField}
annotations.
@param ignoreErrors
If set to true then try each statement regardless of {@link SQLException} thrown previously.
@return The number of statements executed to do so.
|
[
"Issue",
"the",
"database",
"statements",
"to",
"drop",
"the",
"table",
"associated",
"with",
"a",
"table",
"configuration",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/table/TableUtils.java#L211-L222
|
160,205 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/table/TableUtils.java
|
TableUtils.addDropTableStatements
|
private static <T, ID> void addDropTableStatements(DatabaseType databaseType, TableInfo<T, ID> tableInfo,
List<String> statements, boolean logDetails) {
List<String> statementsBefore = new ArrayList<String>();
List<String> statementsAfter = new ArrayList<String>();
for (FieldType fieldType : tableInfo.getFieldTypes()) {
databaseType.dropColumnArg(fieldType, statementsBefore, statementsAfter);
}
StringBuilder sb = new StringBuilder(64);
if (logDetails) {
logger.info("dropping table '{}'", tableInfo.getTableName());
}
sb.append("DROP TABLE ");
databaseType.appendEscapedEntityName(sb, tableInfo.getTableName());
sb.append(' ');
statements.addAll(statementsBefore);
statements.add(sb.toString());
statements.addAll(statementsAfter);
}
|
java
|
private static <T, ID> void addDropTableStatements(DatabaseType databaseType, TableInfo<T, ID> tableInfo,
List<String> statements, boolean logDetails) {
List<String> statementsBefore = new ArrayList<String>();
List<String> statementsAfter = new ArrayList<String>();
for (FieldType fieldType : tableInfo.getFieldTypes()) {
databaseType.dropColumnArg(fieldType, statementsBefore, statementsAfter);
}
StringBuilder sb = new StringBuilder(64);
if (logDetails) {
logger.info("dropping table '{}'", tableInfo.getTableName());
}
sb.append("DROP TABLE ");
databaseType.appendEscapedEntityName(sb, tableInfo.getTableName());
sb.append(' ');
statements.addAll(statementsBefore);
statements.add(sb.toString());
statements.addAll(statementsAfter);
}
|
[
"private",
"static",
"<",
"T",
",",
"ID",
">",
"void",
"addDropTableStatements",
"(",
"DatabaseType",
"databaseType",
",",
"TableInfo",
"<",
"T",
",",
"ID",
">",
"tableInfo",
",",
"List",
"<",
"String",
">",
"statements",
",",
"boolean",
"logDetails",
")",
"{",
"List",
"<",
"String",
">",
"statementsBefore",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"List",
"<",
"String",
">",
"statementsAfter",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"FieldType",
"fieldType",
":",
"tableInfo",
".",
"getFieldTypes",
"(",
")",
")",
"{",
"databaseType",
".",
"dropColumnArg",
"(",
"fieldType",
",",
"statementsBefore",
",",
"statementsAfter",
")",
";",
"}",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"64",
")",
";",
"if",
"(",
"logDetails",
")",
"{",
"logger",
".",
"info",
"(",
"\"dropping table '{}'\"",
",",
"tableInfo",
".",
"getTableName",
"(",
")",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\"DROP TABLE \"",
")",
";",
"databaseType",
".",
"appendEscapedEntityName",
"(",
"sb",
",",
"tableInfo",
".",
"getTableName",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"statements",
".",
"addAll",
"(",
"statementsBefore",
")",
";",
"statements",
".",
"add",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"statements",
".",
"addAll",
"(",
"statementsAfter",
")",
";",
"}"
] |
Generate and return the list of statements to drop a database table.
|
[
"Generate",
"and",
"return",
"the",
"list",
"of",
"statements",
"to",
"drop",
"a",
"database",
"table",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/table/TableUtils.java#L319-L336
|
160,206 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/table/TableUtils.java
|
TableUtils.addCreateTableStatements
|
private static <T, ID> void addCreateTableStatements(DatabaseType databaseType, TableInfo<T, ID> tableInfo,
List<String> statements, List<String> queriesAfter, boolean ifNotExists, boolean logDetails)
throws SQLException {
StringBuilder sb = new StringBuilder(256);
if (logDetails) {
logger.info("creating table '{}'", tableInfo.getTableName());
}
sb.append("CREATE TABLE ");
if (ifNotExists && databaseType.isCreateIfNotExistsSupported()) {
sb.append("IF NOT EXISTS ");
}
databaseType.appendEscapedEntityName(sb, tableInfo.getTableName());
sb.append(" (");
List<String> additionalArgs = new ArrayList<String>();
List<String> statementsBefore = new ArrayList<String>();
List<String> statementsAfter = new ArrayList<String>();
// our statement will be set here later
boolean first = true;
for (FieldType fieldType : tableInfo.getFieldTypes()) {
// skip foreign collections
if (fieldType.isForeignCollection()) {
continue;
} else if (first) {
first = false;
} else {
sb.append(", ");
}
String columnDefinition = fieldType.getColumnDefinition();
if (columnDefinition == null) {
// we have to call back to the database type for the specific create syntax
databaseType.appendColumnArg(tableInfo.getTableName(), sb, fieldType, additionalArgs, statementsBefore,
statementsAfter, queriesAfter);
} else {
// hand defined field
databaseType.appendEscapedEntityName(sb, fieldType.getColumnName());
sb.append(' ').append(columnDefinition).append(' ');
}
}
// add any sql that sets any primary key fields
databaseType.addPrimaryKeySql(tableInfo.getFieldTypes(), additionalArgs, statementsBefore, statementsAfter,
queriesAfter);
// add any sql that sets any unique fields
databaseType.addUniqueComboSql(tableInfo.getFieldTypes(), additionalArgs, statementsBefore, statementsAfter,
queriesAfter);
for (String arg : additionalArgs) {
// we will have spat out one argument already so we don't have to do the first dance
sb.append(", ").append(arg);
}
sb.append(") ");
databaseType.appendCreateTableSuffix(sb);
statements.addAll(statementsBefore);
statements.add(sb.toString());
statements.addAll(statementsAfter);
addCreateIndexStatements(databaseType, tableInfo, statements, ifNotExists, false, logDetails);
addCreateIndexStatements(databaseType, tableInfo, statements, ifNotExists, true, logDetails);
}
|
java
|
private static <T, ID> void addCreateTableStatements(DatabaseType databaseType, TableInfo<T, ID> tableInfo,
List<String> statements, List<String> queriesAfter, boolean ifNotExists, boolean logDetails)
throws SQLException {
StringBuilder sb = new StringBuilder(256);
if (logDetails) {
logger.info("creating table '{}'", tableInfo.getTableName());
}
sb.append("CREATE TABLE ");
if (ifNotExists && databaseType.isCreateIfNotExistsSupported()) {
sb.append("IF NOT EXISTS ");
}
databaseType.appendEscapedEntityName(sb, tableInfo.getTableName());
sb.append(" (");
List<String> additionalArgs = new ArrayList<String>();
List<String> statementsBefore = new ArrayList<String>();
List<String> statementsAfter = new ArrayList<String>();
// our statement will be set here later
boolean first = true;
for (FieldType fieldType : tableInfo.getFieldTypes()) {
// skip foreign collections
if (fieldType.isForeignCollection()) {
continue;
} else if (first) {
first = false;
} else {
sb.append(", ");
}
String columnDefinition = fieldType.getColumnDefinition();
if (columnDefinition == null) {
// we have to call back to the database type for the specific create syntax
databaseType.appendColumnArg(tableInfo.getTableName(), sb, fieldType, additionalArgs, statementsBefore,
statementsAfter, queriesAfter);
} else {
// hand defined field
databaseType.appendEscapedEntityName(sb, fieldType.getColumnName());
sb.append(' ').append(columnDefinition).append(' ');
}
}
// add any sql that sets any primary key fields
databaseType.addPrimaryKeySql(tableInfo.getFieldTypes(), additionalArgs, statementsBefore, statementsAfter,
queriesAfter);
// add any sql that sets any unique fields
databaseType.addUniqueComboSql(tableInfo.getFieldTypes(), additionalArgs, statementsBefore, statementsAfter,
queriesAfter);
for (String arg : additionalArgs) {
// we will have spat out one argument already so we don't have to do the first dance
sb.append(", ").append(arg);
}
sb.append(") ");
databaseType.appendCreateTableSuffix(sb);
statements.addAll(statementsBefore);
statements.add(sb.toString());
statements.addAll(statementsAfter);
addCreateIndexStatements(databaseType, tableInfo, statements, ifNotExists, false, logDetails);
addCreateIndexStatements(databaseType, tableInfo, statements, ifNotExists, true, logDetails);
}
|
[
"private",
"static",
"<",
"T",
",",
"ID",
">",
"void",
"addCreateTableStatements",
"(",
"DatabaseType",
"databaseType",
",",
"TableInfo",
"<",
"T",
",",
"ID",
">",
"tableInfo",
",",
"List",
"<",
"String",
">",
"statements",
",",
"List",
"<",
"String",
">",
"queriesAfter",
",",
"boolean",
"ifNotExists",
",",
"boolean",
"logDetails",
")",
"throws",
"SQLException",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"256",
")",
";",
"if",
"(",
"logDetails",
")",
"{",
"logger",
".",
"info",
"(",
"\"creating table '{}'\"",
",",
"tableInfo",
".",
"getTableName",
"(",
")",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\"CREATE TABLE \"",
")",
";",
"if",
"(",
"ifNotExists",
"&&",
"databaseType",
".",
"isCreateIfNotExistsSupported",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\"IF NOT EXISTS \"",
")",
";",
"}",
"databaseType",
".",
"appendEscapedEntityName",
"(",
"sb",
",",
"tableInfo",
".",
"getTableName",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\" (\"",
")",
";",
"List",
"<",
"String",
">",
"additionalArgs",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"List",
"<",
"String",
">",
"statementsBefore",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"List",
"<",
"String",
">",
"statementsAfter",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"// our statement will be set here later",
"boolean",
"first",
"=",
"true",
";",
"for",
"(",
"FieldType",
"fieldType",
":",
"tableInfo",
".",
"getFieldTypes",
"(",
")",
")",
"{",
"// skip foreign collections",
"if",
"(",
"fieldType",
".",
"isForeignCollection",
"(",
")",
")",
"{",
"continue",
";",
"}",
"else",
"if",
"(",
"first",
")",
"{",
"first",
"=",
"false",
";",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"\", \"",
")",
";",
"}",
"String",
"columnDefinition",
"=",
"fieldType",
".",
"getColumnDefinition",
"(",
")",
";",
"if",
"(",
"columnDefinition",
"==",
"null",
")",
"{",
"// we have to call back to the database type for the specific create syntax",
"databaseType",
".",
"appendColumnArg",
"(",
"tableInfo",
".",
"getTableName",
"(",
")",
",",
"sb",
",",
"fieldType",
",",
"additionalArgs",
",",
"statementsBefore",
",",
"statementsAfter",
",",
"queriesAfter",
")",
";",
"}",
"else",
"{",
"// hand defined field",
"databaseType",
".",
"appendEscapedEntityName",
"(",
"sb",
",",
"fieldType",
".",
"getColumnName",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"columnDefinition",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"}",
"// add any sql that sets any primary key fields",
"databaseType",
".",
"addPrimaryKeySql",
"(",
"tableInfo",
".",
"getFieldTypes",
"(",
")",
",",
"additionalArgs",
",",
"statementsBefore",
",",
"statementsAfter",
",",
"queriesAfter",
")",
";",
"// add any sql that sets any unique fields",
"databaseType",
".",
"addUniqueComboSql",
"(",
"tableInfo",
".",
"getFieldTypes",
"(",
")",
",",
"additionalArgs",
",",
"statementsBefore",
",",
"statementsAfter",
",",
"queriesAfter",
")",
";",
"for",
"(",
"String",
"arg",
":",
"additionalArgs",
")",
"{",
"// we will have spat out one argument already so we don't have to do the first dance",
"sb",
".",
"append",
"(",
"\", \"",
")",
".",
"append",
"(",
"arg",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\") \"",
")",
";",
"databaseType",
".",
"appendCreateTableSuffix",
"(",
"sb",
")",
";",
"statements",
".",
"addAll",
"(",
"statementsBefore",
")",
";",
"statements",
".",
"add",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"statements",
".",
"addAll",
"(",
"statementsAfter",
")",
";",
"addCreateIndexStatements",
"(",
"databaseType",
",",
"tableInfo",
",",
"statements",
",",
"ifNotExists",
",",
"false",
",",
"logDetails",
")",
";",
"addCreateIndexStatements",
"(",
"databaseType",
",",
"tableInfo",
",",
"statements",
",",
"ifNotExists",
",",
"true",
",",
"logDetails",
")",
";",
"}"
] |
Generate and return the list of statements to create a database table and any associated features.
|
[
"Generate",
"and",
"return",
"the",
"list",
"of",
"statements",
"to",
"create",
"a",
"database",
"table",
"and",
"any",
"associated",
"features",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/table/TableUtils.java#L440-L495
|
160,207 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/field/FieldType.java
|
FieldType.assignField
|
public void assignField(ConnectionSource connectionSource, Object data, Object val, boolean parentObject,
ObjectCache objectCache) throws SQLException {
if (logger.isLevelEnabled(Level.TRACE)) {
logger.trace("assiging from data {}, val {}: {}", (data == null ? "null" : data.getClass()),
(val == null ? "null" : val.getClass()), val);
}
// if this is a foreign object then val is the foreign object's id val
if (foreignRefField != null && val != null) {
// get the current field value which is the foreign-id
Object foreignRef = extractJavaFieldValue(data);
/*
* See if we don't need to create a new foreign object. If we are refreshing and the id field has not
* changed then there is no need to create a new foreign object and maybe lose previously refreshed field
* information.
*/
if (foreignRef != null && foreignRef.equals(val)) {
return;
}
// awhitlock: raised as OrmLite issue: bug #122
Object cachedVal;
ObjectCache foreignCache = foreignDao.getObjectCache();
if (foreignCache == null) {
cachedVal = null;
} else {
cachedVal = foreignCache.get(getType(), val);
}
if (cachedVal != null) {
val = cachedVal;
} else if (!parentObject) {
// the value we are to assign to our field is now the foreign object itself
val = createForeignObject(connectionSource, val, objectCache);
}
}
if (fieldSetMethod == null) {
try {
field.set(data, val);
} catch (IllegalArgumentException e) {
if (val == null) {
throw SqlExceptionUtil.create("Could not assign object '" + val + "' to field " + this, e);
} else {
throw SqlExceptionUtil.create(
"Could not assign object '" + val + "' of type " + val.getClass() + " to field " + this, e);
}
} catch (IllegalAccessException e) {
throw SqlExceptionUtil.create(
"Could not assign object '" + val + "' of type " + val.getClass() + "' to field " + this, e);
}
} else {
try {
fieldSetMethod.invoke(data, val);
} catch (Exception e) {
throw SqlExceptionUtil
.create("Could not call " + fieldSetMethod + " on object with '" + val + "' for " + this, e);
}
}
}
|
java
|
public void assignField(ConnectionSource connectionSource, Object data, Object val, boolean parentObject,
ObjectCache objectCache) throws SQLException {
if (logger.isLevelEnabled(Level.TRACE)) {
logger.trace("assiging from data {}, val {}: {}", (data == null ? "null" : data.getClass()),
(val == null ? "null" : val.getClass()), val);
}
// if this is a foreign object then val is the foreign object's id val
if (foreignRefField != null && val != null) {
// get the current field value which is the foreign-id
Object foreignRef = extractJavaFieldValue(data);
/*
* See if we don't need to create a new foreign object. If we are refreshing and the id field has not
* changed then there is no need to create a new foreign object and maybe lose previously refreshed field
* information.
*/
if (foreignRef != null && foreignRef.equals(val)) {
return;
}
// awhitlock: raised as OrmLite issue: bug #122
Object cachedVal;
ObjectCache foreignCache = foreignDao.getObjectCache();
if (foreignCache == null) {
cachedVal = null;
} else {
cachedVal = foreignCache.get(getType(), val);
}
if (cachedVal != null) {
val = cachedVal;
} else if (!parentObject) {
// the value we are to assign to our field is now the foreign object itself
val = createForeignObject(connectionSource, val, objectCache);
}
}
if (fieldSetMethod == null) {
try {
field.set(data, val);
} catch (IllegalArgumentException e) {
if (val == null) {
throw SqlExceptionUtil.create("Could not assign object '" + val + "' to field " + this, e);
} else {
throw SqlExceptionUtil.create(
"Could not assign object '" + val + "' of type " + val.getClass() + " to field " + this, e);
}
} catch (IllegalAccessException e) {
throw SqlExceptionUtil.create(
"Could not assign object '" + val + "' of type " + val.getClass() + "' to field " + this, e);
}
} else {
try {
fieldSetMethod.invoke(data, val);
} catch (Exception e) {
throw SqlExceptionUtil
.create("Could not call " + fieldSetMethod + " on object with '" + val + "' for " + this, e);
}
}
}
|
[
"public",
"void",
"assignField",
"(",
"ConnectionSource",
"connectionSource",
",",
"Object",
"data",
",",
"Object",
"val",
",",
"boolean",
"parentObject",
",",
"ObjectCache",
"objectCache",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"logger",
".",
"isLevelEnabled",
"(",
"Level",
".",
"TRACE",
")",
")",
"{",
"logger",
".",
"trace",
"(",
"\"assiging from data {}, val {}: {}\"",
",",
"(",
"data",
"==",
"null",
"?",
"\"null\"",
":",
"data",
".",
"getClass",
"(",
")",
")",
",",
"(",
"val",
"==",
"null",
"?",
"\"null\"",
":",
"val",
".",
"getClass",
"(",
")",
")",
",",
"val",
")",
";",
"}",
"// if this is a foreign object then val is the foreign object's id val",
"if",
"(",
"foreignRefField",
"!=",
"null",
"&&",
"val",
"!=",
"null",
")",
"{",
"// get the current field value which is the foreign-id",
"Object",
"foreignRef",
"=",
"extractJavaFieldValue",
"(",
"data",
")",
";",
"/*\n\t\t\t * See if we don't need to create a new foreign object. If we are refreshing and the id field has not\n\t\t\t * changed then there is no need to create a new foreign object and maybe lose previously refreshed field\n\t\t\t * information.\n\t\t\t */",
"if",
"(",
"foreignRef",
"!=",
"null",
"&&",
"foreignRef",
".",
"equals",
"(",
"val",
")",
")",
"{",
"return",
";",
"}",
"// awhitlock: raised as OrmLite issue: bug #122",
"Object",
"cachedVal",
";",
"ObjectCache",
"foreignCache",
"=",
"foreignDao",
".",
"getObjectCache",
"(",
")",
";",
"if",
"(",
"foreignCache",
"==",
"null",
")",
"{",
"cachedVal",
"=",
"null",
";",
"}",
"else",
"{",
"cachedVal",
"=",
"foreignCache",
".",
"get",
"(",
"getType",
"(",
")",
",",
"val",
")",
";",
"}",
"if",
"(",
"cachedVal",
"!=",
"null",
")",
"{",
"val",
"=",
"cachedVal",
";",
"}",
"else",
"if",
"(",
"!",
"parentObject",
")",
"{",
"// the value we are to assign to our field is now the foreign object itself",
"val",
"=",
"createForeignObject",
"(",
"connectionSource",
",",
"val",
",",
"objectCache",
")",
";",
"}",
"}",
"if",
"(",
"fieldSetMethod",
"==",
"null",
")",
"{",
"try",
"{",
"field",
".",
"set",
"(",
"data",
",",
"val",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"if",
"(",
"val",
"==",
"null",
")",
"{",
"throw",
"SqlExceptionUtil",
".",
"create",
"(",
"\"Could not assign object '\"",
"+",
"val",
"+",
"\"' to field \"",
"+",
"this",
",",
"e",
")",
";",
"}",
"else",
"{",
"throw",
"SqlExceptionUtil",
".",
"create",
"(",
"\"Could not assign object '\"",
"+",
"val",
"+",
"\"' of type \"",
"+",
"val",
".",
"getClass",
"(",
")",
"+",
"\" to field \"",
"+",
"this",
",",
"e",
")",
";",
"}",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"SqlExceptionUtil",
".",
"create",
"(",
"\"Could not assign object '\"",
"+",
"val",
"+",
"\"' of type \"",
"+",
"val",
".",
"getClass",
"(",
")",
"+",
"\"' to field \"",
"+",
"this",
",",
"e",
")",
";",
"}",
"}",
"else",
"{",
"try",
"{",
"fieldSetMethod",
".",
"invoke",
"(",
"data",
",",
"val",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"SqlExceptionUtil",
".",
"create",
"(",
"\"Could not call \"",
"+",
"fieldSetMethod",
"+",
"\" on object with '\"",
"+",
"val",
"+",
"\"' for \"",
"+",
"this",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
Assign to the data object the val corresponding to the fieldType.
|
[
"Assign",
"to",
"the",
"data",
"object",
"the",
"val",
"corresponding",
"to",
"the",
"fieldType",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/field/FieldType.java#L525-L582
|
160,208 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/field/FieldType.java
|
FieldType.assignIdValue
|
public Object assignIdValue(ConnectionSource connectionSource, Object data, Number val, ObjectCache objectCache)
throws SQLException {
Object idVal = dataPersister.convertIdNumber(val);
if (idVal == null) {
throw new SQLException("Invalid class " + dataPersister + " for sequence-id " + this);
} else {
assignField(connectionSource, data, idVal, false, objectCache);
return idVal;
}
}
|
java
|
public Object assignIdValue(ConnectionSource connectionSource, Object data, Number val, ObjectCache objectCache)
throws SQLException {
Object idVal = dataPersister.convertIdNumber(val);
if (idVal == null) {
throw new SQLException("Invalid class " + dataPersister + " for sequence-id " + this);
} else {
assignField(connectionSource, data, idVal, false, objectCache);
return idVal;
}
}
|
[
"public",
"Object",
"assignIdValue",
"(",
"ConnectionSource",
"connectionSource",
",",
"Object",
"data",
",",
"Number",
"val",
",",
"ObjectCache",
"objectCache",
")",
"throws",
"SQLException",
"{",
"Object",
"idVal",
"=",
"dataPersister",
".",
"convertIdNumber",
"(",
"val",
")",
";",
"if",
"(",
"idVal",
"==",
"null",
")",
"{",
"throw",
"new",
"SQLException",
"(",
"\"Invalid class \"",
"+",
"dataPersister",
"+",
"\" for sequence-id \"",
"+",
"this",
")",
";",
"}",
"else",
"{",
"assignField",
"(",
"connectionSource",
",",
"data",
",",
"idVal",
",",
"false",
",",
"objectCache",
")",
";",
"return",
"idVal",
";",
"}",
"}"
] |
Assign an ID value to this field.
|
[
"Assign",
"an",
"ID",
"value",
"to",
"this",
"field",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/field/FieldType.java#L587-L596
|
160,209 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/field/FieldType.java
|
FieldType.extractRawJavaFieldValue
|
public <FV> FV extractRawJavaFieldValue(Object object) throws SQLException {
Object val;
if (fieldGetMethod == null) {
try {
// field object may not be a T yet
val = field.get(object);
} catch (Exception e) {
throw SqlExceptionUtil.create("Could not get field value for " + this, e);
}
} else {
try {
val = fieldGetMethod.invoke(object);
} catch (Exception e) {
throw SqlExceptionUtil.create("Could not call " + fieldGetMethod + " for " + this, e);
}
}
@SuppressWarnings("unchecked")
FV converted = (FV) val;
return converted;
}
|
java
|
public <FV> FV extractRawJavaFieldValue(Object object) throws SQLException {
Object val;
if (fieldGetMethod == null) {
try {
// field object may not be a T yet
val = field.get(object);
} catch (Exception e) {
throw SqlExceptionUtil.create("Could not get field value for " + this, e);
}
} else {
try {
val = fieldGetMethod.invoke(object);
} catch (Exception e) {
throw SqlExceptionUtil.create("Could not call " + fieldGetMethod + " for " + this, e);
}
}
@SuppressWarnings("unchecked")
FV converted = (FV) val;
return converted;
}
|
[
"public",
"<",
"FV",
">",
"FV",
"extractRawJavaFieldValue",
"(",
"Object",
"object",
")",
"throws",
"SQLException",
"{",
"Object",
"val",
";",
"if",
"(",
"fieldGetMethod",
"==",
"null",
")",
"{",
"try",
"{",
"// field object may not be a T yet",
"val",
"=",
"field",
".",
"get",
"(",
"object",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"SqlExceptionUtil",
".",
"create",
"(",
"\"Could not get field value for \"",
"+",
"this",
",",
"e",
")",
";",
"}",
"}",
"else",
"{",
"try",
"{",
"val",
"=",
"fieldGetMethod",
".",
"invoke",
"(",
"object",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"SqlExceptionUtil",
".",
"create",
"(",
"\"Could not call \"",
"+",
"fieldGetMethod",
"+",
"\" for \"",
"+",
"this",
",",
"e",
")",
";",
"}",
"}",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"FV",
"converted",
"=",
"(",
"FV",
")",
"val",
";",
"return",
"converted",
";",
"}"
] |
Return the value from the field in the object that is defined by this FieldType.
|
[
"Return",
"the",
"value",
"from",
"the",
"field",
"in",
"the",
"object",
"that",
"is",
"defined",
"by",
"this",
"FieldType",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/field/FieldType.java#L601-L621
|
160,210 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/field/FieldType.java
|
FieldType.extractJavaFieldValue
|
public Object extractJavaFieldValue(Object object) throws SQLException {
Object val = extractRawJavaFieldValue(object);
// if this is a foreign object then we want its reference field
if (foreignRefField != null && val != null) {
val = foreignRefField.extractRawJavaFieldValue(val);
}
return val;
}
|
java
|
public Object extractJavaFieldValue(Object object) throws SQLException {
Object val = extractRawJavaFieldValue(object);
// if this is a foreign object then we want its reference field
if (foreignRefField != null && val != null) {
val = foreignRefField.extractRawJavaFieldValue(val);
}
return val;
}
|
[
"public",
"Object",
"extractJavaFieldValue",
"(",
"Object",
"object",
")",
"throws",
"SQLException",
"{",
"Object",
"val",
"=",
"extractRawJavaFieldValue",
"(",
"object",
")",
";",
"// if this is a foreign object then we want its reference field",
"if",
"(",
"foreignRefField",
"!=",
"null",
"&&",
"val",
"!=",
"null",
")",
"{",
"val",
"=",
"foreignRefField",
".",
"extractRawJavaFieldValue",
"(",
"val",
")",
";",
"}",
"return",
"val",
";",
"}"
] |
Return the value from the field in the object that is defined by this FieldType. If the field is a foreign object
then the ID of the field is returned instead.
|
[
"Return",
"the",
"value",
"from",
"the",
"field",
"in",
"the",
"object",
"that",
"is",
"defined",
"by",
"this",
"FieldType",
".",
"If",
"the",
"field",
"is",
"a",
"foreign",
"object",
"then",
"the",
"ID",
"of",
"the",
"field",
"is",
"returned",
"instead",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/field/FieldType.java#L627-L637
|
160,211 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/field/FieldType.java
|
FieldType.convertJavaFieldToSqlArgValue
|
public Object convertJavaFieldToSqlArgValue(Object fieldVal) throws SQLException {
/*
* Limitation here. Some people may want to override the null with their own value in the converter but we
* currently don't allow that. Specifying a default value I guess is a better mechanism.
*/
if (fieldVal == null) {
return null;
} else {
return fieldConverter.javaToSqlArg(this, fieldVal);
}
}
|
java
|
public Object convertJavaFieldToSqlArgValue(Object fieldVal) throws SQLException {
/*
* Limitation here. Some people may want to override the null with their own value in the converter but we
* currently don't allow that. Specifying a default value I guess is a better mechanism.
*/
if (fieldVal == null) {
return null;
} else {
return fieldConverter.javaToSqlArg(this, fieldVal);
}
}
|
[
"public",
"Object",
"convertJavaFieldToSqlArgValue",
"(",
"Object",
"fieldVal",
")",
"throws",
"SQLException",
"{",
"/*\n\t\t * Limitation here. Some people may want to override the null with their own value in the converter but we\n\t\t * currently don't allow that. Specifying a default value I guess is a better mechanism.\n\t\t */",
"if",
"(",
"fieldVal",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"fieldConverter",
".",
"javaToSqlArg",
"(",
"this",
",",
"fieldVal",
")",
";",
"}",
"}"
] |
Convert a field value to something suitable to be stored in the database.
|
[
"Convert",
"a",
"field",
"value",
"to",
"something",
"suitable",
"to",
"be",
"stored",
"in",
"the",
"database",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/field/FieldType.java#L649-L659
|
160,212 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/field/FieldType.java
|
FieldType.convertStringToJavaField
|
public Object convertStringToJavaField(String value, int columnPos) throws SQLException {
if (value == null) {
return null;
} else {
return fieldConverter.resultStringToJava(this, value, columnPos);
}
}
|
java
|
public Object convertStringToJavaField(String value, int columnPos) throws SQLException {
if (value == null) {
return null;
} else {
return fieldConverter.resultStringToJava(this, value, columnPos);
}
}
|
[
"public",
"Object",
"convertStringToJavaField",
"(",
"String",
"value",
",",
"int",
"columnPos",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"fieldConverter",
".",
"resultStringToJava",
"(",
"this",
",",
"value",
",",
"columnPos",
")",
";",
"}",
"}"
] |
Convert a string value into the appropriate Java field value.
|
[
"Convert",
"a",
"string",
"value",
"into",
"the",
"appropriate",
"Java",
"field",
"value",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/field/FieldType.java#L664-L670
|
160,213 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/field/FieldType.java
|
FieldType.moveToNextValue
|
public Object moveToNextValue(Object val) throws SQLException {
if (dataPersister == null) {
return null;
} else {
return dataPersister.moveToNextValue(val);
}
}
|
java
|
public Object moveToNextValue(Object val) throws SQLException {
if (dataPersister == null) {
return null;
} else {
return dataPersister.moveToNextValue(val);
}
}
|
[
"public",
"Object",
"moveToNextValue",
"(",
"Object",
"val",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"dataPersister",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"dataPersister",
".",
"moveToNextValue",
"(",
"val",
")",
";",
"}",
"}"
] |
Move the SQL value to the next one for version processing.
|
[
"Move",
"the",
"SQL",
"value",
"to",
"the",
"next",
"one",
"for",
"version",
"processing",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/field/FieldType.java#L675-L681
|
160,214 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/field/FieldType.java
|
FieldType.buildForeignCollection
|
public <FT, FID> BaseForeignCollection<FT, FID> buildForeignCollection(Object parent, FID id) throws SQLException {
// this can happen if we have a foreign-auto-refresh scenario
if (foreignFieldType == null) {
return null;
}
@SuppressWarnings("unchecked")
Dao<FT, FID> castDao = (Dao<FT, FID>) foreignDao;
if (!fieldConfig.isForeignCollectionEager()) {
// we know this won't go recursive so no need for the counters
return new LazyForeignCollection<FT, FID>(castDao, parent, id, foreignFieldType,
fieldConfig.getForeignCollectionOrderColumnName(), fieldConfig.isForeignCollectionOrderAscending());
}
// try not to create level counter objects unless we have to
LevelCounters levelCounters = threadLevelCounters.get();
if (levelCounters == null) {
if (fieldConfig.getForeignCollectionMaxEagerLevel() == 0) {
// then return a lazy collection instead
return new LazyForeignCollection<FT, FID>(castDao, parent, id, foreignFieldType,
fieldConfig.getForeignCollectionOrderColumnName(),
fieldConfig.isForeignCollectionOrderAscending());
}
levelCounters = new LevelCounters();
threadLevelCounters.set(levelCounters);
}
if (levelCounters.foreignCollectionLevel == 0) {
levelCounters.foreignCollectionLevelMax = fieldConfig.getForeignCollectionMaxEagerLevel();
}
// are we over our level limit?
if (levelCounters.foreignCollectionLevel >= levelCounters.foreignCollectionLevelMax) {
// then return a lazy collection instead
return new LazyForeignCollection<FT, FID>(castDao, parent, id, foreignFieldType,
fieldConfig.getForeignCollectionOrderColumnName(), fieldConfig.isForeignCollectionOrderAscending());
}
levelCounters.foreignCollectionLevel++;
try {
return new EagerForeignCollection<FT, FID>(castDao, parent, id, foreignFieldType,
fieldConfig.getForeignCollectionOrderColumnName(), fieldConfig.isForeignCollectionOrderAscending());
} finally {
levelCounters.foreignCollectionLevel--;
}
}
|
java
|
public <FT, FID> BaseForeignCollection<FT, FID> buildForeignCollection(Object parent, FID id) throws SQLException {
// this can happen if we have a foreign-auto-refresh scenario
if (foreignFieldType == null) {
return null;
}
@SuppressWarnings("unchecked")
Dao<FT, FID> castDao = (Dao<FT, FID>) foreignDao;
if (!fieldConfig.isForeignCollectionEager()) {
// we know this won't go recursive so no need for the counters
return new LazyForeignCollection<FT, FID>(castDao, parent, id, foreignFieldType,
fieldConfig.getForeignCollectionOrderColumnName(), fieldConfig.isForeignCollectionOrderAscending());
}
// try not to create level counter objects unless we have to
LevelCounters levelCounters = threadLevelCounters.get();
if (levelCounters == null) {
if (fieldConfig.getForeignCollectionMaxEagerLevel() == 0) {
// then return a lazy collection instead
return new LazyForeignCollection<FT, FID>(castDao, parent, id, foreignFieldType,
fieldConfig.getForeignCollectionOrderColumnName(),
fieldConfig.isForeignCollectionOrderAscending());
}
levelCounters = new LevelCounters();
threadLevelCounters.set(levelCounters);
}
if (levelCounters.foreignCollectionLevel == 0) {
levelCounters.foreignCollectionLevelMax = fieldConfig.getForeignCollectionMaxEagerLevel();
}
// are we over our level limit?
if (levelCounters.foreignCollectionLevel >= levelCounters.foreignCollectionLevelMax) {
// then return a lazy collection instead
return new LazyForeignCollection<FT, FID>(castDao, parent, id, foreignFieldType,
fieldConfig.getForeignCollectionOrderColumnName(), fieldConfig.isForeignCollectionOrderAscending());
}
levelCounters.foreignCollectionLevel++;
try {
return new EagerForeignCollection<FT, FID>(castDao, parent, id, foreignFieldType,
fieldConfig.getForeignCollectionOrderColumnName(), fieldConfig.isForeignCollectionOrderAscending());
} finally {
levelCounters.foreignCollectionLevel--;
}
}
|
[
"public",
"<",
"FT",
",",
"FID",
">",
"BaseForeignCollection",
"<",
"FT",
",",
"FID",
">",
"buildForeignCollection",
"(",
"Object",
"parent",
",",
"FID",
"id",
")",
"throws",
"SQLException",
"{",
"// this can happen if we have a foreign-auto-refresh scenario",
"if",
"(",
"foreignFieldType",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Dao",
"<",
"FT",
",",
"FID",
">",
"castDao",
"=",
"(",
"Dao",
"<",
"FT",
",",
"FID",
">",
")",
"foreignDao",
";",
"if",
"(",
"!",
"fieldConfig",
".",
"isForeignCollectionEager",
"(",
")",
")",
"{",
"// we know this won't go recursive so no need for the counters",
"return",
"new",
"LazyForeignCollection",
"<",
"FT",
",",
"FID",
">",
"(",
"castDao",
",",
"parent",
",",
"id",
",",
"foreignFieldType",
",",
"fieldConfig",
".",
"getForeignCollectionOrderColumnName",
"(",
")",
",",
"fieldConfig",
".",
"isForeignCollectionOrderAscending",
"(",
")",
")",
";",
"}",
"// try not to create level counter objects unless we have to",
"LevelCounters",
"levelCounters",
"=",
"threadLevelCounters",
".",
"get",
"(",
")",
";",
"if",
"(",
"levelCounters",
"==",
"null",
")",
"{",
"if",
"(",
"fieldConfig",
".",
"getForeignCollectionMaxEagerLevel",
"(",
")",
"==",
"0",
")",
"{",
"// then return a lazy collection instead",
"return",
"new",
"LazyForeignCollection",
"<",
"FT",
",",
"FID",
">",
"(",
"castDao",
",",
"parent",
",",
"id",
",",
"foreignFieldType",
",",
"fieldConfig",
".",
"getForeignCollectionOrderColumnName",
"(",
")",
",",
"fieldConfig",
".",
"isForeignCollectionOrderAscending",
"(",
")",
")",
";",
"}",
"levelCounters",
"=",
"new",
"LevelCounters",
"(",
")",
";",
"threadLevelCounters",
".",
"set",
"(",
"levelCounters",
")",
";",
"}",
"if",
"(",
"levelCounters",
".",
"foreignCollectionLevel",
"==",
"0",
")",
"{",
"levelCounters",
".",
"foreignCollectionLevelMax",
"=",
"fieldConfig",
".",
"getForeignCollectionMaxEagerLevel",
"(",
")",
";",
"}",
"// are we over our level limit?",
"if",
"(",
"levelCounters",
".",
"foreignCollectionLevel",
">=",
"levelCounters",
".",
"foreignCollectionLevelMax",
")",
"{",
"// then return a lazy collection instead",
"return",
"new",
"LazyForeignCollection",
"<",
"FT",
",",
"FID",
">",
"(",
"castDao",
",",
"parent",
",",
"id",
",",
"foreignFieldType",
",",
"fieldConfig",
".",
"getForeignCollectionOrderColumnName",
"(",
")",
",",
"fieldConfig",
".",
"isForeignCollectionOrderAscending",
"(",
")",
")",
";",
"}",
"levelCounters",
".",
"foreignCollectionLevel",
"++",
";",
"try",
"{",
"return",
"new",
"EagerForeignCollection",
"<",
"FT",
",",
"FID",
">",
"(",
"castDao",
",",
"parent",
",",
"id",
",",
"foreignFieldType",
",",
"fieldConfig",
".",
"getForeignCollectionOrderColumnName",
"(",
")",
",",
"fieldConfig",
".",
"isForeignCollectionOrderAscending",
"(",
")",
")",
";",
"}",
"finally",
"{",
"levelCounters",
".",
"foreignCollectionLevel",
"--",
";",
"}",
"}"
] |
Build and return a foreign collection based on the field settings that matches the id argument. This can return
null in certain circumstances.
@param parent
The parent object that we will set on each item in the collection.
@param id
The id of the foreign object we will look for. This can be null if we are creating an empty
collection.
|
[
"Build",
"and",
"return",
"a",
"foreign",
"collection",
"based",
"on",
"the",
"field",
"settings",
"that",
"matches",
"the",
"id",
"argument",
".",
"This",
"can",
"return",
"null",
"in",
"certain",
"circumstances",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/field/FieldType.java#L781-L823
|
160,215 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/field/FieldType.java
|
FieldType.getFieldValueIfNotDefault
|
public <FV> FV getFieldValueIfNotDefault(Object object) throws SQLException {
@SuppressWarnings("unchecked")
FV fieldValue = (FV) extractJavaFieldValue(object);
if (isFieldValueDefault(fieldValue)) {
return null;
} else {
return fieldValue;
}
}
|
java
|
public <FV> FV getFieldValueIfNotDefault(Object object) throws SQLException {
@SuppressWarnings("unchecked")
FV fieldValue = (FV) extractJavaFieldValue(object);
if (isFieldValueDefault(fieldValue)) {
return null;
} else {
return fieldValue;
}
}
|
[
"public",
"<",
"FV",
">",
"FV",
"getFieldValueIfNotDefault",
"(",
"Object",
"object",
")",
"throws",
"SQLException",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"FV",
"fieldValue",
"=",
"(",
"FV",
")",
"extractJavaFieldValue",
"(",
"object",
")",
";",
"if",
"(",
"isFieldValueDefault",
"(",
"fieldValue",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"fieldValue",
";",
"}",
"}"
] |
Return the value of field in the data argument if it is not the default value for the class. If it is the default
then null is returned.
|
[
"Return",
"the",
"value",
"of",
"field",
"in",
"the",
"data",
"argument",
"if",
"it",
"is",
"not",
"the",
"default",
"value",
"for",
"the",
"class",
".",
"If",
"it",
"is",
"the",
"default",
"then",
"null",
"is",
"returned",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/field/FieldType.java#L927-L935
|
160,216 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/field/FieldType.java
|
FieldType.isObjectsFieldValueDefault
|
public boolean isObjectsFieldValueDefault(Object object) throws SQLException {
Object fieldValue = extractJavaFieldValue(object);
return isFieldValueDefault(fieldValue);
}
|
java
|
public boolean isObjectsFieldValueDefault(Object object) throws SQLException {
Object fieldValue = extractJavaFieldValue(object);
return isFieldValueDefault(fieldValue);
}
|
[
"public",
"boolean",
"isObjectsFieldValueDefault",
"(",
"Object",
"object",
")",
"throws",
"SQLException",
"{",
"Object",
"fieldValue",
"=",
"extractJavaFieldValue",
"(",
"object",
")",
";",
"return",
"isFieldValueDefault",
"(",
"fieldValue",
")",
";",
"}"
] |
Return whether or not the data object has a default value passed for this field of this type.
|
[
"Return",
"whether",
"or",
"not",
"the",
"data",
"object",
"has",
"a",
"default",
"value",
"passed",
"for",
"this",
"field",
"of",
"this",
"type",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/field/FieldType.java#L940-L943
|
160,217 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/field/FieldType.java
|
FieldType.getJavaDefaultValueDefault
|
public Object getJavaDefaultValueDefault() {
if (field.getType() == boolean.class) {
return DEFAULT_VALUE_BOOLEAN;
} else if (field.getType() == byte.class || field.getType() == Byte.class) {
return DEFAULT_VALUE_BYTE;
} else if (field.getType() == char.class || field.getType() == Character.class) {
return DEFAULT_VALUE_CHAR;
} else if (field.getType() == short.class || field.getType() == Short.class) {
return DEFAULT_VALUE_SHORT;
} else if (field.getType() == int.class || field.getType() == Integer.class) {
return DEFAULT_VALUE_INT;
} else if (field.getType() == long.class || field.getType() == Long.class) {
return DEFAULT_VALUE_LONG;
} else if (field.getType() == float.class || field.getType() == Float.class) {
return DEFAULT_VALUE_FLOAT;
} else if (field.getType() == double.class || field.getType() == Double.class) {
return DEFAULT_VALUE_DOUBLE;
} else {
return null;
}
}
|
java
|
public Object getJavaDefaultValueDefault() {
if (field.getType() == boolean.class) {
return DEFAULT_VALUE_BOOLEAN;
} else if (field.getType() == byte.class || field.getType() == Byte.class) {
return DEFAULT_VALUE_BYTE;
} else if (field.getType() == char.class || field.getType() == Character.class) {
return DEFAULT_VALUE_CHAR;
} else if (field.getType() == short.class || field.getType() == Short.class) {
return DEFAULT_VALUE_SHORT;
} else if (field.getType() == int.class || field.getType() == Integer.class) {
return DEFAULT_VALUE_INT;
} else if (field.getType() == long.class || field.getType() == Long.class) {
return DEFAULT_VALUE_LONG;
} else if (field.getType() == float.class || field.getType() == Float.class) {
return DEFAULT_VALUE_FLOAT;
} else if (field.getType() == double.class || field.getType() == Double.class) {
return DEFAULT_VALUE_DOUBLE;
} else {
return null;
}
}
|
[
"public",
"Object",
"getJavaDefaultValueDefault",
"(",
")",
"{",
"if",
"(",
"field",
".",
"getType",
"(",
")",
"==",
"boolean",
".",
"class",
")",
"{",
"return",
"DEFAULT_VALUE_BOOLEAN",
";",
"}",
"else",
"if",
"(",
"field",
".",
"getType",
"(",
")",
"==",
"byte",
".",
"class",
"||",
"field",
".",
"getType",
"(",
")",
"==",
"Byte",
".",
"class",
")",
"{",
"return",
"DEFAULT_VALUE_BYTE",
";",
"}",
"else",
"if",
"(",
"field",
".",
"getType",
"(",
")",
"==",
"char",
".",
"class",
"||",
"field",
".",
"getType",
"(",
")",
"==",
"Character",
".",
"class",
")",
"{",
"return",
"DEFAULT_VALUE_CHAR",
";",
"}",
"else",
"if",
"(",
"field",
".",
"getType",
"(",
")",
"==",
"short",
".",
"class",
"||",
"field",
".",
"getType",
"(",
")",
"==",
"Short",
".",
"class",
")",
"{",
"return",
"DEFAULT_VALUE_SHORT",
";",
"}",
"else",
"if",
"(",
"field",
".",
"getType",
"(",
")",
"==",
"int",
".",
"class",
"||",
"field",
".",
"getType",
"(",
")",
"==",
"Integer",
".",
"class",
")",
"{",
"return",
"DEFAULT_VALUE_INT",
";",
"}",
"else",
"if",
"(",
"field",
".",
"getType",
"(",
")",
"==",
"long",
".",
"class",
"||",
"field",
".",
"getType",
"(",
")",
"==",
"Long",
".",
"class",
")",
"{",
"return",
"DEFAULT_VALUE_LONG",
";",
"}",
"else",
"if",
"(",
"field",
".",
"getType",
"(",
")",
"==",
"float",
".",
"class",
"||",
"field",
".",
"getType",
"(",
")",
"==",
"Float",
".",
"class",
")",
"{",
"return",
"DEFAULT_VALUE_FLOAT",
";",
"}",
"else",
"if",
"(",
"field",
".",
"getType",
"(",
")",
"==",
"double",
".",
"class",
"||",
"field",
".",
"getType",
"(",
")",
"==",
"Double",
".",
"class",
")",
"{",
"return",
"DEFAULT_VALUE_DOUBLE",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Return whether or not the field value passed in is the default value for the type of the field. Null will return
true.
|
[
"Return",
"whether",
"or",
"not",
"the",
"field",
"value",
"passed",
"in",
"is",
"the",
"default",
"value",
"for",
"the",
"type",
"of",
"the",
"field",
".",
"Null",
"will",
"return",
"true",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/field/FieldType.java#L949-L969
|
160,218 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/field/FieldType.java
|
FieldType.createForeignShell
|
private <FT, FID> FT createForeignShell(ConnectionSource connectionSource, Object val, ObjectCache objectCache)
throws SQLException {
@SuppressWarnings("unchecked")
Dao<FT, FID> castDao = (Dao<FT, FID>) foreignDao;
FT foreignObject = castDao.createObjectInstance();
foreignIdField.assignField(connectionSource, foreignObject, val, false, objectCache);
return foreignObject;
}
|
java
|
private <FT, FID> FT createForeignShell(ConnectionSource connectionSource, Object val, ObjectCache objectCache)
throws SQLException {
@SuppressWarnings("unchecked")
Dao<FT, FID> castDao = (Dao<FT, FID>) foreignDao;
FT foreignObject = castDao.createObjectInstance();
foreignIdField.assignField(connectionSource, foreignObject, val, false, objectCache);
return foreignObject;
}
|
[
"private",
"<",
"FT",
",",
"FID",
">",
"FT",
"createForeignShell",
"(",
"ConnectionSource",
"connectionSource",
",",
"Object",
"val",
",",
"ObjectCache",
"objectCache",
")",
"throws",
"SQLException",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Dao",
"<",
"FT",
",",
"FID",
">",
"castDao",
"=",
"(",
"Dao",
"<",
"FT",
",",
"FID",
">",
")",
"foreignDao",
";",
"FT",
"foreignObject",
"=",
"castDao",
".",
"createObjectInstance",
"(",
")",
";",
"foreignIdField",
".",
"assignField",
"(",
"connectionSource",
",",
"foreignObject",
",",
"val",
",",
"false",
",",
"objectCache",
")",
";",
"return",
"foreignObject",
";",
"}"
] |
Create a shell object and assign its id field.
|
[
"Create",
"a",
"shell",
"object",
"and",
"assign",
"its",
"id",
"field",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/field/FieldType.java#L1084-L1091
|
160,219 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/field/FieldType.java
|
FieldType.findForeignFieldType
|
private FieldType findForeignFieldType(Class<?> clazz, Class<?> foreignClass, Dao<?, ?> foreignDao)
throws SQLException {
String foreignColumnName = fieldConfig.getForeignCollectionForeignFieldName();
for (FieldType fieldType : foreignDao.getTableInfo().getFieldTypes()) {
if (fieldType.getType() == foreignClass
&& (foreignColumnName == null || fieldType.getField().getName().equals(foreignColumnName))) {
if (!fieldType.fieldConfig.isForeign() && !fieldType.fieldConfig.isForeignAutoRefresh()) {
// this may never be reached
throw new SQLException("Foreign collection object " + clazz + " for field '" + field.getName()
+ "' contains a field of class " + foreignClass + " but it's not foreign");
}
return fieldType;
}
}
// build our complex error message
StringBuilder sb = new StringBuilder();
sb.append("Foreign collection class ").append(clazz.getName());
sb.append(" for field '").append(field.getName()).append("' column-name does not contain a foreign field");
if (foreignColumnName != null) {
sb.append(" named '").append(foreignColumnName).append('\'');
}
sb.append(" of class ").append(foreignClass.getName());
throw new SQLException(sb.toString());
}
|
java
|
private FieldType findForeignFieldType(Class<?> clazz, Class<?> foreignClass, Dao<?, ?> foreignDao)
throws SQLException {
String foreignColumnName = fieldConfig.getForeignCollectionForeignFieldName();
for (FieldType fieldType : foreignDao.getTableInfo().getFieldTypes()) {
if (fieldType.getType() == foreignClass
&& (foreignColumnName == null || fieldType.getField().getName().equals(foreignColumnName))) {
if (!fieldType.fieldConfig.isForeign() && !fieldType.fieldConfig.isForeignAutoRefresh()) {
// this may never be reached
throw new SQLException("Foreign collection object " + clazz + " for field '" + field.getName()
+ "' contains a field of class " + foreignClass + " but it's not foreign");
}
return fieldType;
}
}
// build our complex error message
StringBuilder sb = new StringBuilder();
sb.append("Foreign collection class ").append(clazz.getName());
sb.append(" for field '").append(field.getName()).append("' column-name does not contain a foreign field");
if (foreignColumnName != null) {
sb.append(" named '").append(foreignColumnName).append('\'');
}
sb.append(" of class ").append(foreignClass.getName());
throw new SQLException(sb.toString());
}
|
[
"private",
"FieldType",
"findForeignFieldType",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"Class",
"<",
"?",
">",
"foreignClass",
",",
"Dao",
"<",
"?",
",",
"?",
">",
"foreignDao",
")",
"throws",
"SQLException",
"{",
"String",
"foreignColumnName",
"=",
"fieldConfig",
".",
"getForeignCollectionForeignFieldName",
"(",
")",
";",
"for",
"(",
"FieldType",
"fieldType",
":",
"foreignDao",
".",
"getTableInfo",
"(",
")",
".",
"getFieldTypes",
"(",
")",
")",
"{",
"if",
"(",
"fieldType",
".",
"getType",
"(",
")",
"==",
"foreignClass",
"&&",
"(",
"foreignColumnName",
"==",
"null",
"||",
"fieldType",
".",
"getField",
"(",
")",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"foreignColumnName",
")",
")",
")",
"{",
"if",
"(",
"!",
"fieldType",
".",
"fieldConfig",
".",
"isForeign",
"(",
")",
"&&",
"!",
"fieldType",
".",
"fieldConfig",
".",
"isForeignAutoRefresh",
"(",
")",
")",
"{",
"// this may never be reached",
"throw",
"new",
"SQLException",
"(",
"\"Foreign collection object \"",
"+",
"clazz",
"+",
"\" for field '\"",
"+",
"field",
".",
"getName",
"(",
")",
"+",
"\"' contains a field of class \"",
"+",
"foreignClass",
"+",
"\" but it's not foreign\"",
")",
";",
"}",
"return",
"fieldType",
";",
"}",
"}",
"// build our complex error message",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"\"Foreign collection class \"",
")",
".",
"append",
"(",
"clazz",
".",
"getName",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\" for field '\"",
")",
".",
"append",
"(",
"field",
".",
"getName",
"(",
")",
")",
".",
"append",
"(",
"\"' column-name does not contain a foreign field\"",
")",
";",
"if",
"(",
"foreignColumnName",
"!=",
"null",
")",
"{",
"sb",
".",
"append",
"(",
"\" named '\"",
")",
".",
"append",
"(",
"foreignColumnName",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\" of class \"",
")",
".",
"append",
"(",
"foreignClass",
".",
"getName",
"(",
")",
")",
";",
"throw",
"new",
"SQLException",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
If we have a class Foo with a collection of Bar's then we go through Bar's DAO looking for a Foo field. We need
this field to build the query that is able to find all Bar's that have foo_id that matches our id.
|
[
"If",
"we",
"have",
"a",
"class",
"Foo",
"with",
"a",
"collection",
"of",
"Bar",
"s",
"then",
"we",
"go",
"through",
"Bar",
"s",
"DAO",
"looking",
"for",
"a",
"Foo",
"field",
".",
"We",
"need",
"this",
"field",
"to",
"build",
"the",
"query",
"that",
"is",
"able",
"to",
"find",
"all",
"Bar",
"s",
"that",
"have",
"foo_id",
"that",
"matches",
"our",
"id",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/field/FieldType.java#L1109-L1132
|
160,220 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/stmt/mapped/MappedQueryForFieldEq.java
|
MappedQueryForFieldEq.execute
|
public T execute(DatabaseConnection databaseConnection, ID id, ObjectCache objectCache) throws SQLException {
if (objectCache != null) {
T result = objectCache.get(clazz, id);
if (result != null) {
return result;
}
}
Object[] args = new Object[] { convertIdToFieldObject(id) };
// @SuppressWarnings("unchecked")
Object result = databaseConnection.queryForOne(statement, args, argFieldTypes, this, objectCache);
if (result == null) {
logger.debug("{} using '{}' and {} args, got no results", label, statement, args.length);
} else if (result == DatabaseConnection.MORE_THAN_ONE) {
logger.error("{} using '{}' and {} args, got >1 results", label, statement, args.length);
logArgs(args);
throw new SQLException(label + " got more than 1 result: " + statement);
} else {
logger.debug("{} using '{}' and {} args, got 1 result", label, statement, args.length);
}
logArgs(args);
@SuppressWarnings("unchecked")
T castResult = (T) result;
return castResult;
}
|
java
|
public T execute(DatabaseConnection databaseConnection, ID id, ObjectCache objectCache) throws SQLException {
if (objectCache != null) {
T result = objectCache.get(clazz, id);
if (result != null) {
return result;
}
}
Object[] args = new Object[] { convertIdToFieldObject(id) };
// @SuppressWarnings("unchecked")
Object result = databaseConnection.queryForOne(statement, args, argFieldTypes, this, objectCache);
if (result == null) {
logger.debug("{} using '{}' and {} args, got no results", label, statement, args.length);
} else if (result == DatabaseConnection.MORE_THAN_ONE) {
logger.error("{} using '{}' and {} args, got >1 results", label, statement, args.length);
logArgs(args);
throw new SQLException(label + " got more than 1 result: " + statement);
} else {
logger.debug("{} using '{}' and {} args, got 1 result", label, statement, args.length);
}
logArgs(args);
@SuppressWarnings("unchecked")
T castResult = (T) result;
return castResult;
}
|
[
"public",
"T",
"execute",
"(",
"DatabaseConnection",
"databaseConnection",
",",
"ID",
"id",
",",
"ObjectCache",
"objectCache",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"objectCache",
"!=",
"null",
")",
"{",
"T",
"result",
"=",
"objectCache",
".",
"get",
"(",
"clazz",
",",
"id",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"return",
"result",
";",
"}",
"}",
"Object",
"[",
"]",
"args",
"=",
"new",
"Object",
"[",
"]",
"{",
"convertIdToFieldObject",
"(",
"id",
")",
"}",
";",
"// @SuppressWarnings(\"unchecked\")",
"Object",
"result",
"=",
"databaseConnection",
".",
"queryForOne",
"(",
"statement",
",",
"args",
",",
"argFieldTypes",
",",
"this",
",",
"objectCache",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"logger",
".",
"debug",
"(",
"\"{} using '{}' and {} args, got no results\"",
",",
"label",
",",
"statement",
",",
"args",
".",
"length",
")",
";",
"}",
"else",
"if",
"(",
"result",
"==",
"DatabaseConnection",
".",
"MORE_THAN_ONE",
")",
"{",
"logger",
".",
"error",
"(",
"\"{} using '{}' and {} args, got >1 results\"",
",",
"label",
",",
"statement",
",",
"args",
".",
"length",
")",
";",
"logArgs",
"(",
"args",
")",
";",
"throw",
"new",
"SQLException",
"(",
"label",
"+",
"\" got more than 1 result: \"",
"+",
"statement",
")",
";",
"}",
"else",
"{",
"logger",
".",
"debug",
"(",
"\"{} using '{}' and {} args, got 1 result\"",
",",
"label",
",",
"statement",
",",
"args",
".",
"length",
")",
";",
"}",
"logArgs",
"(",
"args",
")",
";",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"T",
"castResult",
"=",
"(",
"T",
")",
"result",
";",
"return",
"castResult",
";",
"}"
] |
Query for an object in the database which matches the id argument.
|
[
"Query",
"for",
"an",
"object",
"in",
"the",
"database",
"which",
"matches",
"the",
"id",
"argument",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/stmt/mapped/MappedQueryForFieldEq.java#L30-L53
|
160,221 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/db/BaseDatabaseType.java
|
BaseDatabaseType.appendStringType
|
protected void appendStringType(StringBuilder sb, FieldType fieldType, int fieldWidth) {
if (isVarcharFieldWidthSupported()) {
sb.append("VARCHAR(").append(fieldWidth).append(')');
} else {
sb.append("VARCHAR");
}
}
|
java
|
protected void appendStringType(StringBuilder sb, FieldType fieldType, int fieldWidth) {
if (isVarcharFieldWidthSupported()) {
sb.append("VARCHAR(").append(fieldWidth).append(')');
} else {
sb.append("VARCHAR");
}
}
|
[
"protected",
"void",
"appendStringType",
"(",
"StringBuilder",
"sb",
",",
"FieldType",
"fieldType",
",",
"int",
"fieldWidth",
")",
"{",
"if",
"(",
"isVarcharFieldWidthSupported",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\"VARCHAR(\"",
")",
".",
"append",
"(",
"fieldWidth",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"\"VARCHAR\"",
")",
";",
"}",
"}"
] |
Output the SQL type for a Java String.
|
[
"Output",
"the",
"SQL",
"type",
"for",
"a",
"Java",
"String",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/db/BaseDatabaseType.java#L205-L211
|
160,222 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/db/BaseDatabaseType.java
|
BaseDatabaseType.appendDefaultValue
|
private void appendDefaultValue(StringBuilder sb, FieldType fieldType, Object defaultValue) {
if (fieldType.isEscapedDefaultValue()) {
appendEscapedWord(sb, defaultValue.toString());
} else {
sb.append(defaultValue);
}
}
|
java
|
private void appendDefaultValue(StringBuilder sb, FieldType fieldType, Object defaultValue) {
if (fieldType.isEscapedDefaultValue()) {
appendEscapedWord(sb, defaultValue.toString());
} else {
sb.append(defaultValue);
}
}
|
[
"private",
"void",
"appendDefaultValue",
"(",
"StringBuilder",
"sb",
",",
"FieldType",
"fieldType",
",",
"Object",
"defaultValue",
")",
"{",
"if",
"(",
"fieldType",
".",
"isEscapedDefaultValue",
"(",
")",
")",
"{",
"appendEscapedWord",
"(",
"sb",
",",
"defaultValue",
".",
"toString",
"(",
")",
")",
";",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"defaultValue",
")",
";",
"}",
"}"
] |
Output the SQL type for the default value for the type.
|
[
"Output",
"the",
"SQL",
"type",
"for",
"the",
"default",
"value",
"for",
"the",
"type",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/db/BaseDatabaseType.java#L315-L321
|
160,223 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/db/BaseDatabaseType.java
|
BaseDatabaseType.addSingleUnique
|
private void addSingleUnique(StringBuilder sb, FieldType fieldType, List<String> additionalArgs,
List<String> statementsAfter) {
StringBuilder alterSb = new StringBuilder();
alterSb.append(" UNIQUE (");
appendEscapedEntityName(alterSb, fieldType.getColumnName());
alterSb.append(')');
additionalArgs.add(alterSb.toString());
}
|
java
|
private void addSingleUnique(StringBuilder sb, FieldType fieldType, List<String> additionalArgs,
List<String> statementsAfter) {
StringBuilder alterSb = new StringBuilder();
alterSb.append(" UNIQUE (");
appendEscapedEntityName(alterSb, fieldType.getColumnName());
alterSb.append(')');
additionalArgs.add(alterSb.toString());
}
|
[
"private",
"void",
"addSingleUnique",
"(",
"StringBuilder",
"sb",
",",
"FieldType",
"fieldType",
",",
"List",
"<",
"String",
">",
"additionalArgs",
",",
"List",
"<",
"String",
">",
"statementsAfter",
")",
"{",
"StringBuilder",
"alterSb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"alterSb",
".",
"append",
"(",
"\" UNIQUE (\"",
")",
";",
"appendEscapedEntityName",
"(",
"alterSb",
",",
"fieldType",
".",
"getColumnName",
"(",
")",
")",
";",
"alterSb",
".",
"append",
"(",
"'",
"'",
")",
";",
"additionalArgs",
".",
"add",
"(",
"alterSb",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Add SQL to handle a unique=true field. THis is not for uniqueCombo=true.
|
[
"Add",
"SQL",
"to",
"handle",
"a",
"unique",
"=",
"true",
"field",
".",
"THis",
"is",
"not",
"for",
"uniqueCombo",
"=",
"true",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/db/BaseDatabaseType.java#L631-L638
|
160,224 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/field/DataPersisterManager.java
|
DataPersisterManager.registerDataPersisters
|
public static void registerDataPersisters(DataPersister... dataPersisters) {
// we build the map and replace it to lower the chance of concurrency issues
List<DataPersister> newList = new ArrayList<DataPersister>();
if (registeredPersisters != null) {
newList.addAll(registeredPersisters);
}
for (DataPersister persister : dataPersisters) {
newList.add(persister);
}
registeredPersisters = newList;
}
|
java
|
public static void registerDataPersisters(DataPersister... dataPersisters) {
// we build the map and replace it to lower the chance of concurrency issues
List<DataPersister> newList = new ArrayList<DataPersister>();
if (registeredPersisters != null) {
newList.addAll(registeredPersisters);
}
for (DataPersister persister : dataPersisters) {
newList.add(persister);
}
registeredPersisters = newList;
}
|
[
"public",
"static",
"void",
"registerDataPersisters",
"(",
"DataPersister",
"...",
"dataPersisters",
")",
"{",
"// we build the map and replace it to lower the chance of concurrency issues",
"List",
"<",
"DataPersister",
">",
"newList",
"=",
"new",
"ArrayList",
"<",
"DataPersister",
">",
"(",
")",
";",
"if",
"(",
"registeredPersisters",
"!=",
"null",
")",
"{",
"newList",
".",
"addAll",
"(",
"registeredPersisters",
")",
";",
"}",
"for",
"(",
"DataPersister",
"persister",
":",
"dataPersisters",
")",
"{",
"newList",
".",
"add",
"(",
"persister",
")",
";",
"}",
"registeredPersisters",
"=",
"newList",
";",
"}"
] |
Register a data type with the manager.
|
[
"Register",
"a",
"data",
"type",
"with",
"the",
"manager",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/field/DataPersisterManager.java#L51-L61
|
160,225 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/field/DataPersisterManager.java
|
DataPersisterManager.lookupForField
|
public static DataPersister lookupForField(Field field) {
// see if the any of the registered persisters are valid first
if (registeredPersisters != null) {
for (DataPersister persister : registeredPersisters) {
if (persister.isValidForField(field)) {
return persister;
}
// check the classes instead
for (Class<?> clazz : persister.getAssociatedClasses()) {
if (field.getType() == clazz) {
return persister;
}
}
}
}
// look it up in our built-in map by class
DataPersister dataPersister = builtInMap.get(field.getType().getName());
if (dataPersister != null) {
return dataPersister;
}
/*
* Special case for enum types. We can't put this in the registered persisters because we want people to be able
* to override it.
*/
if (field.getType().isEnum()) {
return DEFAULT_ENUM_PERSISTER;
} else {
/*
* Serializable classes return null here because we don't want them to be automatically configured for
* forwards compatibility with future field types that happen to be Serializable.
*/
return null;
}
}
|
java
|
public static DataPersister lookupForField(Field field) {
// see if the any of the registered persisters are valid first
if (registeredPersisters != null) {
for (DataPersister persister : registeredPersisters) {
if (persister.isValidForField(field)) {
return persister;
}
// check the classes instead
for (Class<?> clazz : persister.getAssociatedClasses()) {
if (field.getType() == clazz) {
return persister;
}
}
}
}
// look it up in our built-in map by class
DataPersister dataPersister = builtInMap.get(field.getType().getName());
if (dataPersister != null) {
return dataPersister;
}
/*
* Special case for enum types. We can't put this in the registered persisters because we want people to be able
* to override it.
*/
if (field.getType().isEnum()) {
return DEFAULT_ENUM_PERSISTER;
} else {
/*
* Serializable classes return null here because we don't want them to be automatically configured for
* forwards compatibility with future field types that happen to be Serializable.
*/
return null;
}
}
|
[
"public",
"static",
"DataPersister",
"lookupForField",
"(",
"Field",
"field",
")",
"{",
"// see if the any of the registered persisters are valid first",
"if",
"(",
"registeredPersisters",
"!=",
"null",
")",
"{",
"for",
"(",
"DataPersister",
"persister",
":",
"registeredPersisters",
")",
"{",
"if",
"(",
"persister",
".",
"isValidForField",
"(",
"field",
")",
")",
"{",
"return",
"persister",
";",
"}",
"// check the classes instead",
"for",
"(",
"Class",
"<",
"?",
">",
"clazz",
":",
"persister",
".",
"getAssociatedClasses",
"(",
")",
")",
"{",
"if",
"(",
"field",
".",
"getType",
"(",
")",
"==",
"clazz",
")",
"{",
"return",
"persister",
";",
"}",
"}",
"}",
"}",
"// look it up in our built-in map by class",
"DataPersister",
"dataPersister",
"=",
"builtInMap",
".",
"get",
"(",
"field",
".",
"getType",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"dataPersister",
"!=",
"null",
")",
"{",
"return",
"dataPersister",
";",
"}",
"/*\n\t\t * Special case for enum types. We can't put this in the registered persisters because we want people to be able\n\t\t * to override it.\n\t\t */",
"if",
"(",
"field",
".",
"getType",
"(",
")",
".",
"isEnum",
"(",
")",
")",
"{",
"return",
"DEFAULT_ENUM_PERSISTER",
";",
"}",
"else",
"{",
"/*\n\t\t\t * Serializable classes return null here because we don't want them to be automatically configured for\n\t\t\t * forwards compatibility with future field types that happen to be Serializable.\n\t\t\t */",
"return",
"null",
";",
"}",
"}"
] |
Lookup the data-type associated with the class.
@return The associated data-type interface or null if none found.
|
[
"Lookup",
"the",
"data",
"-",
"type",
"associated",
"with",
"the",
"class",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/field/DataPersisterManager.java#L75-L111
|
160,226 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/stmt/mapped/MappedUpdate.java
|
MappedUpdate.update
|
public int update(DatabaseConnection databaseConnection, T data, ObjectCache objectCache) throws SQLException {
try {
// there is always and id field as an argument so just return 0 lines updated
if (argFieldTypes.length <= 1) {
return 0;
}
Object[] args = getFieldObjects(data);
Object newVersion = null;
if (versionFieldType != null) {
newVersion = versionFieldType.extractJavaFieldValue(data);
newVersion = versionFieldType.moveToNextValue(newVersion);
args[versionFieldTypeIndex] = versionFieldType.convertJavaFieldToSqlArgValue(newVersion);
}
int rowC = databaseConnection.update(statement, args, argFieldTypes);
if (rowC > 0) {
if (newVersion != null) {
// if we have updated a row then update the version field in our object to the new value
versionFieldType.assignField(connectionSource, data, newVersion, false, null);
}
if (objectCache != null) {
// if we've changed something then see if we need to update our cache
Object id = idField.extractJavaFieldValue(data);
T cachedData = objectCache.get(clazz, id);
if (cachedData != null && cachedData != data) {
// copy each field from the updated data into the cached object
for (FieldType fieldType : tableInfo.getFieldTypes()) {
if (fieldType != idField) {
fieldType.assignField(connectionSource, cachedData,
fieldType.extractJavaFieldValue(data), false, objectCache);
}
}
}
}
}
logger.debug("update data with statement '{}' and {} args, changed {} rows", statement, args.length, rowC);
if (args.length > 0) {
// need to do the (Object) cast to force args to be a single object
logger.trace("update arguments: {}", (Object) args);
}
return rowC;
} catch (SQLException e) {
throw SqlExceptionUtil.create("Unable to run update stmt on object " + data + ": " + statement, e);
}
}
|
java
|
public int update(DatabaseConnection databaseConnection, T data, ObjectCache objectCache) throws SQLException {
try {
// there is always and id field as an argument so just return 0 lines updated
if (argFieldTypes.length <= 1) {
return 0;
}
Object[] args = getFieldObjects(data);
Object newVersion = null;
if (versionFieldType != null) {
newVersion = versionFieldType.extractJavaFieldValue(data);
newVersion = versionFieldType.moveToNextValue(newVersion);
args[versionFieldTypeIndex] = versionFieldType.convertJavaFieldToSqlArgValue(newVersion);
}
int rowC = databaseConnection.update(statement, args, argFieldTypes);
if (rowC > 0) {
if (newVersion != null) {
// if we have updated a row then update the version field in our object to the new value
versionFieldType.assignField(connectionSource, data, newVersion, false, null);
}
if (objectCache != null) {
// if we've changed something then see if we need to update our cache
Object id = idField.extractJavaFieldValue(data);
T cachedData = objectCache.get(clazz, id);
if (cachedData != null && cachedData != data) {
// copy each field from the updated data into the cached object
for (FieldType fieldType : tableInfo.getFieldTypes()) {
if (fieldType != idField) {
fieldType.assignField(connectionSource, cachedData,
fieldType.extractJavaFieldValue(data), false, objectCache);
}
}
}
}
}
logger.debug("update data with statement '{}' and {} args, changed {} rows", statement, args.length, rowC);
if (args.length > 0) {
// need to do the (Object) cast to force args to be a single object
logger.trace("update arguments: {}", (Object) args);
}
return rowC;
} catch (SQLException e) {
throw SqlExceptionUtil.create("Unable to run update stmt on object " + data + ": " + statement, e);
}
}
|
[
"public",
"int",
"update",
"(",
"DatabaseConnection",
"databaseConnection",
",",
"T",
"data",
",",
"ObjectCache",
"objectCache",
")",
"throws",
"SQLException",
"{",
"try",
"{",
"// there is always and id field as an argument so just return 0 lines updated",
"if",
"(",
"argFieldTypes",
".",
"length",
"<=",
"1",
")",
"{",
"return",
"0",
";",
"}",
"Object",
"[",
"]",
"args",
"=",
"getFieldObjects",
"(",
"data",
")",
";",
"Object",
"newVersion",
"=",
"null",
";",
"if",
"(",
"versionFieldType",
"!=",
"null",
")",
"{",
"newVersion",
"=",
"versionFieldType",
".",
"extractJavaFieldValue",
"(",
"data",
")",
";",
"newVersion",
"=",
"versionFieldType",
".",
"moveToNextValue",
"(",
"newVersion",
")",
";",
"args",
"[",
"versionFieldTypeIndex",
"]",
"=",
"versionFieldType",
".",
"convertJavaFieldToSqlArgValue",
"(",
"newVersion",
")",
";",
"}",
"int",
"rowC",
"=",
"databaseConnection",
".",
"update",
"(",
"statement",
",",
"args",
",",
"argFieldTypes",
")",
";",
"if",
"(",
"rowC",
">",
"0",
")",
"{",
"if",
"(",
"newVersion",
"!=",
"null",
")",
"{",
"// if we have updated a row then update the version field in our object to the new value",
"versionFieldType",
".",
"assignField",
"(",
"connectionSource",
",",
"data",
",",
"newVersion",
",",
"false",
",",
"null",
")",
";",
"}",
"if",
"(",
"objectCache",
"!=",
"null",
")",
"{",
"// if we've changed something then see if we need to update our cache",
"Object",
"id",
"=",
"idField",
".",
"extractJavaFieldValue",
"(",
"data",
")",
";",
"T",
"cachedData",
"=",
"objectCache",
".",
"get",
"(",
"clazz",
",",
"id",
")",
";",
"if",
"(",
"cachedData",
"!=",
"null",
"&&",
"cachedData",
"!=",
"data",
")",
"{",
"// copy each field from the updated data into the cached object",
"for",
"(",
"FieldType",
"fieldType",
":",
"tableInfo",
".",
"getFieldTypes",
"(",
")",
")",
"{",
"if",
"(",
"fieldType",
"!=",
"idField",
")",
"{",
"fieldType",
".",
"assignField",
"(",
"connectionSource",
",",
"cachedData",
",",
"fieldType",
".",
"extractJavaFieldValue",
"(",
"data",
")",
",",
"false",
",",
"objectCache",
")",
";",
"}",
"}",
"}",
"}",
"}",
"logger",
".",
"debug",
"(",
"\"update data with statement '{}' and {} args, changed {} rows\"",
",",
"statement",
",",
"args",
".",
"length",
",",
"rowC",
")",
";",
"if",
"(",
"args",
".",
"length",
">",
"0",
")",
"{",
"// need to do the (Object) cast to force args to be a single object",
"logger",
".",
"trace",
"(",
"\"update arguments: {}\"",
",",
"(",
"Object",
")",
"args",
")",
";",
"}",
"return",
"rowC",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"SqlExceptionUtil",
".",
"create",
"(",
"\"Unable to run update stmt on object \"",
"+",
"data",
"+",
"\": \"",
"+",
"statement",
",",
"e",
")",
";",
"}",
"}"
] |
Update the object in the database.
|
[
"Update",
"the",
"object",
"in",
"the",
"database",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/stmt/mapped/MappedUpdate.java#L91-L134
|
160,227 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/stmt/mapped/BaseMappedStatement.java
|
BaseMappedStatement.getFieldObjects
|
protected Object[] getFieldObjects(Object data) throws SQLException {
Object[] objects = new Object[argFieldTypes.length];
for (int i = 0; i < argFieldTypes.length; i++) {
FieldType fieldType = argFieldTypes[i];
if (fieldType.isAllowGeneratedIdInsert()) {
objects[i] = fieldType.getFieldValueIfNotDefault(data);
} else {
objects[i] = fieldType.extractJavaFieldToSqlArgValue(data);
}
if (objects[i] == null) {
// NOTE: the default value could be null as well
objects[i] = fieldType.getDefaultValue();
}
}
return objects;
}
|
java
|
protected Object[] getFieldObjects(Object data) throws SQLException {
Object[] objects = new Object[argFieldTypes.length];
for (int i = 0; i < argFieldTypes.length; i++) {
FieldType fieldType = argFieldTypes[i];
if (fieldType.isAllowGeneratedIdInsert()) {
objects[i] = fieldType.getFieldValueIfNotDefault(data);
} else {
objects[i] = fieldType.extractJavaFieldToSqlArgValue(data);
}
if (objects[i] == null) {
// NOTE: the default value could be null as well
objects[i] = fieldType.getDefaultValue();
}
}
return objects;
}
|
[
"protected",
"Object",
"[",
"]",
"getFieldObjects",
"(",
"Object",
"data",
")",
"throws",
"SQLException",
"{",
"Object",
"[",
"]",
"objects",
"=",
"new",
"Object",
"[",
"argFieldTypes",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"argFieldTypes",
".",
"length",
";",
"i",
"++",
")",
"{",
"FieldType",
"fieldType",
"=",
"argFieldTypes",
"[",
"i",
"]",
";",
"if",
"(",
"fieldType",
".",
"isAllowGeneratedIdInsert",
"(",
")",
")",
"{",
"objects",
"[",
"i",
"]",
"=",
"fieldType",
".",
"getFieldValueIfNotDefault",
"(",
"data",
")",
";",
"}",
"else",
"{",
"objects",
"[",
"i",
"]",
"=",
"fieldType",
".",
"extractJavaFieldToSqlArgValue",
"(",
"data",
")",
";",
"}",
"if",
"(",
"objects",
"[",
"i",
"]",
"==",
"null",
")",
"{",
"// NOTE: the default value could be null as well",
"objects",
"[",
"i",
"]",
"=",
"fieldType",
".",
"getDefaultValue",
"(",
")",
";",
"}",
"}",
"return",
"objects",
";",
"}"
] |
Return the array of field objects pulled from the data object.
|
[
"Return",
"the",
"array",
"of",
"field",
"objects",
"pulled",
"from",
"the",
"data",
"object",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/stmt/mapped/BaseMappedStatement.java#L45-L60
|
160,228 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/stmt/mapped/MappedPreparedStmt.java
|
MappedPreparedStmt.assignStatementArguments
|
private CompiledStatement assignStatementArguments(CompiledStatement stmt) throws SQLException {
boolean ok = false;
try {
if (limit != null) {
// we use this if SQL statement LIMITs are not supported by this database type
stmt.setMaxRows(limit.intValue());
}
// set any arguments if we are logging our object
Object[] argValues = null;
if (logger.isLevelEnabled(Level.TRACE) && argHolders.length > 0) {
argValues = new Object[argHolders.length];
}
for (int i = 0; i < argHolders.length; i++) {
Object argValue = argHolders[i].getSqlArgValue();
FieldType fieldType = argFieldTypes[i];
SqlType sqlType;
if (fieldType == null) {
sqlType = argHolders[i].getSqlType();
} else {
sqlType = fieldType.getSqlType();
}
stmt.setObject(i, argValue, sqlType);
if (argValues != null) {
argValues[i] = argValue;
}
}
logger.debug("prepared statement '{}' with {} args", statement, argHolders.length);
if (argValues != null) {
// need to do the (Object) cast to force args to be a single object
logger.trace("prepared statement arguments: {}", (Object) argValues);
}
ok = true;
return stmt;
} finally {
if (!ok) {
IOUtils.closeThrowSqlException(stmt, "statement");
}
}
}
|
java
|
private CompiledStatement assignStatementArguments(CompiledStatement stmt) throws SQLException {
boolean ok = false;
try {
if (limit != null) {
// we use this if SQL statement LIMITs are not supported by this database type
stmt.setMaxRows(limit.intValue());
}
// set any arguments if we are logging our object
Object[] argValues = null;
if (logger.isLevelEnabled(Level.TRACE) && argHolders.length > 0) {
argValues = new Object[argHolders.length];
}
for (int i = 0; i < argHolders.length; i++) {
Object argValue = argHolders[i].getSqlArgValue();
FieldType fieldType = argFieldTypes[i];
SqlType sqlType;
if (fieldType == null) {
sqlType = argHolders[i].getSqlType();
} else {
sqlType = fieldType.getSqlType();
}
stmt.setObject(i, argValue, sqlType);
if (argValues != null) {
argValues[i] = argValue;
}
}
logger.debug("prepared statement '{}' with {} args", statement, argHolders.length);
if (argValues != null) {
// need to do the (Object) cast to force args to be a single object
logger.trace("prepared statement arguments: {}", (Object) argValues);
}
ok = true;
return stmt;
} finally {
if (!ok) {
IOUtils.closeThrowSqlException(stmt, "statement");
}
}
}
|
[
"private",
"CompiledStatement",
"assignStatementArguments",
"(",
"CompiledStatement",
"stmt",
")",
"throws",
"SQLException",
"{",
"boolean",
"ok",
"=",
"false",
";",
"try",
"{",
"if",
"(",
"limit",
"!=",
"null",
")",
"{",
"// we use this if SQL statement LIMITs are not supported by this database type",
"stmt",
".",
"setMaxRows",
"(",
"limit",
".",
"intValue",
"(",
")",
")",
";",
"}",
"// set any arguments if we are logging our object",
"Object",
"[",
"]",
"argValues",
"=",
"null",
";",
"if",
"(",
"logger",
".",
"isLevelEnabled",
"(",
"Level",
".",
"TRACE",
")",
"&&",
"argHolders",
".",
"length",
">",
"0",
")",
"{",
"argValues",
"=",
"new",
"Object",
"[",
"argHolders",
".",
"length",
"]",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"argHolders",
".",
"length",
";",
"i",
"++",
")",
"{",
"Object",
"argValue",
"=",
"argHolders",
"[",
"i",
"]",
".",
"getSqlArgValue",
"(",
")",
";",
"FieldType",
"fieldType",
"=",
"argFieldTypes",
"[",
"i",
"]",
";",
"SqlType",
"sqlType",
";",
"if",
"(",
"fieldType",
"==",
"null",
")",
"{",
"sqlType",
"=",
"argHolders",
"[",
"i",
"]",
".",
"getSqlType",
"(",
")",
";",
"}",
"else",
"{",
"sqlType",
"=",
"fieldType",
".",
"getSqlType",
"(",
")",
";",
"}",
"stmt",
".",
"setObject",
"(",
"i",
",",
"argValue",
",",
"sqlType",
")",
";",
"if",
"(",
"argValues",
"!=",
"null",
")",
"{",
"argValues",
"[",
"i",
"]",
"=",
"argValue",
";",
"}",
"}",
"logger",
".",
"debug",
"(",
"\"prepared statement '{}' with {} args\"",
",",
"statement",
",",
"argHolders",
".",
"length",
")",
";",
"if",
"(",
"argValues",
"!=",
"null",
")",
"{",
"// need to do the (Object) cast to force args to be a single object",
"logger",
".",
"trace",
"(",
"\"prepared statement arguments: {}\"",
",",
"(",
"Object",
")",
"argValues",
")",
";",
"}",
"ok",
"=",
"true",
";",
"return",
"stmt",
";",
"}",
"finally",
"{",
"if",
"(",
"!",
"ok",
")",
"{",
"IOUtils",
".",
"closeThrowSqlException",
"(",
"stmt",
",",
"\"statement\"",
")",
";",
"}",
"}",
"}"
] |
Assign arguments to the statement.
@return The statement passed in or null if it had to be closed on error.
|
[
"Assign",
"arguments",
"to",
"the",
"statement",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/stmt/mapped/MappedPreparedStmt.java#L89-L127
|
160,229 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/support/BaseConnectionSource.java
|
BaseConnectionSource.getSavedConnection
|
protected DatabaseConnection getSavedConnection() {
NestedConnection nested = specialConnection.get();
if (nested == null) {
return null;
} else {
return nested.connection;
}
}
|
java
|
protected DatabaseConnection getSavedConnection() {
NestedConnection nested = specialConnection.get();
if (nested == null) {
return null;
} else {
return nested.connection;
}
}
|
[
"protected",
"DatabaseConnection",
"getSavedConnection",
"(",
")",
"{",
"NestedConnection",
"nested",
"=",
"specialConnection",
".",
"get",
"(",
")",
";",
"if",
"(",
"nested",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"nested",
".",
"connection",
";",
"}",
"}"
] |
Returns the connection that has been saved or null if none.
|
[
"Returns",
"the",
"connection",
"that",
"has",
"been",
"saved",
"or",
"null",
"if",
"none",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/support/BaseConnectionSource.java#L29-L36
|
160,230 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/support/BaseConnectionSource.java
|
BaseConnectionSource.isSavedConnection
|
protected boolean isSavedConnection(DatabaseConnection connection) {
NestedConnection currentSaved = specialConnection.get();
if (currentSaved == null) {
return false;
} else if (currentSaved.connection == connection) {
// ignore the release when we have a saved connection
return true;
} else {
return false;
}
}
|
java
|
protected boolean isSavedConnection(DatabaseConnection connection) {
NestedConnection currentSaved = specialConnection.get();
if (currentSaved == null) {
return false;
} else if (currentSaved.connection == connection) {
// ignore the release when we have a saved connection
return true;
} else {
return false;
}
}
|
[
"protected",
"boolean",
"isSavedConnection",
"(",
"DatabaseConnection",
"connection",
")",
"{",
"NestedConnection",
"currentSaved",
"=",
"specialConnection",
".",
"get",
"(",
")",
";",
"if",
"(",
"currentSaved",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"currentSaved",
".",
"connection",
"==",
"connection",
")",
"{",
"// ignore the release when we have a saved connection",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Return true if the connection being released is the one that has been saved.
|
[
"Return",
"true",
"if",
"the",
"connection",
"being",
"released",
"is",
"the",
"one",
"that",
"has",
"been",
"saved",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/support/BaseConnectionSource.java#L41-L51
|
160,231 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/support/BaseConnectionSource.java
|
BaseConnectionSource.clearSpecial
|
protected boolean clearSpecial(DatabaseConnection connection, Logger logger) {
NestedConnection currentSaved = specialConnection.get();
boolean cleared = false;
if (connection == null) {
// ignored
} else if (currentSaved == null) {
logger.error("no connection has been saved when clear() called");
} else if (currentSaved.connection == connection) {
if (currentSaved.decrementAndGet() == 0) {
// we only clear the connection if nested counter is 0
specialConnection.set(null);
}
cleared = true;
} else {
logger.error("connection saved {} is not the one being cleared {}", currentSaved.connection, connection);
}
// release should then be called after clear
return cleared;
}
|
java
|
protected boolean clearSpecial(DatabaseConnection connection, Logger logger) {
NestedConnection currentSaved = specialConnection.get();
boolean cleared = false;
if (connection == null) {
// ignored
} else if (currentSaved == null) {
logger.error("no connection has been saved when clear() called");
} else if (currentSaved.connection == connection) {
if (currentSaved.decrementAndGet() == 0) {
// we only clear the connection if nested counter is 0
specialConnection.set(null);
}
cleared = true;
} else {
logger.error("connection saved {} is not the one being cleared {}", currentSaved.connection, connection);
}
// release should then be called after clear
return cleared;
}
|
[
"protected",
"boolean",
"clearSpecial",
"(",
"DatabaseConnection",
"connection",
",",
"Logger",
"logger",
")",
"{",
"NestedConnection",
"currentSaved",
"=",
"specialConnection",
".",
"get",
"(",
")",
";",
"boolean",
"cleared",
"=",
"false",
";",
"if",
"(",
"connection",
"==",
"null",
")",
"{",
"// ignored",
"}",
"else",
"if",
"(",
"currentSaved",
"==",
"null",
")",
"{",
"logger",
".",
"error",
"(",
"\"no connection has been saved when clear() called\"",
")",
";",
"}",
"else",
"if",
"(",
"currentSaved",
".",
"connection",
"==",
"connection",
")",
"{",
"if",
"(",
"currentSaved",
".",
"decrementAndGet",
"(",
")",
"==",
"0",
")",
"{",
"// we only clear the connection if nested counter is 0",
"specialConnection",
".",
"set",
"(",
"null",
")",
";",
"}",
"cleared",
"=",
"true",
";",
"}",
"else",
"{",
"logger",
".",
"error",
"(",
"\"connection saved {} is not the one being cleared {}\"",
",",
"currentSaved",
".",
"connection",
",",
"connection",
")",
";",
"}",
"// release should then be called after clear",
"return",
"cleared",
";",
"}"
] |
Clear the connection that was previously saved.
@return True if the connection argument had been saved.
|
[
"Clear",
"the",
"connection",
"that",
"was",
"previously",
"saved",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/support/BaseConnectionSource.java#L80-L98
|
160,232 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/support/BaseConnectionSource.java
|
BaseConnectionSource.isSingleConnection
|
protected boolean isSingleConnection(DatabaseConnection conn1, DatabaseConnection conn2) throws SQLException {
// initialize the connections auto-commit flags
conn1.setAutoCommit(true);
conn2.setAutoCommit(true);
try {
// change conn1's auto-commit to be false
conn1.setAutoCommit(false);
if (conn2.isAutoCommit()) {
// if the 2nd connection's auto-commit is still true then we have multiple connections
return false;
} else {
// if the 2nd connection's auto-commit is also false then we have a single connection
return true;
}
} finally {
// restore its auto-commit
conn1.setAutoCommit(true);
}
}
|
java
|
protected boolean isSingleConnection(DatabaseConnection conn1, DatabaseConnection conn2) throws SQLException {
// initialize the connections auto-commit flags
conn1.setAutoCommit(true);
conn2.setAutoCommit(true);
try {
// change conn1's auto-commit to be false
conn1.setAutoCommit(false);
if (conn2.isAutoCommit()) {
// if the 2nd connection's auto-commit is still true then we have multiple connections
return false;
} else {
// if the 2nd connection's auto-commit is also false then we have a single connection
return true;
}
} finally {
// restore its auto-commit
conn1.setAutoCommit(true);
}
}
|
[
"protected",
"boolean",
"isSingleConnection",
"(",
"DatabaseConnection",
"conn1",
",",
"DatabaseConnection",
"conn2",
")",
"throws",
"SQLException",
"{",
"// initialize the connections auto-commit flags",
"conn1",
".",
"setAutoCommit",
"(",
"true",
")",
";",
"conn2",
".",
"setAutoCommit",
"(",
"true",
")",
";",
"try",
"{",
"// change conn1's auto-commit to be false",
"conn1",
".",
"setAutoCommit",
"(",
"false",
")",
";",
"if",
"(",
"conn2",
".",
"isAutoCommit",
"(",
")",
")",
"{",
"// if the 2nd connection's auto-commit is still true then we have multiple connections",
"return",
"false",
";",
"}",
"else",
"{",
"// if the 2nd connection's auto-commit is also false then we have a single connection",
"return",
"true",
";",
"}",
"}",
"finally",
"{",
"// restore its auto-commit",
"conn1",
".",
"setAutoCommit",
"(",
"true",
")",
";",
"}",
"}"
] |
Return true if the two connections seem to one one connection under the covers.
|
[
"Return",
"true",
"if",
"the",
"two",
"connections",
"seem",
"to",
"one",
"one",
"connection",
"under",
"the",
"covers",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/support/BaseConnectionSource.java#L103-L121
|
160,233 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/table/DatabaseTableConfigLoader.java
|
DatabaseTableConfigLoader.loadDatabaseConfigFromReader
|
public static List<DatabaseTableConfig<?>> loadDatabaseConfigFromReader(BufferedReader reader) throws SQLException {
List<DatabaseTableConfig<?>> list = new ArrayList<DatabaseTableConfig<?>>();
while (true) {
DatabaseTableConfig<?> config = DatabaseTableConfigLoader.fromReader(reader);
if (config == null) {
break;
}
list.add(config);
}
return list;
}
|
java
|
public static List<DatabaseTableConfig<?>> loadDatabaseConfigFromReader(BufferedReader reader) throws SQLException {
List<DatabaseTableConfig<?>> list = new ArrayList<DatabaseTableConfig<?>>();
while (true) {
DatabaseTableConfig<?> config = DatabaseTableConfigLoader.fromReader(reader);
if (config == null) {
break;
}
list.add(config);
}
return list;
}
|
[
"public",
"static",
"List",
"<",
"DatabaseTableConfig",
"<",
"?",
">",
">",
"loadDatabaseConfigFromReader",
"(",
"BufferedReader",
"reader",
")",
"throws",
"SQLException",
"{",
"List",
"<",
"DatabaseTableConfig",
"<",
"?",
">",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"DatabaseTableConfig",
"<",
"?",
">",
">",
"(",
")",
";",
"while",
"(",
"true",
")",
"{",
"DatabaseTableConfig",
"<",
"?",
">",
"config",
"=",
"DatabaseTableConfigLoader",
".",
"fromReader",
"(",
"reader",
")",
";",
"if",
"(",
"config",
"==",
"null",
")",
"{",
"break",
";",
"}",
"list",
".",
"add",
"(",
"config",
")",
";",
"}",
"return",
"list",
";",
"}"
] |
Load in a number of database configuration entries from a buffered reader.
|
[
"Load",
"in",
"a",
"number",
"of",
"database",
"configuration",
"entries",
"from",
"a",
"buffered",
"reader",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/table/DatabaseTableConfigLoader.java#L29-L39
|
160,234 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/table/DatabaseTableConfigLoader.java
|
DatabaseTableConfigLoader.fromReader
|
public static <T> DatabaseTableConfig<T> fromReader(BufferedReader reader) throws SQLException {
DatabaseTableConfig<T> config = new DatabaseTableConfig<T>();
boolean anything = false;
while (true) {
String line;
try {
line = reader.readLine();
} catch (IOException e) {
throw SqlExceptionUtil.create("Could not read DatabaseTableConfig from stream", e);
}
if (line == null) {
break;
}
// we do this so we can support multiple class configs per file
if (line.equals(CONFIG_FILE_END_MARKER)) {
break;
}
// we do this so we can support multiple class configs per file
if (line.equals(CONFIG_FILE_FIELDS_START)) {
readFields(reader, config);
continue;
}
// skip empty lines or comments
if (line.length() == 0 || line.startsWith("#") || line.equals(CONFIG_FILE_START_MARKER)) {
continue;
}
String[] parts = line.split("=", -2);
if (parts.length != 2) {
throw new SQLException("DatabaseTableConfig reading from stream cannot parse line: " + line);
}
readTableField(config, parts[0], parts[1]);
anything = true;
}
// if we got any config lines then we return the config
if (anything) {
return config;
} else {
// otherwise we return null for none
return null;
}
}
|
java
|
public static <T> DatabaseTableConfig<T> fromReader(BufferedReader reader) throws SQLException {
DatabaseTableConfig<T> config = new DatabaseTableConfig<T>();
boolean anything = false;
while (true) {
String line;
try {
line = reader.readLine();
} catch (IOException e) {
throw SqlExceptionUtil.create("Could not read DatabaseTableConfig from stream", e);
}
if (line == null) {
break;
}
// we do this so we can support multiple class configs per file
if (line.equals(CONFIG_FILE_END_MARKER)) {
break;
}
// we do this so we can support multiple class configs per file
if (line.equals(CONFIG_FILE_FIELDS_START)) {
readFields(reader, config);
continue;
}
// skip empty lines or comments
if (line.length() == 0 || line.startsWith("#") || line.equals(CONFIG_FILE_START_MARKER)) {
continue;
}
String[] parts = line.split("=", -2);
if (parts.length != 2) {
throw new SQLException("DatabaseTableConfig reading from stream cannot parse line: " + line);
}
readTableField(config, parts[0], parts[1]);
anything = true;
}
// if we got any config lines then we return the config
if (anything) {
return config;
} else {
// otherwise we return null for none
return null;
}
}
|
[
"public",
"static",
"<",
"T",
">",
"DatabaseTableConfig",
"<",
"T",
">",
"fromReader",
"(",
"BufferedReader",
"reader",
")",
"throws",
"SQLException",
"{",
"DatabaseTableConfig",
"<",
"T",
">",
"config",
"=",
"new",
"DatabaseTableConfig",
"<",
"T",
">",
"(",
")",
";",
"boolean",
"anything",
"=",
"false",
";",
"while",
"(",
"true",
")",
"{",
"String",
"line",
";",
"try",
"{",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"SqlExceptionUtil",
".",
"create",
"(",
"\"Could not read DatabaseTableConfig from stream\"",
",",
"e",
")",
";",
"}",
"if",
"(",
"line",
"==",
"null",
")",
"{",
"break",
";",
"}",
"// we do this so we can support multiple class configs per file",
"if",
"(",
"line",
".",
"equals",
"(",
"CONFIG_FILE_END_MARKER",
")",
")",
"{",
"break",
";",
"}",
"// we do this so we can support multiple class configs per file",
"if",
"(",
"line",
".",
"equals",
"(",
"CONFIG_FILE_FIELDS_START",
")",
")",
"{",
"readFields",
"(",
"reader",
",",
"config",
")",
";",
"continue",
";",
"}",
"// skip empty lines or comments",
"if",
"(",
"line",
".",
"length",
"(",
")",
"==",
"0",
"||",
"line",
".",
"startsWith",
"(",
"\"#\"",
")",
"||",
"line",
".",
"equals",
"(",
"CONFIG_FILE_START_MARKER",
")",
")",
"{",
"continue",
";",
"}",
"String",
"[",
"]",
"parts",
"=",
"line",
".",
"split",
"(",
"\"=\"",
",",
"-",
"2",
")",
";",
"if",
"(",
"parts",
".",
"length",
"!=",
"2",
")",
"{",
"throw",
"new",
"SQLException",
"(",
"\"DatabaseTableConfig reading from stream cannot parse line: \"",
"+",
"line",
")",
";",
"}",
"readTableField",
"(",
"config",
",",
"parts",
"[",
"0",
"]",
",",
"parts",
"[",
"1",
"]",
")",
";",
"anything",
"=",
"true",
";",
"}",
"// if we got any config lines then we return the config",
"if",
"(",
"anything",
")",
"{",
"return",
"config",
";",
"}",
"else",
"{",
"// otherwise we return null for none",
"return",
"null",
";",
"}",
"}"
] |
Load a table configuration in from a text-file reader.
@return A config if any of the fields were set otherwise null if we reach EOF.
|
[
"Load",
"a",
"table",
"configuration",
"in",
"from",
"a",
"text",
"-",
"file",
"reader",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/table/DatabaseTableConfigLoader.java#L46-L86
|
160,235 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/table/DatabaseTableConfigLoader.java
|
DatabaseTableConfigLoader.write
|
public static <T> void write(BufferedWriter writer, DatabaseTableConfig<T> config) throws SQLException {
try {
writeConfig(writer, config);
} catch (IOException e) {
throw SqlExceptionUtil.create("Could not write config to writer", e);
}
}
|
java
|
public static <T> void write(BufferedWriter writer, DatabaseTableConfig<T> config) throws SQLException {
try {
writeConfig(writer, config);
} catch (IOException e) {
throw SqlExceptionUtil.create("Could not write config to writer", e);
}
}
|
[
"public",
"static",
"<",
"T",
">",
"void",
"write",
"(",
"BufferedWriter",
"writer",
",",
"DatabaseTableConfig",
"<",
"T",
">",
"config",
")",
"throws",
"SQLException",
"{",
"try",
"{",
"writeConfig",
"(",
"writer",
",",
"config",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"SqlExceptionUtil",
".",
"create",
"(",
"\"Could not write config to writer\"",
",",
"e",
")",
";",
"}",
"}"
] |
Write the table configuration to a buffered writer.
|
[
"Write",
"the",
"table",
"configuration",
"to",
"a",
"buffered",
"writer",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/table/DatabaseTableConfigLoader.java#L91-L97
|
160,236 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/table/DatabaseTableConfigLoader.java
|
DatabaseTableConfigLoader.writeConfig
|
private static <T> void writeConfig(BufferedWriter writer, DatabaseTableConfig<T> config) throws IOException,
SQLException {
writer.append(CONFIG_FILE_START_MARKER);
writer.newLine();
if (config.getDataClass() != null) {
writer.append(FIELD_NAME_DATA_CLASS).append('=').append(config.getDataClass().getName());
writer.newLine();
}
if (config.getTableName() != null) {
writer.append(FIELD_NAME_TABLE_NAME).append('=').append(config.getTableName());
writer.newLine();
}
writer.append(CONFIG_FILE_FIELDS_START);
writer.newLine();
if (config.getFieldConfigs() != null) {
for (DatabaseFieldConfig field : config.getFieldConfigs()) {
DatabaseFieldConfigLoader.write(writer, field, config.getTableName());
}
}
writer.append(CONFIG_FILE_FIELDS_END);
writer.newLine();
writer.append(CONFIG_FILE_END_MARKER);
writer.newLine();
}
|
java
|
private static <T> void writeConfig(BufferedWriter writer, DatabaseTableConfig<T> config) throws IOException,
SQLException {
writer.append(CONFIG_FILE_START_MARKER);
writer.newLine();
if (config.getDataClass() != null) {
writer.append(FIELD_NAME_DATA_CLASS).append('=').append(config.getDataClass().getName());
writer.newLine();
}
if (config.getTableName() != null) {
writer.append(FIELD_NAME_TABLE_NAME).append('=').append(config.getTableName());
writer.newLine();
}
writer.append(CONFIG_FILE_FIELDS_START);
writer.newLine();
if (config.getFieldConfigs() != null) {
for (DatabaseFieldConfig field : config.getFieldConfigs()) {
DatabaseFieldConfigLoader.write(writer, field, config.getTableName());
}
}
writer.append(CONFIG_FILE_FIELDS_END);
writer.newLine();
writer.append(CONFIG_FILE_END_MARKER);
writer.newLine();
}
|
[
"private",
"static",
"<",
"T",
">",
"void",
"writeConfig",
"(",
"BufferedWriter",
"writer",
",",
"DatabaseTableConfig",
"<",
"T",
">",
"config",
")",
"throws",
"IOException",
",",
"SQLException",
"{",
"writer",
".",
"append",
"(",
"CONFIG_FILE_START_MARKER",
")",
";",
"writer",
".",
"newLine",
"(",
")",
";",
"if",
"(",
"config",
".",
"getDataClass",
"(",
")",
"!=",
"null",
")",
"{",
"writer",
".",
"append",
"(",
"FIELD_NAME_DATA_CLASS",
")",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"config",
".",
"getDataClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"writer",
".",
"newLine",
"(",
")",
";",
"}",
"if",
"(",
"config",
".",
"getTableName",
"(",
")",
"!=",
"null",
")",
"{",
"writer",
".",
"append",
"(",
"FIELD_NAME_TABLE_NAME",
")",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"config",
".",
"getTableName",
"(",
")",
")",
";",
"writer",
".",
"newLine",
"(",
")",
";",
"}",
"writer",
".",
"append",
"(",
"CONFIG_FILE_FIELDS_START",
")",
";",
"writer",
".",
"newLine",
"(",
")",
";",
"if",
"(",
"config",
".",
"getFieldConfigs",
"(",
")",
"!=",
"null",
")",
"{",
"for",
"(",
"DatabaseFieldConfig",
"field",
":",
"config",
".",
"getFieldConfigs",
"(",
")",
")",
"{",
"DatabaseFieldConfigLoader",
".",
"write",
"(",
"writer",
",",
"field",
",",
"config",
".",
"getTableName",
"(",
")",
")",
";",
"}",
"}",
"writer",
".",
"append",
"(",
"CONFIG_FILE_FIELDS_END",
")",
";",
"writer",
".",
"newLine",
"(",
")",
";",
"writer",
".",
"append",
"(",
"CONFIG_FILE_END_MARKER",
")",
";",
"writer",
".",
"newLine",
"(",
")",
";",
"}"
] |
Write the config to the writer.
|
[
"Write",
"the",
"config",
"to",
"the",
"writer",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/table/DatabaseTableConfigLoader.java#L106-L129
|
160,237 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/table/DatabaseTableConfigLoader.java
|
DatabaseTableConfigLoader.readTableField
|
private static <T> void readTableField(DatabaseTableConfig<T> config, String field, String value) {
if (field.equals(FIELD_NAME_DATA_CLASS)) {
try {
@SuppressWarnings("unchecked")
Class<T> clazz = (Class<T>) Class.forName(value);
config.setDataClass(clazz);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Unknown class specified for dataClass: " + value);
}
} else if (field.equals(FIELD_NAME_TABLE_NAME)) {
config.setTableName(value);
}
}
|
java
|
private static <T> void readTableField(DatabaseTableConfig<T> config, String field, String value) {
if (field.equals(FIELD_NAME_DATA_CLASS)) {
try {
@SuppressWarnings("unchecked")
Class<T> clazz = (Class<T>) Class.forName(value);
config.setDataClass(clazz);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Unknown class specified for dataClass: " + value);
}
} else if (field.equals(FIELD_NAME_TABLE_NAME)) {
config.setTableName(value);
}
}
|
[
"private",
"static",
"<",
"T",
">",
"void",
"readTableField",
"(",
"DatabaseTableConfig",
"<",
"T",
">",
"config",
",",
"String",
"field",
",",
"String",
"value",
")",
"{",
"if",
"(",
"field",
".",
"equals",
"(",
"FIELD_NAME_DATA_CLASS",
")",
")",
"{",
"try",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Class",
"<",
"T",
">",
"clazz",
"=",
"(",
"Class",
"<",
"T",
">",
")",
"Class",
".",
"forName",
"(",
"value",
")",
";",
"config",
".",
"setDataClass",
"(",
"clazz",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unknown class specified for dataClass: \"",
"+",
"value",
")",
";",
"}",
"}",
"else",
"if",
"(",
"field",
".",
"equals",
"(",
"FIELD_NAME_TABLE_NAME",
")",
")",
"{",
"config",
".",
"setTableName",
"(",
"value",
")",
";",
"}",
"}"
] |
Read a field into our table configuration for field=value line.
|
[
"Read",
"a",
"field",
"into",
"our",
"table",
"configuration",
"for",
"field",
"=",
"value",
"line",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/table/DatabaseTableConfigLoader.java#L134-L146
|
160,238 |
j256/ormlite-core
|
src/main/java/com/j256/ormlite/table/DatabaseTableConfigLoader.java
|
DatabaseTableConfigLoader.readFields
|
private static <T> void readFields(BufferedReader reader, DatabaseTableConfig<T> config) throws SQLException {
List<DatabaseFieldConfig> fields = new ArrayList<DatabaseFieldConfig>();
while (true) {
String line;
try {
line = reader.readLine();
} catch (IOException e) {
throw SqlExceptionUtil.create("Could not read next field from config file", e);
}
if (line == null || line.equals(CONFIG_FILE_FIELDS_END)) {
break;
}
DatabaseFieldConfig fieldConfig = DatabaseFieldConfigLoader.fromReader(reader);
if (fieldConfig == null) {
break;
}
fields.add(fieldConfig);
}
config.setFieldConfigs(fields);
}
|
java
|
private static <T> void readFields(BufferedReader reader, DatabaseTableConfig<T> config) throws SQLException {
List<DatabaseFieldConfig> fields = new ArrayList<DatabaseFieldConfig>();
while (true) {
String line;
try {
line = reader.readLine();
} catch (IOException e) {
throw SqlExceptionUtil.create("Could not read next field from config file", e);
}
if (line == null || line.equals(CONFIG_FILE_FIELDS_END)) {
break;
}
DatabaseFieldConfig fieldConfig = DatabaseFieldConfigLoader.fromReader(reader);
if (fieldConfig == null) {
break;
}
fields.add(fieldConfig);
}
config.setFieldConfigs(fields);
}
|
[
"private",
"static",
"<",
"T",
">",
"void",
"readFields",
"(",
"BufferedReader",
"reader",
",",
"DatabaseTableConfig",
"<",
"T",
">",
"config",
")",
"throws",
"SQLException",
"{",
"List",
"<",
"DatabaseFieldConfig",
">",
"fields",
"=",
"new",
"ArrayList",
"<",
"DatabaseFieldConfig",
">",
"(",
")",
";",
"while",
"(",
"true",
")",
"{",
"String",
"line",
";",
"try",
"{",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"SqlExceptionUtil",
".",
"create",
"(",
"\"Could not read next field from config file\"",
",",
"e",
")",
";",
"}",
"if",
"(",
"line",
"==",
"null",
"||",
"line",
".",
"equals",
"(",
"CONFIG_FILE_FIELDS_END",
")",
")",
"{",
"break",
";",
"}",
"DatabaseFieldConfig",
"fieldConfig",
"=",
"DatabaseFieldConfigLoader",
".",
"fromReader",
"(",
"reader",
")",
";",
"if",
"(",
"fieldConfig",
"==",
"null",
")",
"{",
"break",
";",
"}",
"fields",
".",
"add",
"(",
"fieldConfig",
")",
";",
"}",
"config",
".",
"setFieldConfigs",
"(",
"fields",
")",
";",
"}"
] |
Read all of the fields information from the configuration file.
|
[
"Read",
"all",
"of",
"the",
"fields",
"information",
"from",
"the",
"configuration",
"file",
"."
] |
154d85bbb9614a0ea65a012251257831fb4fba21
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/table/DatabaseTableConfigLoader.java#L151-L170
|
160,239 |
HubSpot/jackson-datatype-protobuf
|
src/main/java/com/hubspot/jackson/datatype/protobuf/ProtobufDeserializer.java
|
ProtobufDeserializer.readKey
|
private Object readKey(
FieldDescriptor field,
JsonParser parser,
DeserializationContext context
) throws IOException {
if (parser.getCurrentToken() != JsonToken.FIELD_NAME) {
throw reportWrongToken(JsonToken.FIELD_NAME, context, "Expected FIELD_NAME token");
}
String fieldName = parser.getCurrentName();
switch (field.getJavaType()) {
case INT:
// lifted from StdDeserializer since there's no method to call
try {
return NumberInput.parseInt(fieldName.trim());
} catch (IllegalArgumentException iae) {
Number number = (Number) context.handleWeirdStringValue(
_valueClass,
fieldName.trim(),
"not a valid int value"
);
return number == null ? 0 : number.intValue();
}
case LONG:
// lifted from StdDeserializer since there's no method to call
try {
return NumberInput.parseLong(fieldName.trim());
} catch (IllegalArgumentException iae) {
Number number = (Number) context.handleWeirdStringValue(
_valueClass,
fieldName.trim(),
"not a valid long value"
);
return number == null ? 0L : number.longValue();
}
case BOOLEAN:
// lifted from StdDeserializer since there's no method to call
String text = fieldName.trim();
if ("true".equals(text) || "True".equals(text)) {
return true;
}
if ("false".equals(text) || "False".equals(text)) {
return false;
}
Boolean b = (Boolean) context.handleWeirdStringValue(
_valueClass,
text,
"only \"true\" or \"false\" recognized"
);
return Boolean.TRUE.equals(b);
case STRING:
return fieldName;
case ENUM:
EnumValueDescriptor enumValueDescriptor = field.getEnumType().findValueByName(parser.getText());
if (enumValueDescriptor == null && !ignorableEnum(parser.getText().trim(), context)) {
throw context.weirdStringException(parser.getText(), field.getEnumType().getClass(),
"value not one of declared Enum instance names");
}
return enumValueDescriptor;
default:
throw new IllegalArgumentException("Unexpected map key type: " + field.getJavaType());
}
}
|
java
|
private Object readKey(
FieldDescriptor field,
JsonParser parser,
DeserializationContext context
) throws IOException {
if (parser.getCurrentToken() != JsonToken.FIELD_NAME) {
throw reportWrongToken(JsonToken.FIELD_NAME, context, "Expected FIELD_NAME token");
}
String fieldName = parser.getCurrentName();
switch (field.getJavaType()) {
case INT:
// lifted from StdDeserializer since there's no method to call
try {
return NumberInput.parseInt(fieldName.trim());
} catch (IllegalArgumentException iae) {
Number number = (Number) context.handleWeirdStringValue(
_valueClass,
fieldName.trim(),
"not a valid int value"
);
return number == null ? 0 : number.intValue();
}
case LONG:
// lifted from StdDeserializer since there's no method to call
try {
return NumberInput.parseLong(fieldName.trim());
} catch (IllegalArgumentException iae) {
Number number = (Number) context.handleWeirdStringValue(
_valueClass,
fieldName.trim(),
"not a valid long value"
);
return number == null ? 0L : number.longValue();
}
case BOOLEAN:
// lifted from StdDeserializer since there's no method to call
String text = fieldName.trim();
if ("true".equals(text) || "True".equals(text)) {
return true;
}
if ("false".equals(text) || "False".equals(text)) {
return false;
}
Boolean b = (Boolean) context.handleWeirdStringValue(
_valueClass,
text,
"only \"true\" or \"false\" recognized"
);
return Boolean.TRUE.equals(b);
case STRING:
return fieldName;
case ENUM:
EnumValueDescriptor enumValueDescriptor = field.getEnumType().findValueByName(parser.getText());
if (enumValueDescriptor == null && !ignorableEnum(parser.getText().trim(), context)) {
throw context.weirdStringException(parser.getText(), field.getEnumType().getClass(),
"value not one of declared Enum instance names");
}
return enumValueDescriptor;
default:
throw new IllegalArgumentException("Unexpected map key type: " + field.getJavaType());
}
}
|
[
"private",
"Object",
"readKey",
"(",
"FieldDescriptor",
"field",
",",
"JsonParser",
"parser",
",",
"DeserializationContext",
"context",
")",
"throws",
"IOException",
"{",
"if",
"(",
"parser",
".",
"getCurrentToken",
"(",
")",
"!=",
"JsonToken",
".",
"FIELD_NAME",
")",
"{",
"throw",
"reportWrongToken",
"(",
"JsonToken",
".",
"FIELD_NAME",
",",
"context",
",",
"\"Expected FIELD_NAME token\"",
")",
";",
"}",
"String",
"fieldName",
"=",
"parser",
".",
"getCurrentName",
"(",
")",
";",
"switch",
"(",
"field",
".",
"getJavaType",
"(",
")",
")",
"{",
"case",
"INT",
":",
"// lifted from StdDeserializer since there's no method to call",
"try",
"{",
"return",
"NumberInput",
".",
"parseInt",
"(",
"fieldName",
".",
"trim",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"iae",
")",
"{",
"Number",
"number",
"=",
"(",
"Number",
")",
"context",
".",
"handleWeirdStringValue",
"(",
"_valueClass",
",",
"fieldName",
".",
"trim",
"(",
")",
",",
"\"not a valid int value\"",
")",
";",
"return",
"number",
"==",
"null",
"?",
"0",
":",
"number",
".",
"intValue",
"(",
")",
";",
"}",
"case",
"LONG",
":",
"// lifted from StdDeserializer since there's no method to call",
"try",
"{",
"return",
"NumberInput",
".",
"parseLong",
"(",
"fieldName",
".",
"trim",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"iae",
")",
"{",
"Number",
"number",
"=",
"(",
"Number",
")",
"context",
".",
"handleWeirdStringValue",
"(",
"_valueClass",
",",
"fieldName",
".",
"trim",
"(",
")",
",",
"\"not a valid long value\"",
")",
";",
"return",
"number",
"==",
"null",
"?",
"0L",
":",
"number",
".",
"longValue",
"(",
")",
";",
"}",
"case",
"BOOLEAN",
":",
"// lifted from StdDeserializer since there's no method to call",
"String",
"text",
"=",
"fieldName",
".",
"trim",
"(",
")",
";",
"if",
"(",
"\"true\"",
".",
"equals",
"(",
"text",
")",
"||",
"\"True\"",
".",
"equals",
"(",
"text",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"\"false\"",
".",
"equals",
"(",
"text",
")",
"||",
"\"False\"",
".",
"equals",
"(",
"text",
")",
")",
"{",
"return",
"false",
";",
"}",
"Boolean",
"b",
"=",
"(",
"Boolean",
")",
"context",
".",
"handleWeirdStringValue",
"(",
"_valueClass",
",",
"text",
",",
"\"only \\\"true\\\" or \\\"false\\\" recognized\"",
")",
";",
"return",
"Boolean",
".",
"TRUE",
".",
"equals",
"(",
"b",
")",
";",
"case",
"STRING",
":",
"return",
"fieldName",
";",
"case",
"ENUM",
":",
"EnumValueDescriptor",
"enumValueDescriptor",
"=",
"field",
".",
"getEnumType",
"(",
")",
".",
"findValueByName",
"(",
"parser",
".",
"getText",
"(",
")",
")",
";",
"if",
"(",
"enumValueDescriptor",
"==",
"null",
"&&",
"!",
"ignorableEnum",
"(",
"parser",
".",
"getText",
"(",
")",
".",
"trim",
"(",
")",
",",
"context",
")",
")",
"{",
"throw",
"context",
".",
"weirdStringException",
"(",
"parser",
".",
"getText",
"(",
")",
",",
"field",
".",
"getEnumType",
"(",
")",
".",
"getClass",
"(",
")",
",",
"\"value not one of declared Enum instance names\"",
")",
";",
"}",
"return",
"enumValueDescriptor",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unexpected map key type: \"",
"+",
"field",
".",
"getJavaType",
"(",
")",
")",
";",
"}",
"}"
] |
Specialized version of readValue just for reading map keys, because the StdDeserializer methods like
_parseIntPrimitive blow up when the current JsonToken is FIELD_NAME
|
[
"Specialized",
"version",
"of",
"readValue",
"just",
"for",
"reading",
"map",
"keys",
"because",
"the",
"StdDeserializer",
"methods",
"like",
"_parseIntPrimitive",
"blow",
"up",
"when",
"the",
"current",
"JsonToken",
"is",
"FIELD_NAME"
] |
33c6c8085421387d43770c6599fe1b9cb27ad10e
|
https://github.com/HubSpot/jackson-datatype-protobuf/blob/33c6c8085421387d43770c6599fe1b9cb27ad10e/src/main/java/com/hubspot/jackson/datatype/protobuf/ProtobufDeserializer.java#L132-L196
|
160,240 |
bujiio/buji-pac4j
|
src/main/java/io/buji/pac4j/util/ShiroHelper.java
|
ShiroHelper.populateSubject
|
public static void populateSubject(final LinkedHashMap<String, CommonProfile> profiles) {
if (profiles != null && profiles.size() > 0) {
final List<CommonProfile> listProfiles = ProfileHelper.flatIntoAProfileList(profiles);
try {
if (IS_FULLY_AUTHENTICATED_AUTHORIZER.isAuthorized(null, listProfiles)) {
SecurityUtils.getSubject().login(new Pac4jToken(listProfiles, false));
} else if (IS_REMEMBERED_AUTHORIZER.isAuthorized(null, listProfiles)) {
SecurityUtils.getSubject().login(new Pac4jToken(listProfiles, true));
}
} catch (final HttpAction e) {
throw new TechnicalException(e);
}
}
}
|
java
|
public static void populateSubject(final LinkedHashMap<String, CommonProfile> profiles) {
if (profiles != null && profiles.size() > 0) {
final List<CommonProfile> listProfiles = ProfileHelper.flatIntoAProfileList(profiles);
try {
if (IS_FULLY_AUTHENTICATED_AUTHORIZER.isAuthorized(null, listProfiles)) {
SecurityUtils.getSubject().login(new Pac4jToken(listProfiles, false));
} else if (IS_REMEMBERED_AUTHORIZER.isAuthorized(null, listProfiles)) {
SecurityUtils.getSubject().login(new Pac4jToken(listProfiles, true));
}
} catch (final HttpAction e) {
throw new TechnicalException(e);
}
}
}
|
[
"public",
"static",
"void",
"populateSubject",
"(",
"final",
"LinkedHashMap",
"<",
"String",
",",
"CommonProfile",
">",
"profiles",
")",
"{",
"if",
"(",
"profiles",
"!=",
"null",
"&&",
"profiles",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"final",
"List",
"<",
"CommonProfile",
">",
"listProfiles",
"=",
"ProfileHelper",
".",
"flatIntoAProfileList",
"(",
"profiles",
")",
";",
"try",
"{",
"if",
"(",
"IS_FULLY_AUTHENTICATED_AUTHORIZER",
".",
"isAuthorized",
"(",
"null",
",",
"listProfiles",
")",
")",
"{",
"SecurityUtils",
".",
"getSubject",
"(",
")",
".",
"login",
"(",
"new",
"Pac4jToken",
"(",
"listProfiles",
",",
"false",
")",
")",
";",
"}",
"else",
"if",
"(",
"IS_REMEMBERED_AUTHORIZER",
".",
"isAuthorized",
"(",
"null",
",",
"listProfiles",
")",
")",
"{",
"SecurityUtils",
".",
"getSubject",
"(",
")",
".",
"login",
"(",
"new",
"Pac4jToken",
"(",
"listProfiles",
",",
"true",
")",
")",
";",
"}",
"}",
"catch",
"(",
"final",
"HttpAction",
"e",
")",
"{",
"throw",
"new",
"TechnicalException",
"(",
"e",
")",
";",
"}",
"}",
"}"
] |
Populate the authenticated user profiles in the Shiro subject.
@param profiles the linked hashmap of profiles
|
[
"Populate",
"the",
"authenticated",
"user",
"profiles",
"in",
"the",
"Shiro",
"subject",
"."
] |
5ce149161f359074df09bc47b9f2aed8e17141a2
|
https://github.com/bujiio/buji-pac4j/blob/5ce149161f359074df09bc47b9f2aed8e17141a2/src/main/java/io/buji/pac4j/util/ShiroHelper.java#L51-L64
|
160,241 |
bujiio/buji-pac4j
|
src/main/java/io/buji/pac4j/subject/Pac4jPrincipal.java
|
Pac4jPrincipal.getName
|
@Override
public String getName() {
CommonProfile profile = this.getProfile();
if(null == principalNameAttribute) {
return profile.getId();
}
Object attrValue = profile.getAttribute(principalNameAttribute);
return (null == attrValue) ? null : String.valueOf(attrValue);
}
|
java
|
@Override
public String getName() {
CommonProfile profile = this.getProfile();
if(null == principalNameAttribute) {
return profile.getId();
}
Object attrValue = profile.getAttribute(principalNameAttribute);
return (null == attrValue) ? null : String.valueOf(attrValue);
}
|
[
"@",
"Override",
"public",
"String",
"getName",
"(",
")",
"{",
"CommonProfile",
"profile",
"=",
"this",
".",
"getProfile",
"(",
")",
";",
"if",
"(",
"null",
"==",
"principalNameAttribute",
")",
"{",
"return",
"profile",
".",
"getId",
"(",
")",
";",
"}",
"Object",
"attrValue",
"=",
"profile",
".",
"getAttribute",
"(",
"principalNameAttribute",
")",
";",
"return",
"(",
"null",
"==",
"attrValue",
")",
"?",
"null",
":",
"String",
".",
"valueOf",
"(",
"attrValue",
")",
";",
"}"
] |
Returns a name for the principal based upon one of the attributes
of the main CommonProfile. The attribute name used to query the CommonProfile
is specified in the constructor.
@return a name for the Principal or null if the attribute is not populated.
|
[
"Returns",
"a",
"name",
"for",
"the",
"principal",
"based",
"upon",
"one",
"of",
"the",
"attributes",
"of",
"the",
"main",
"CommonProfile",
".",
"The",
"attribute",
"name",
"used",
"to",
"query",
"the",
"CommonProfile",
"is",
"specified",
"in",
"the",
"constructor",
"."
] |
5ce149161f359074df09bc47b9f2aed8e17141a2
|
https://github.com/bujiio/buji-pac4j/blob/5ce149161f359074df09bc47b9f2aed8e17141a2/src/main/java/io/buji/pac4j/subject/Pac4jPrincipal.java#L107-L115
|
160,242 |
Talend/tesb-rt-se
|
examples/tesb/library-service/common/src/main/java/org/talend/services/demos/common/Utils.java
|
Utils.showBooks
|
public static void showBooks(final ListOfBooks booksList){
if(booksList != null && booksList.getBook() != null && !booksList.getBook().isEmpty()){
List<BookType> books = booksList.getBook();
System.out.println("\nNumber of books: " + books.size());
int cnt = 0;
for (BookType book : books) {
System.out.println("\nBookNum: " + (cnt++ + 1));
List<PersonType> authors = book.getAuthor();
if(authors != null && !authors.isEmpty()){
for (PersonType author : authors) {
System.out.println("Author: " + author.getFirstName() +
" " + author.getLastName());
}
}
System.out.println("Title: " + book.getTitle());
System.out.println("Year: " + book.getYearPublished());
if(book.getISBN()!=null){
System.out.println("ISBN: " + book.getISBN());
}
}
}else{
System.out.println("List of books is empty");
}
System.out.println("");
}
|
java
|
public static void showBooks(final ListOfBooks booksList){
if(booksList != null && booksList.getBook() != null && !booksList.getBook().isEmpty()){
List<BookType> books = booksList.getBook();
System.out.println("\nNumber of books: " + books.size());
int cnt = 0;
for (BookType book : books) {
System.out.println("\nBookNum: " + (cnt++ + 1));
List<PersonType> authors = book.getAuthor();
if(authors != null && !authors.isEmpty()){
for (PersonType author : authors) {
System.out.println("Author: " + author.getFirstName() +
" " + author.getLastName());
}
}
System.out.println("Title: " + book.getTitle());
System.out.println("Year: " + book.getYearPublished());
if(book.getISBN()!=null){
System.out.println("ISBN: " + book.getISBN());
}
}
}else{
System.out.println("List of books is empty");
}
System.out.println("");
}
|
[
"public",
"static",
"void",
"showBooks",
"(",
"final",
"ListOfBooks",
"booksList",
")",
"{",
"if",
"(",
"booksList",
"!=",
"null",
"&&",
"booksList",
".",
"getBook",
"(",
")",
"!=",
"null",
"&&",
"!",
"booksList",
".",
"getBook",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"List",
"<",
"BookType",
">",
"books",
"=",
"booksList",
".",
"getBook",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\\nNumber of books: \"",
"+",
"books",
".",
"size",
"(",
")",
")",
";",
"int",
"cnt",
"=",
"0",
";",
"for",
"(",
"BookType",
"book",
":",
"books",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\\nBookNum: \"",
"+",
"(",
"cnt",
"++",
"+",
"1",
")",
")",
";",
"List",
"<",
"PersonType",
">",
"authors",
"=",
"book",
".",
"getAuthor",
"(",
")",
";",
"if",
"(",
"authors",
"!=",
"null",
"&&",
"!",
"authors",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"PersonType",
"author",
":",
"authors",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Author: \"",
"+",
"author",
".",
"getFirstName",
"(",
")",
"+",
"\" \"",
"+",
"author",
".",
"getLastName",
"(",
")",
")",
";",
"}",
"}",
"System",
".",
"out",
".",
"println",
"(",
"\"Title: \"",
"+",
"book",
".",
"getTitle",
"(",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Year: \"",
"+",
"book",
".",
"getYearPublished",
"(",
")",
")",
";",
"if",
"(",
"book",
".",
"getISBN",
"(",
")",
"!=",
"null",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"ISBN: \"",
"+",
"book",
".",
"getISBN",
"(",
")",
")",
";",
"}",
"}",
"}",
"else",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"List of books is empty\"",
")",
";",
"}",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"}"
] |
Show books.
@param booksList the books list
|
[
"Show",
"books",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/tesb/library-service/common/src/main/java/org/talend/services/demos/common/Utils.java#L19-L45
|
160,243 |
Talend/tesb-rt-se
|
examples/tesb/locator-service/soap-service/war/src/main/java/demo/service/ContextListener.java
|
ContextListener.contextInitialized
|
public void contextInitialized(ServletContextEvent event) {
this.context = event.getServletContext();
// Output a simple message to the server's console
System.out.println("The Simple Web App. Is Ready");
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"/client.xml");
LocatorService client = (LocatorService) context
.getBean("locatorService");
String serviceHost = this.context.getInitParameter("serviceHost");
try {
client.registerEndpoint(new QName(
"http://talend.org/esb/examples/", "GreeterService"),
serviceHost, BindingType.SOAP_11, TransportType.HTTP, null);
} catch (InterruptedExceptionFault e) {
e.printStackTrace();
} catch (ServiceLocatorFault e) {
e.printStackTrace();
}
}
|
java
|
public void contextInitialized(ServletContextEvent event) {
this.context = event.getServletContext();
// Output a simple message to the server's console
System.out.println("The Simple Web App. Is Ready");
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"/client.xml");
LocatorService client = (LocatorService) context
.getBean("locatorService");
String serviceHost = this.context.getInitParameter("serviceHost");
try {
client.registerEndpoint(new QName(
"http://talend.org/esb/examples/", "GreeterService"),
serviceHost, BindingType.SOAP_11, TransportType.HTTP, null);
} catch (InterruptedExceptionFault e) {
e.printStackTrace();
} catch (ServiceLocatorFault e) {
e.printStackTrace();
}
}
|
[
"public",
"void",
"contextInitialized",
"(",
"ServletContextEvent",
"event",
")",
"{",
"this",
".",
"context",
"=",
"event",
".",
"getServletContext",
"(",
")",
";",
"// Output a simple message to the server's console",
"System",
".",
"out",
".",
"println",
"(",
"\"The Simple Web App. Is Ready\"",
")",
";",
"ClassPathXmlApplicationContext",
"context",
"=",
"new",
"ClassPathXmlApplicationContext",
"(",
"\"/client.xml\"",
")",
";",
"LocatorService",
"client",
"=",
"(",
"LocatorService",
")",
"context",
".",
"getBean",
"(",
"\"locatorService\"",
")",
";",
"String",
"serviceHost",
"=",
"this",
".",
"context",
".",
"getInitParameter",
"(",
"\"serviceHost\"",
")",
";",
"try",
"{",
"client",
".",
"registerEndpoint",
"(",
"new",
"QName",
"(",
"\"http://talend.org/esb/examples/\"",
",",
"\"GreeterService\"",
")",
",",
"serviceHost",
",",
"BindingType",
".",
"SOAP_11",
",",
"TransportType",
".",
"HTTP",
",",
"null",
")",
";",
"}",
"catch",
"(",
"InterruptedExceptionFault",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"catch",
"(",
"ServiceLocatorFault",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
] |
is ready to service requests
|
[
"is",
"ready",
"to",
"service",
"requests"
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/tesb/locator-service/soap-service/war/src/main/java/demo/service/ContextListener.java#L63-L85
|
160,244 |
Talend/tesb-rt-se
|
locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/CXFEndpointProvider.java
|
CXFEndpointProvider.serializeEPR
|
private void serializeEPR(EndpointReferenceType wsAddr, Node parent) throws ServiceLocatorException {
try {
JAXBElement<EndpointReferenceType> ep =
WSA_OBJECT_FACTORY.createEndpointReference(wsAddr);
createMarshaller().marshal(ep, parent);
} catch (JAXBException e) {
if (LOG.isLoggable(Level.SEVERE)) {
LOG.log(Level.SEVERE,
"Failed to serialize endpoint data", e);
}
throw new ServiceLocatorException("Failed to serialize endpoint data", e);
}
}
|
java
|
private void serializeEPR(EndpointReferenceType wsAddr, Node parent) throws ServiceLocatorException {
try {
JAXBElement<EndpointReferenceType> ep =
WSA_OBJECT_FACTORY.createEndpointReference(wsAddr);
createMarshaller().marshal(ep, parent);
} catch (JAXBException e) {
if (LOG.isLoggable(Level.SEVERE)) {
LOG.log(Level.SEVERE,
"Failed to serialize endpoint data", e);
}
throw new ServiceLocatorException("Failed to serialize endpoint data", e);
}
}
|
[
"private",
"void",
"serializeEPR",
"(",
"EndpointReferenceType",
"wsAddr",
",",
"Node",
"parent",
")",
"throws",
"ServiceLocatorException",
"{",
"try",
"{",
"JAXBElement",
"<",
"EndpointReferenceType",
">",
"ep",
"=",
"WSA_OBJECT_FACTORY",
".",
"createEndpointReference",
"(",
"wsAddr",
")",
";",
"createMarshaller",
"(",
")",
".",
"marshal",
"(",
"ep",
",",
"parent",
")",
";",
"}",
"catch",
"(",
"JAXBException",
"e",
")",
"{",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"SEVERE",
")",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Failed to serialize endpoint data\"",
",",
"e",
")",
";",
"}",
"throw",
"new",
"ServiceLocatorException",
"(",
"\"Failed to serialize endpoint data\"",
",",
"e",
")",
";",
"}",
"}"
] |
Inserts a marshalled endpoint reference to a given DOM tree rooted by parent.
@param wsAddr
@param parent
@throws ServiceLocatorException
|
[
"Inserts",
"a",
"marshalled",
"endpoint",
"reference",
"to",
"a",
"given",
"DOM",
"tree",
"rooted",
"by",
"parent",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/CXFEndpointProvider.java#L205-L217
|
160,245 |
Talend/tesb-rt-se
|
locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/CXFEndpointProvider.java
|
CXFEndpointProvider.createEPR
|
private static EndpointReferenceType createEPR(String address, SLProperties props) {
EndpointReferenceType epr = WSAEndpointReferenceUtils.getEndpointReference(address);
if (props != null) {
addProperties(epr, props);
}
return epr;
}
|
java
|
private static EndpointReferenceType createEPR(String address, SLProperties props) {
EndpointReferenceType epr = WSAEndpointReferenceUtils.getEndpointReference(address);
if (props != null) {
addProperties(epr, props);
}
return epr;
}
|
[
"private",
"static",
"EndpointReferenceType",
"createEPR",
"(",
"String",
"address",
",",
"SLProperties",
"props",
")",
"{",
"EndpointReferenceType",
"epr",
"=",
"WSAEndpointReferenceUtils",
".",
"getEndpointReference",
"(",
"address",
")",
";",
"if",
"(",
"props",
"!=",
"null",
")",
"{",
"addProperties",
"(",
"epr",
",",
"props",
")",
";",
"}",
"return",
"epr",
";",
"}"
] |
Creates an endpoint reference from a given adress.
@param address
@param props
@return
|
[
"Creates",
"an",
"endpoint",
"reference",
"from",
"a",
"given",
"adress",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/CXFEndpointProvider.java#L279-L285
|
160,246 |
Talend/tesb-rt-se
|
locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/CXFEndpointProvider.java
|
CXFEndpointProvider.createEPR
|
private static EndpointReferenceType createEPR(Server server, String address, SLProperties props) {
EndpointReferenceType sourceEPR = server.getEndpoint().getEndpointInfo().getTarget();
EndpointReferenceType targetEPR = WSAEndpointReferenceUtils.duplicate(sourceEPR);
WSAEndpointReferenceUtils.setAddress(targetEPR, address);
if (props != null) {
addProperties(targetEPR, props);
}
return targetEPR;
}
|
java
|
private static EndpointReferenceType createEPR(Server server, String address, SLProperties props) {
EndpointReferenceType sourceEPR = server.getEndpoint().getEndpointInfo().getTarget();
EndpointReferenceType targetEPR = WSAEndpointReferenceUtils.duplicate(sourceEPR);
WSAEndpointReferenceUtils.setAddress(targetEPR, address);
if (props != null) {
addProperties(targetEPR, props);
}
return targetEPR;
}
|
[
"private",
"static",
"EndpointReferenceType",
"createEPR",
"(",
"Server",
"server",
",",
"String",
"address",
",",
"SLProperties",
"props",
")",
"{",
"EndpointReferenceType",
"sourceEPR",
"=",
"server",
".",
"getEndpoint",
"(",
")",
".",
"getEndpointInfo",
"(",
")",
".",
"getTarget",
"(",
")",
";",
"EndpointReferenceType",
"targetEPR",
"=",
"WSAEndpointReferenceUtils",
".",
"duplicate",
"(",
"sourceEPR",
")",
";",
"WSAEndpointReferenceUtils",
".",
"setAddress",
"(",
"targetEPR",
",",
"address",
")",
";",
"if",
"(",
"props",
"!=",
"null",
")",
"{",
"addProperties",
"(",
"targetEPR",
",",
"props",
")",
";",
"}",
"return",
"targetEPR",
";",
"}"
] |
Creates an endpoint reference by duplicating the endpoint reference of a given server.
@param server
@param address
@param props
@return
|
[
"Creates",
"an",
"endpoint",
"reference",
"by",
"duplicating",
"the",
"endpoint",
"reference",
"of",
"a",
"given",
"server",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/CXFEndpointProvider.java#L294-L303
|
160,247 |
Talend/tesb-rt-se
|
locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/CXFEndpointProvider.java
|
CXFEndpointProvider.addProperties
|
private static void addProperties(EndpointReferenceType epr, SLProperties props) {
MetadataType metadata = WSAEndpointReferenceUtils.getSetMetadata(epr);
ServiceLocatorPropertiesType jaxbProps = SLPropertiesConverter.toServiceLocatorPropertiesType(props);
JAXBElement<ServiceLocatorPropertiesType>
slp = SL_OBJECT_FACTORY.createServiceLocatorProperties(jaxbProps);
metadata.getAny().add(slp);
}
|
java
|
private static void addProperties(EndpointReferenceType epr, SLProperties props) {
MetadataType metadata = WSAEndpointReferenceUtils.getSetMetadata(epr);
ServiceLocatorPropertiesType jaxbProps = SLPropertiesConverter.toServiceLocatorPropertiesType(props);
JAXBElement<ServiceLocatorPropertiesType>
slp = SL_OBJECT_FACTORY.createServiceLocatorProperties(jaxbProps);
metadata.getAny().add(slp);
}
|
[
"private",
"static",
"void",
"addProperties",
"(",
"EndpointReferenceType",
"epr",
",",
"SLProperties",
"props",
")",
"{",
"MetadataType",
"metadata",
"=",
"WSAEndpointReferenceUtils",
".",
"getSetMetadata",
"(",
"epr",
")",
";",
"ServiceLocatorPropertiesType",
"jaxbProps",
"=",
"SLPropertiesConverter",
".",
"toServiceLocatorPropertiesType",
"(",
"props",
")",
";",
"JAXBElement",
"<",
"ServiceLocatorPropertiesType",
">",
"slp",
"=",
"SL_OBJECT_FACTORY",
".",
"createServiceLocatorProperties",
"(",
"jaxbProps",
")",
";",
"metadata",
".",
"getAny",
"(",
")",
".",
"add",
"(",
"slp",
")",
";",
"}"
] |
Adds service locator properties to an endpoint reference.
@param epr
@param props
|
[
"Adds",
"service",
"locator",
"properties",
"to",
"an",
"endpoint",
"reference",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/CXFEndpointProvider.java#L310-L317
|
160,248 |
Talend/tesb-rt-se
|
locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/CXFEndpointProvider.java
|
CXFEndpointProvider.getServiceName
|
private static QName getServiceName(Server server) {
QName serviceName;
String bindingId = getBindingId(server);
EndpointInfo eInfo = server.getEndpoint().getEndpointInfo();
if (JAXRS_BINDING_ID.equals(bindingId)) {
serviceName = eInfo.getName();
} else {
ServiceInfo serviceInfo = eInfo.getService();
serviceName = serviceInfo.getName();
}
return serviceName;
}
|
java
|
private static QName getServiceName(Server server) {
QName serviceName;
String bindingId = getBindingId(server);
EndpointInfo eInfo = server.getEndpoint().getEndpointInfo();
if (JAXRS_BINDING_ID.equals(bindingId)) {
serviceName = eInfo.getName();
} else {
ServiceInfo serviceInfo = eInfo.getService();
serviceName = serviceInfo.getName();
}
return serviceName;
}
|
[
"private",
"static",
"QName",
"getServiceName",
"(",
"Server",
"server",
")",
"{",
"QName",
"serviceName",
";",
"String",
"bindingId",
"=",
"getBindingId",
"(",
"server",
")",
";",
"EndpointInfo",
"eInfo",
"=",
"server",
".",
"getEndpoint",
"(",
")",
".",
"getEndpointInfo",
"(",
")",
";",
"if",
"(",
"JAXRS_BINDING_ID",
".",
"equals",
"(",
"bindingId",
")",
")",
"{",
"serviceName",
"=",
"eInfo",
".",
"getName",
"(",
")",
";",
"}",
"else",
"{",
"ServiceInfo",
"serviceInfo",
"=",
"eInfo",
".",
"getService",
"(",
")",
";",
"serviceName",
"=",
"serviceInfo",
".",
"getName",
"(",
")",
";",
"}",
"return",
"serviceName",
";",
"}"
] |
Extracts the service name from a Server.
@param server
@return
|
[
"Extracts",
"the",
"service",
"name",
"from",
"a",
"Server",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/CXFEndpointProvider.java#L324-L336
|
160,249 |
Talend/tesb-rt-se
|
locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/CXFEndpointProvider.java
|
CXFEndpointProvider.getBindingId
|
private static String getBindingId(Server server) {
Endpoint ep = server.getEndpoint();
BindingInfo bi = ep.getBinding().getBindingInfo();
return bi.getBindingId();
}
|
java
|
private static String getBindingId(Server server) {
Endpoint ep = server.getEndpoint();
BindingInfo bi = ep.getBinding().getBindingInfo();
return bi.getBindingId();
}
|
[
"private",
"static",
"String",
"getBindingId",
"(",
"Server",
"server",
")",
"{",
"Endpoint",
"ep",
"=",
"server",
".",
"getEndpoint",
"(",
")",
";",
"BindingInfo",
"bi",
"=",
"ep",
".",
"getBinding",
"(",
")",
".",
"getBindingInfo",
"(",
")",
";",
"return",
"bi",
".",
"getBindingId",
"(",
")",
";",
"}"
] |
Extracts the bindingId from a Server.
@param server
@return
|
[
"Extracts",
"the",
"bindingId",
"from",
"a",
"Server",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/CXFEndpointProvider.java#L343-L347
|
160,250 |
Talend/tesb-rt-se
|
locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/CXFEndpointProvider.java
|
CXFEndpointProvider.map2BindingType
|
private static BindingType map2BindingType(String bindingId) {
BindingType type;
if (SOAP11_BINDING_ID.equals(bindingId)) {
type = BindingType.SOAP11;
} else if (SOAP12_BINDING_ID.equals(bindingId)) {
type = BindingType.SOAP12;
} else if (JAXRS_BINDING_ID.equals(bindingId)) {
type = BindingType.JAXRS;
} else {
type = BindingType.OTHER;
}
return type;
}
|
java
|
private static BindingType map2BindingType(String bindingId) {
BindingType type;
if (SOAP11_BINDING_ID.equals(bindingId)) {
type = BindingType.SOAP11;
} else if (SOAP12_BINDING_ID.equals(bindingId)) {
type = BindingType.SOAP12;
} else if (JAXRS_BINDING_ID.equals(bindingId)) {
type = BindingType.JAXRS;
} else {
type = BindingType.OTHER;
}
return type;
}
|
[
"private",
"static",
"BindingType",
"map2BindingType",
"(",
"String",
"bindingId",
")",
"{",
"BindingType",
"type",
";",
"if",
"(",
"SOAP11_BINDING_ID",
".",
"equals",
"(",
"bindingId",
")",
")",
"{",
"type",
"=",
"BindingType",
".",
"SOAP11",
";",
"}",
"else",
"if",
"(",
"SOAP12_BINDING_ID",
".",
"equals",
"(",
"bindingId",
")",
")",
"{",
"type",
"=",
"BindingType",
".",
"SOAP12",
";",
"}",
"else",
"if",
"(",
"JAXRS_BINDING_ID",
".",
"equals",
"(",
"bindingId",
")",
")",
"{",
"type",
"=",
"BindingType",
".",
"JAXRS",
";",
"}",
"else",
"{",
"type",
"=",
"BindingType",
".",
"OTHER",
";",
"}",
"return",
"type",
";",
"}"
] |
Maps a bindingId to its corresponding BindingType.
@param bindingId
@return
|
[
"Maps",
"a",
"bindingId",
"to",
"its",
"corresponding",
"BindingType",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/CXFEndpointProvider.java#L363-L375
|
160,251 |
Talend/tesb-rt-se
|
locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/CXFEndpointProvider.java
|
CXFEndpointProvider.map2TransportType
|
private static TransportType map2TransportType(String transportId) {
TransportType type;
if (CXF_HTTP_TRANSPORT_ID.equals(transportId) || SOAP_HTTP_TRANSPORT_ID.equals(transportId)) {
type = TransportType.HTTP;
} else {
type = TransportType.OTHER;
}
return type;
}
|
java
|
private static TransportType map2TransportType(String transportId) {
TransportType type;
if (CXF_HTTP_TRANSPORT_ID.equals(transportId) || SOAP_HTTP_TRANSPORT_ID.equals(transportId)) {
type = TransportType.HTTP;
} else {
type = TransportType.OTHER;
}
return type;
}
|
[
"private",
"static",
"TransportType",
"map2TransportType",
"(",
"String",
"transportId",
")",
"{",
"TransportType",
"type",
";",
"if",
"(",
"CXF_HTTP_TRANSPORT_ID",
".",
"equals",
"(",
"transportId",
")",
"||",
"SOAP_HTTP_TRANSPORT_ID",
".",
"equals",
"(",
"transportId",
")",
")",
"{",
"type",
"=",
"TransportType",
".",
"HTTP",
";",
"}",
"else",
"{",
"type",
"=",
"TransportType",
".",
"OTHER",
";",
"}",
"return",
"type",
";",
"}"
] |
Maps a transportId to its corresponding TransportType.
@param transportId
@return
|
[
"Maps",
"a",
"transportId",
"to",
"its",
"corresponding",
"TransportType",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/CXFEndpointProvider.java#L382-L390
|
160,252 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/eventproducer/MessageToEventMapper.java
|
MessageToEventMapper.getEventType
|
private EventTypeEnum getEventType(Message message) {
boolean isRequestor = MessageUtils.isRequestor(message);
boolean isFault = MessageUtils.isFault(message);
boolean isOutbound = MessageUtils.isOutbound(message);
//Needed because if it is rest request and method does not exists had better to return Fault
if(!isFault && isRestMessage(message)) {
isFault = (message.getExchange().get("org.apache.cxf.resource.operation.name") == null);
if (!isFault) {
Integer responseCode = (Integer) message.get(Message.RESPONSE_CODE);
if (null != responseCode) {
isFault = (responseCode >= 400);
}
}
}
if (isOutbound) {
if (isFault) {
return EventTypeEnum.FAULT_OUT;
} else {
return isRequestor ? EventTypeEnum.REQ_OUT : EventTypeEnum.RESP_OUT;
}
} else {
if (isFault) {
return EventTypeEnum.FAULT_IN;
} else {
return isRequestor ? EventTypeEnum.RESP_IN : EventTypeEnum.REQ_IN;
}
}
}
|
java
|
private EventTypeEnum getEventType(Message message) {
boolean isRequestor = MessageUtils.isRequestor(message);
boolean isFault = MessageUtils.isFault(message);
boolean isOutbound = MessageUtils.isOutbound(message);
//Needed because if it is rest request and method does not exists had better to return Fault
if(!isFault && isRestMessage(message)) {
isFault = (message.getExchange().get("org.apache.cxf.resource.operation.name") == null);
if (!isFault) {
Integer responseCode = (Integer) message.get(Message.RESPONSE_CODE);
if (null != responseCode) {
isFault = (responseCode >= 400);
}
}
}
if (isOutbound) {
if (isFault) {
return EventTypeEnum.FAULT_OUT;
} else {
return isRequestor ? EventTypeEnum.REQ_OUT : EventTypeEnum.RESP_OUT;
}
} else {
if (isFault) {
return EventTypeEnum.FAULT_IN;
} else {
return isRequestor ? EventTypeEnum.RESP_IN : EventTypeEnum.REQ_IN;
}
}
}
|
[
"private",
"EventTypeEnum",
"getEventType",
"(",
"Message",
"message",
")",
"{",
"boolean",
"isRequestor",
"=",
"MessageUtils",
".",
"isRequestor",
"(",
"message",
")",
";",
"boolean",
"isFault",
"=",
"MessageUtils",
".",
"isFault",
"(",
"message",
")",
";",
"boolean",
"isOutbound",
"=",
"MessageUtils",
".",
"isOutbound",
"(",
"message",
")",
";",
"//Needed because if it is rest request and method does not exists had better to return Fault",
"if",
"(",
"!",
"isFault",
"&&",
"isRestMessage",
"(",
"message",
")",
")",
"{",
"isFault",
"=",
"(",
"message",
".",
"getExchange",
"(",
")",
".",
"get",
"(",
"\"org.apache.cxf.resource.operation.name\"",
")",
"==",
"null",
")",
";",
"if",
"(",
"!",
"isFault",
")",
"{",
"Integer",
"responseCode",
"=",
"(",
"Integer",
")",
"message",
".",
"get",
"(",
"Message",
".",
"RESPONSE_CODE",
")",
";",
"if",
"(",
"null",
"!=",
"responseCode",
")",
"{",
"isFault",
"=",
"(",
"responseCode",
">=",
"400",
")",
";",
"}",
"}",
"}",
"if",
"(",
"isOutbound",
")",
"{",
"if",
"(",
"isFault",
")",
"{",
"return",
"EventTypeEnum",
".",
"FAULT_OUT",
";",
"}",
"else",
"{",
"return",
"isRequestor",
"?",
"EventTypeEnum",
".",
"REQ_OUT",
":",
"EventTypeEnum",
".",
"RESP_OUT",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"isFault",
")",
"{",
"return",
"EventTypeEnum",
".",
"FAULT_IN",
";",
"}",
"else",
"{",
"return",
"isRequestor",
"?",
"EventTypeEnum",
".",
"RESP_IN",
":",
"EventTypeEnum",
".",
"REQ_IN",
";",
"}",
"}",
"}"
] |
Gets the event type from message.
@param message the message
@return the event type
|
[
"Gets",
"the",
"event",
"type",
"from",
"message",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/eventproducer/MessageToEventMapper.java#L270-L298
|
160,253 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/eventproducer/MessageToEventMapper.java
|
MessageToEventMapper.getPayload
|
protected String getPayload(Message message) {
try {
String encoding = (String) message.get(Message.ENCODING);
if (encoding == null) {
encoding = "UTF-8";
}
CachedOutputStream cos = message.getContent(CachedOutputStream.class);
if (cos == null) {
LOG.warning("Could not find CachedOutputStream in message."
+ " Continuing without message content");
return "";
}
return new String(cos.getBytes(), encoding);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
java
|
protected String getPayload(Message message) {
try {
String encoding = (String) message.get(Message.ENCODING);
if (encoding == null) {
encoding = "UTF-8";
}
CachedOutputStream cos = message.getContent(CachedOutputStream.class);
if (cos == null) {
LOG.warning("Could not find CachedOutputStream in message."
+ " Continuing without message content");
return "";
}
return new String(cos.getBytes(), encoding);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
[
"protected",
"String",
"getPayload",
"(",
"Message",
"message",
")",
"{",
"try",
"{",
"String",
"encoding",
"=",
"(",
"String",
")",
"message",
".",
"get",
"(",
"Message",
".",
"ENCODING",
")",
";",
"if",
"(",
"encoding",
"==",
"null",
")",
"{",
"encoding",
"=",
"\"UTF-8\"",
";",
"}",
"CachedOutputStream",
"cos",
"=",
"message",
".",
"getContent",
"(",
"CachedOutputStream",
".",
"class",
")",
";",
"if",
"(",
"cos",
"==",
"null",
")",
"{",
"LOG",
".",
"warning",
"(",
"\"Could not find CachedOutputStream in message.\"",
"+",
"\" Continuing without message content\"",
")",
";",
"return",
"\"\"",
";",
"}",
"return",
"new",
"String",
"(",
"cos",
".",
"getBytes",
"(",
")",
",",
"encoding",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
Gets the message payload.
@param message the message
@return the payload
|
[
"Gets",
"the",
"message",
"payload",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/eventproducer/MessageToEventMapper.java#L345-L361
|
160,254 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/eventproducer/MessageToEventMapper.java
|
MessageToEventMapper.handleContentLength
|
private void handleContentLength(Event event) {
if (event.getContent() == null) {
return;
}
if (maxContentLength == -1 || event.getContent().length() <= maxContentLength) {
return;
}
if (maxContentLength < CUT_START_TAG.length() + CUT_END_TAG.length()) {
event.setContent("");
event.setContentCut(true);
return;
}
int contentLength = maxContentLength - CUT_START_TAG.length() - CUT_END_TAG.length();
event.setContent(CUT_START_TAG + event.getContent().substring(0, contentLength) + CUT_END_TAG);
event.setContentCut(true);
}
|
java
|
private void handleContentLength(Event event) {
if (event.getContent() == null) {
return;
}
if (maxContentLength == -1 || event.getContent().length() <= maxContentLength) {
return;
}
if (maxContentLength < CUT_START_TAG.length() + CUT_END_TAG.length()) {
event.setContent("");
event.setContentCut(true);
return;
}
int contentLength = maxContentLength - CUT_START_TAG.length() - CUT_END_TAG.length();
event.setContent(CUT_START_TAG + event.getContent().substring(0, contentLength) + CUT_END_TAG);
event.setContentCut(true);
}
|
[
"private",
"void",
"handleContentLength",
"(",
"Event",
"event",
")",
"{",
"if",
"(",
"event",
".",
"getContent",
"(",
")",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"maxContentLength",
"==",
"-",
"1",
"||",
"event",
".",
"getContent",
"(",
")",
".",
"length",
"(",
")",
"<=",
"maxContentLength",
")",
"{",
"return",
";",
"}",
"if",
"(",
"maxContentLength",
"<",
"CUT_START_TAG",
".",
"length",
"(",
")",
"+",
"CUT_END_TAG",
".",
"length",
"(",
")",
")",
"{",
"event",
".",
"setContent",
"(",
"\"\"",
")",
";",
"event",
".",
"setContentCut",
"(",
"true",
")",
";",
"return",
";",
"}",
"int",
"contentLength",
"=",
"maxContentLength",
"-",
"CUT_START_TAG",
".",
"length",
"(",
")",
"-",
"CUT_END_TAG",
".",
"length",
"(",
")",
";",
"event",
".",
"setContent",
"(",
"CUT_START_TAG",
"+",
"event",
".",
"getContent",
"(",
")",
".",
"substring",
"(",
"0",
",",
"contentLength",
")",
"+",
"CUT_END_TAG",
")",
";",
"event",
".",
"setContentCut",
"(",
"true",
")",
";",
"}"
] |
Handle content length.
@param event
the event
|
[
"Handle",
"content",
"length",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/eventproducer/MessageToEventMapper.java#L388-L406
|
160,255 |
Talend/tesb-rt-se
|
sam/sam-server/src/main/java/org/talend/esb/sam/server/persistence/criterias/CriteriaAdapter.java
|
CriteriaAdapter.getCriterias
|
private Map<String, Criteria> getCriterias(Map<String, String[]> params) {
Map<String, Criteria> result = new HashMap<String, Criteria>();
for (Map.Entry<String, String[]> param : params.entrySet()) {
for (Criteria criteria : FILTER_CRITERIAS) {
if (criteria.getName().equals(param.getKey())) {
try {
Criteria[] parsedCriterias = criteria.parseValue(param.getValue()[0]);
for (Criteria parsedCriteria : parsedCriterias) {
result.put(parsedCriteria.getName(), parsedCriteria);
}
} catch (Exception e) {
// Exception happened during paring
LOG.log(Level.SEVERE, "Error parsing parameter " + param.getKey(), e);
}
break;
}
}
}
return result;
}
|
java
|
private Map<String, Criteria> getCriterias(Map<String, String[]> params) {
Map<String, Criteria> result = new HashMap<String, Criteria>();
for (Map.Entry<String, String[]> param : params.entrySet()) {
for (Criteria criteria : FILTER_CRITERIAS) {
if (criteria.getName().equals(param.getKey())) {
try {
Criteria[] parsedCriterias = criteria.parseValue(param.getValue()[0]);
for (Criteria parsedCriteria : parsedCriterias) {
result.put(parsedCriteria.getName(), parsedCriteria);
}
} catch (Exception e) {
// Exception happened during paring
LOG.log(Level.SEVERE, "Error parsing parameter " + param.getKey(), e);
}
break;
}
}
}
return result;
}
|
[
"private",
"Map",
"<",
"String",
",",
"Criteria",
">",
"getCriterias",
"(",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"params",
")",
"{",
"Map",
"<",
"String",
",",
"Criteria",
">",
"result",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Criteria",
">",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
"[",
"]",
">",
"param",
":",
"params",
".",
"entrySet",
"(",
")",
")",
"{",
"for",
"(",
"Criteria",
"criteria",
":",
"FILTER_CRITERIAS",
")",
"{",
"if",
"(",
"criteria",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"param",
".",
"getKey",
"(",
")",
")",
")",
"{",
"try",
"{",
"Criteria",
"[",
"]",
"parsedCriterias",
"=",
"criteria",
".",
"parseValue",
"(",
"param",
".",
"getValue",
"(",
")",
"[",
"0",
"]",
")",
";",
"for",
"(",
"Criteria",
"parsedCriteria",
":",
"parsedCriterias",
")",
"{",
"result",
".",
"put",
"(",
"parsedCriteria",
".",
"getName",
"(",
")",
",",
"parsedCriteria",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// Exception happened during paring",
"LOG",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Error parsing parameter \"",
"+",
"param",
".",
"getKey",
"(",
")",
",",
"e",
")",
";",
"}",
"break",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] |
Reads filter parameters.
@param params the params
@return the criterias
|
[
"Reads",
"filter",
"parameters",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-server/src/main/java/org/talend/esb/sam/server/persistence/criterias/CriteriaAdapter.java#L93-L112
|
160,256 |
Talend/tesb-rt-se
|
locator/src/main/java/org/talend/esb/servicelocator/client/internal/ServiceLocatorImpl.java
|
ServiceLocatorImpl.setSessionTimeout
|
public void setSessionTimeout(int timeout) {
((ZKBackend) getBackend()).setSessionTimeout(timeout);
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Locator session timeout set to: " + timeout);
}
}
|
java
|
public void setSessionTimeout(int timeout) {
((ZKBackend) getBackend()).setSessionTimeout(timeout);
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Locator session timeout set to: " + timeout);
}
}
|
[
"public",
"void",
"setSessionTimeout",
"(",
"int",
"timeout",
")",
"{",
"(",
"(",
"ZKBackend",
")",
"getBackend",
"(",
")",
")",
".",
"setSessionTimeout",
"(",
"timeout",
")",
";",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"Locator session timeout set to: \"",
"+",
"timeout",
")",
";",
"}",
"}"
] |
Specify the time out of the session established at the server. The
session is kept alive by requests sent by this client object. If the
session is idle for a period of time that would timeout the session, the
client will send a PING request to keep the session alive.
@param timeout timeout in milliseconds, must be greater than zero and less
than 60000.
|
[
"Specify",
"the",
"time",
"out",
"of",
"the",
"session",
"established",
"at",
"the",
"server",
".",
"The",
"session",
"is",
"kept",
"alive",
"by",
"requests",
"sent",
"by",
"this",
"client",
"object",
".",
"If",
"the",
"session",
"is",
"idle",
"for",
"a",
"period",
"of",
"time",
"that",
"would",
"timeout",
"the",
"session",
"the",
"client",
"will",
"send",
"a",
"PING",
"request",
"to",
"keep",
"the",
"session",
"alive",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator/src/main/java/org/talend/esb/servicelocator/client/internal/ServiceLocatorImpl.java#L450-L456
|
160,257 |
Talend/tesb-rt-se
|
examples/tesb/rent-a-car/app-reservation/src/main/java/org/talend/esb/client/commands/CarRent.java
|
CarRent.racRent
|
public void racRent() {
pos = pos - 1;
String userName = CarSearch.getLastSearchParams()[0];
String pickupDate = CarSearch.getLastSearchParams()[1];
String returnDate = CarSearch.getLastSearchParams()[2];
this.searcher.search(userName, pickupDate, returnDate);
if (searcher!=null && searcher.getCars()!= null && pos < searcher.getCars().size() && searcher.getCars().get(pos) != null) {
RESStatusType resStatus = reserver.reserveCar(searcher.getCustomer()
, searcher.getCars().get(pos)
, pickupDate
, returnDate);
ConfirmationType confirm = reserver.getConfirmation(resStatus
, searcher.getCustomer()
, searcher.getCars().get(pos)
, pickupDate
, returnDate);
RESCarType car = confirm.getCar();
CustomerDetailsType customer = confirm.getCustomer();
System.out.println(MessageFormat.format(CONFIRMATION
, confirm.getDescription()
, confirm.getReservationId()
, customer.getName()
, customer.getEmail()
, customer.getCity()
, customer.getStatus()
, car.getBrand()
, car.getDesignModel()
, confirm.getFromDate()
, confirm.getToDate()
, padl(car.getRateDay(), 10)
, padl(car.getRateWeekend(), 10)
, padl(confirm.getCreditPoints().toString(), 7)));
} else {
System.out.println("Invalid selection: " + (pos+1)); //$NON-NLS-1$
}
}
|
java
|
public void racRent() {
pos = pos - 1;
String userName = CarSearch.getLastSearchParams()[0];
String pickupDate = CarSearch.getLastSearchParams()[1];
String returnDate = CarSearch.getLastSearchParams()[2];
this.searcher.search(userName, pickupDate, returnDate);
if (searcher!=null && searcher.getCars()!= null && pos < searcher.getCars().size() && searcher.getCars().get(pos) != null) {
RESStatusType resStatus = reserver.reserveCar(searcher.getCustomer()
, searcher.getCars().get(pos)
, pickupDate
, returnDate);
ConfirmationType confirm = reserver.getConfirmation(resStatus
, searcher.getCustomer()
, searcher.getCars().get(pos)
, pickupDate
, returnDate);
RESCarType car = confirm.getCar();
CustomerDetailsType customer = confirm.getCustomer();
System.out.println(MessageFormat.format(CONFIRMATION
, confirm.getDescription()
, confirm.getReservationId()
, customer.getName()
, customer.getEmail()
, customer.getCity()
, customer.getStatus()
, car.getBrand()
, car.getDesignModel()
, confirm.getFromDate()
, confirm.getToDate()
, padl(car.getRateDay(), 10)
, padl(car.getRateWeekend(), 10)
, padl(confirm.getCreditPoints().toString(), 7)));
} else {
System.out.println("Invalid selection: " + (pos+1)); //$NON-NLS-1$
}
}
|
[
"public",
"void",
"racRent",
"(",
")",
"{",
"pos",
"=",
"pos",
"-",
"1",
";",
"String",
"userName",
"=",
"CarSearch",
".",
"getLastSearchParams",
"(",
")",
"[",
"0",
"]",
";",
"String",
"pickupDate",
"=",
"CarSearch",
".",
"getLastSearchParams",
"(",
")",
"[",
"1",
"]",
";",
"String",
"returnDate",
"=",
"CarSearch",
".",
"getLastSearchParams",
"(",
")",
"[",
"2",
"]",
";",
"this",
".",
"searcher",
".",
"search",
"(",
"userName",
",",
"pickupDate",
",",
"returnDate",
")",
";",
"if",
"(",
"searcher",
"!=",
"null",
"&&",
"searcher",
".",
"getCars",
"(",
")",
"!=",
"null",
"&&",
"pos",
"<",
"searcher",
".",
"getCars",
"(",
")",
".",
"size",
"(",
")",
"&&",
"searcher",
".",
"getCars",
"(",
")",
".",
"get",
"(",
"pos",
")",
"!=",
"null",
")",
"{",
"RESStatusType",
"resStatus",
"=",
"reserver",
".",
"reserveCar",
"(",
"searcher",
".",
"getCustomer",
"(",
")",
",",
"searcher",
".",
"getCars",
"(",
")",
".",
"get",
"(",
"pos",
")",
",",
"pickupDate",
",",
"returnDate",
")",
";",
"ConfirmationType",
"confirm",
"=",
"reserver",
".",
"getConfirmation",
"(",
"resStatus",
",",
"searcher",
".",
"getCustomer",
"(",
")",
",",
"searcher",
".",
"getCars",
"(",
")",
".",
"get",
"(",
"pos",
")",
",",
"pickupDate",
",",
"returnDate",
")",
";",
"RESCarType",
"car",
"=",
"confirm",
".",
"getCar",
"(",
")",
";",
"CustomerDetailsType",
"customer",
"=",
"confirm",
".",
"getCustomer",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"MessageFormat",
".",
"format",
"(",
"CONFIRMATION",
",",
"confirm",
".",
"getDescription",
"(",
")",
",",
"confirm",
".",
"getReservationId",
"(",
")",
",",
"customer",
".",
"getName",
"(",
")",
",",
"customer",
".",
"getEmail",
"(",
")",
",",
"customer",
".",
"getCity",
"(",
")",
",",
"customer",
".",
"getStatus",
"(",
")",
",",
"car",
".",
"getBrand",
"(",
")",
",",
"car",
".",
"getDesignModel",
"(",
")",
",",
"confirm",
".",
"getFromDate",
"(",
")",
",",
"confirm",
".",
"getToDate",
"(",
")",
",",
"padl",
"(",
"car",
".",
"getRateDay",
"(",
")",
",",
"10",
")",
",",
"padl",
"(",
"car",
".",
"getRateWeekend",
"(",
")",
",",
"10",
")",
",",
"padl",
"(",
"confirm",
".",
"getCreditPoints",
"(",
")",
".",
"toString",
"(",
")",
",",
"7",
")",
")",
")",
";",
"}",
"else",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Invalid selection: \"",
"+",
"(",
"pos",
"+",
"1",
")",
")",
";",
"//$NON-NLS-1$",
"}",
"}"
] |
Rent a car available in the last serach result
@param intp - the command interpreter instance
|
[
"Rent",
"a",
"car",
"available",
"in",
"the",
"last",
"serach",
"result"
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/tesb/rent-a-car/app-reservation/src/main/java/org/talend/esb/client/commands/CarRent.java#L81-L118
|
160,258 |
Talend/tesb-rt-se
|
locator/src/main/java/org/talend/esb/servicelocator/client/SLPropertiesImpl.java
|
SLPropertiesImpl.addProperty
|
public void addProperty(String name, String... values) {
List<String> valueList = new ArrayList<String>();
for (String value : values) {
valueList.add(value.trim());
}
properties.put(name.trim(), valueList);
}
|
java
|
public void addProperty(String name, String... values) {
List<String> valueList = new ArrayList<String>();
for (String value : values) {
valueList.add(value.trim());
}
properties.put(name.trim(), valueList);
}
|
[
"public",
"void",
"addProperty",
"(",
"String",
"name",
",",
"String",
"...",
"values",
")",
"{",
"List",
"<",
"String",
">",
"valueList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"String",
"value",
":",
"values",
")",
"{",
"valueList",
".",
"add",
"(",
"value",
".",
"trim",
"(",
")",
")",
";",
"}",
"properties",
".",
"put",
"(",
"name",
".",
"trim",
"(",
")",
",",
"valueList",
")",
";",
"}"
] |
Add a property with the given name and the given list of values to this Properties object. Name
and values are trimmed before the property is added.
@param name the name of the property, must not be <code>null</code>.
@param values the values of the property, must no be <code>null</code>,
none of the values must be <code>null</code>
|
[
"Add",
"a",
"property",
"with",
"the",
"given",
"name",
"and",
"the",
"given",
"list",
"of",
"values",
"to",
"this",
"Properties",
"object",
".",
"Name",
"and",
"values",
"are",
"trimmed",
"before",
"the",
"property",
"is",
"added",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator/src/main/java/org/talend/esb/servicelocator/client/SLPropertiesImpl.java#L52-L58
|
160,259 |
Talend/tesb-rt-se
|
locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/LocatorRegistrar.java
|
LocatorRegistrar.getRegistrar
|
protected SingleBusLocatorRegistrar getRegistrar(Bus bus) {
SingleBusLocatorRegistrar registrar = busRegistrars.get(bus);
if (registrar == null) {
check(locatorClient, "serviceLocator", "registerService");
registrar = new SingleBusLocatorRegistrar(bus);
registrar.setServiceLocator(locatorClient);
registrar.setEndpointPrefix(endpointPrefix);
Map<String, String> endpointPrefixes = new HashMap<String, String>();
endpointPrefixes.put("HTTP", endpointPrefixHttp);
endpointPrefixes.put("HTTPS", endpointPrefixHttps);
registrar.setEndpointPrefixes(endpointPrefixes);
busRegistrars.put(bus, registrar);
addLifeCycleListener(bus);
}
return registrar;
}
|
java
|
protected SingleBusLocatorRegistrar getRegistrar(Bus bus) {
SingleBusLocatorRegistrar registrar = busRegistrars.get(bus);
if (registrar == null) {
check(locatorClient, "serviceLocator", "registerService");
registrar = new SingleBusLocatorRegistrar(bus);
registrar.setServiceLocator(locatorClient);
registrar.setEndpointPrefix(endpointPrefix);
Map<String, String> endpointPrefixes = new HashMap<String, String>();
endpointPrefixes.put("HTTP", endpointPrefixHttp);
endpointPrefixes.put("HTTPS", endpointPrefixHttps);
registrar.setEndpointPrefixes(endpointPrefixes);
busRegistrars.put(bus, registrar);
addLifeCycleListener(bus);
}
return registrar;
}
|
[
"protected",
"SingleBusLocatorRegistrar",
"getRegistrar",
"(",
"Bus",
"bus",
")",
"{",
"SingleBusLocatorRegistrar",
"registrar",
"=",
"busRegistrars",
".",
"get",
"(",
"bus",
")",
";",
"if",
"(",
"registrar",
"==",
"null",
")",
"{",
"check",
"(",
"locatorClient",
",",
"\"serviceLocator\"",
",",
"\"registerService\"",
")",
";",
"registrar",
"=",
"new",
"SingleBusLocatorRegistrar",
"(",
"bus",
")",
";",
"registrar",
".",
"setServiceLocator",
"(",
"locatorClient",
")",
";",
"registrar",
".",
"setEndpointPrefix",
"(",
"endpointPrefix",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"endpointPrefixes",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"endpointPrefixes",
".",
"put",
"(",
"\"HTTP\"",
",",
"endpointPrefixHttp",
")",
";",
"endpointPrefixes",
".",
"put",
"(",
"\"HTTPS\"",
",",
"endpointPrefixHttps",
")",
";",
"registrar",
".",
"setEndpointPrefixes",
"(",
"endpointPrefixes",
")",
";",
"busRegistrars",
".",
"put",
"(",
"bus",
",",
"registrar",
")",
";",
"addLifeCycleListener",
"(",
"bus",
")",
";",
"}",
"return",
"registrar",
";",
"}"
] |
Retrieves the registar linked to the bus.
Creates a new registar is not present.
@param bus
@return
|
[
"Retrieves",
"the",
"registar",
"linked",
"to",
"the",
"bus",
".",
"Creates",
"a",
"new",
"registar",
"is",
"not",
"present",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/LocatorRegistrar.java#L105-L120
|
160,260 |
Talend/tesb-rt-se
|
examples/cxf/jaxrs-attachments/client/src/main/java/client/RESTClient.java
|
RESTClient.useXopAttachmentServiceWithWebClient
|
public void useXopAttachmentServiceWithWebClient() throws Exception {
final String serviceURI = "http://localhost:" + port + "/services/attachments/xop";
JAXRSClientFactoryBean factoryBean = new JAXRSClientFactoryBean();
factoryBean.setAddress(serviceURI);
factoryBean.setProperties(Collections.singletonMap(org.apache.cxf.message.Message.MTOM_ENABLED,
(Object)"true"));
WebClient client = factoryBean.createWebClient();
WebClient.getConfig(client).getRequestContext().put("support.type.as.multipart",
"true");
client.type("multipart/related").accept("multipart/related");
XopBean xop = createXopBean();
System.out.println();
System.out.println("Posting a XOP attachment with a WebClient");
XopBean xopResponse = client.post(xop, XopBean.class);
verifyXopResponse(xop, xopResponse);
}
|
java
|
public void useXopAttachmentServiceWithWebClient() throws Exception {
final String serviceURI = "http://localhost:" + port + "/services/attachments/xop";
JAXRSClientFactoryBean factoryBean = new JAXRSClientFactoryBean();
factoryBean.setAddress(serviceURI);
factoryBean.setProperties(Collections.singletonMap(org.apache.cxf.message.Message.MTOM_ENABLED,
(Object)"true"));
WebClient client = factoryBean.createWebClient();
WebClient.getConfig(client).getRequestContext().put("support.type.as.multipart",
"true");
client.type("multipart/related").accept("multipart/related");
XopBean xop = createXopBean();
System.out.println();
System.out.println("Posting a XOP attachment with a WebClient");
XopBean xopResponse = client.post(xop, XopBean.class);
verifyXopResponse(xop, xopResponse);
}
|
[
"public",
"void",
"useXopAttachmentServiceWithWebClient",
"(",
")",
"throws",
"Exception",
"{",
"final",
"String",
"serviceURI",
"=",
"\"http://localhost:\"",
"+",
"port",
"+",
"\"/services/attachments/xop\"",
";",
"JAXRSClientFactoryBean",
"factoryBean",
"=",
"new",
"JAXRSClientFactoryBean",
"(",
")",
";",
"factoryBean",
".",
"setAddress",
"(",
"serviceURI",
")",
";",
"factoryBean",
".",
"setProperties",
"(",
"Collections",
".",
"singletonMap",
"(",
"org",
".",
"apache",
".",
"cxf",
".",
"message",
".",
"Message",
".",
"MTOM_ENABLED",
",",
"(",
"Object",
")",
"\"true\"",
")",
")",
";",
"WebClient",
"client",
"=",
"factoryBean",
".",
"createWebClient",
"(",
")",
";",
"WebClient",
".",
"getConfig",
"(",
"client",
")",
".",
"getRequestContext",
"(",
")",
".",
"put",
"(",
"\"support.type.as.multipart\"",
",",
"\"true\"",
")",
";",
"client",
".",
"type",
"(",
"\"multipart/related\"",
")",
".",
"accept",
"(",
"\"multipart/related\"",
")",
";",
"XopBean",
"xop",
"=",
"createXopBean",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Posting a XOP attachment with a WebClient\"",
")",
";",
"XopBean",
"xopResponse",
"=",
"client",
".",
"post",
"(",
"xop",
",",
"XopBean",
".",
"class",
")",
";",
"verifyXopResponse",
"(",
"xop",
",",
"xopResponse",
")",
";",
"}"
] |
Writes and reads the XOP attachment using a CXF JAX-RS WebClient.
Note that WebClient is created with the help of JAXRSClientFactoryBean.
JAXRSClientFactoryBean can be used when neither of the WebClient factory
methods is appropriate. For example, in this case, an "mtom-enabled"
property is set on the factory bean first.
@throws Exception
|
[
"Writes",
"and",
"reads",
"the",
"XOP",
"attachment",
"using",
"a",
"CXF",
"JAX",
"-",
"RS",
"WebClient",
".",
"Note",
"that",
"WebClient",
"is",
"created",
"with",
"the",
"help",
"of",
"JAXRSClientFactoryBean",
".",
"JAXRSClientFactoryBean",
"can",
"be",
"used",
"when",
"neither",
"of",
"the",
"WebClient",
"factory",
"methods",
"is",
"appropriate",
".",
"For",
"example",
"in",
"this",
"case",
"an",
"mtom",
"-",
"enabled",
"property",
"is",
"set",
"on",
"the",
"factory",
"bean",
"first",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/cxf/jaxrs-attachments/client/src/main/java/client/RESTClient.java#L71-L92
|
160,261 |
Talend/tesb-rt-se
|
examples/cxf/jaxrs-attachments/client/src/main/java/client/RESTClient.java
|
RESTClient.useXopAttachmentServiceWithProxy
|
public void useXopAttachmentServiceWithProxy() throws Exception {
final String serviceURI = "http://localhost:" + port + "/services/attachments";
XopAttachmentService proxy = JAXRSClientFactory.create(serviceURI,
XopAttachmentService.class);
XopBean xop = createXopBean();
System.out.println();
System.out.println("Posting a XOP attachment with a proxy");
XopBean xopResponse = proxy.echoXopAttachment(xop);
verifyXopResponse(xop, xopResponse);
}
|
java
|
public void useXopAttachmentServiceWithProxy() throws Exception {
final String serviceURI = "http://localhost:" + port + "/services/attachments";
XopAttachmentService proxy = JAXRSClientFactory.create(serviceURI,
XopAttachmentService.class);
XopBean xop = createXopBean();
System.out.println();
System.out.println("Posting a XOP attachment with a proxy");
XopBean xopResponse = proxy.echoXopAttachment(xop);
verifyXopResponse(xop, xopResponse);
}
|
[
"public",
"void",
"useXopAttachmentServiceWithProxy",
"(",
")",
"throws",
"Exception",
"{",
"final",
"String",
"serviceURI",
"=",
"\"http://localhost:\"",
"+",
"port",
"+",
"\"/services/attachments\"",
";",
"XopAttachmentService",
"proxy",
"=",
"JAXRSClientFactory",
".",
"create",
"(",
"serviceURI",
",",
"XopAttachmentService",
".",
"class",
")",
";",
"XopBean",
"xop",
"=",
"createXopBean",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Posting a XOP attachment with a proxy\"",
")",
";",
"XopBean",
"xopResponse",
"=",
"proxy",
".",
"echoXopAttachment",
"(",
"xop",
")",
";",
"verifyXopResponse",
"(",
"xop",
",",
"xopResponse",
")",
";",
"}"
] |
Writes and reads the XOP attachment using a CXF JAX-RS Proxy
The proxy automatically sets the "mtom-enabled" property by checking
the CXF EndpointProperty set on the XopAttachment interface.
@throws Exception
|
[
"Writes",
"and",
"reads",
"the",
"XOP",
"attachment",
"using",
"a",
"CXF",
"JAX",
"-",
"RS",
"Proxy",
"The",
"proxy",
"automatically",
"sets",
"the",
"mtom",
"-",
"enabled",
"property",
"by",
"checking",
"the",
"CXF",
"EndpointProperty",
"set",
"on",
"the",
"XopAttachment",
"interface",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/cxf/jaxrs-attachments/client/src/main/java/client/RESTClient.java#L101-L116
|
160,262 |
Talend/tesb-rt-se
|
examples/cxf/jaxrs-attachments/client/src/main/java/client/RESTClient.java
|
RESTClient.createXopBean
|
private XopBean createXopBean() throws Exception {
XopBean xop = new XopBean();
xop.setName("xopName");
InputStream is = getClass().getResourceAsStream("/java.jpg");
byte[] data = IOUtils.readBytesFromStream(is);
// Pass java.jpg as an array of bytes
xop.setBytes(data);
// Wrap java.jpg as a DataHandler
xop.setDatahandler(new DataHandler(
new ByteArrayDataSource(data, "application/octet-stream")));
if (Boolean.getBoolean("java.awt.headless")) {
System.out.println("Running headless. Ignoring an Image property.");
} else {
xop.setImage(getImage("/java.jpg"));
}
return xop;
}
|
java
|
private XopBean createXopBean() throws Exception {
XopBean xop = new XopBean();
xop.setName("xopName");
InputStream is = getClass().getResourceAsStream("/java.jpg");
byte[] data = IOUtils.readBytesFromStream(is);
// Pass java.jpg as an array of bytes
xop.setBytes(data);
// Wrap java.jpg as a DataHandler
xop.setDatahandler(new DataHandler(
new ByteArrayDataSource(data, "application/octet-stream")));
if (Boolean.getBoolean("java.awt.headless")) {
System.out.println("Running headless. Ignoring an Image property.");
} else {
xop.setImage(getImage("/java.jpg"));
}
return xop;
}
|
[
"private",
"XopBean",
"createXopBean",
"(",
")",
"throws",
"Exception",
"{",
"XopBean",
"xop",
"=",
"new",
"XopBean",
"(",
")",
";",
"xop",
".",
"setName",
"(",
"\"xopName\"",
")",
";",
"InputStream",
"is",
"=",
"getClass",
"(",
")",
".",
"getResourceAsStream",
"(",
"\"/java.jpg\"",
")",
";",
"byte",
"[",
"]",
"data",
"=",
"IOUtils",
".",
"readBytesFromStream",
"(",
"is",
")",
";",
"// Pass java.jpg as an array of bytes",
"xop",
".",
"setBytes",
"(",
"data",
")",
";",
"// Wrap java.jpg as a DataHandler",
"xop",
".",
"setDatahandler",
"(",
"new",
"DataHandler",
"(",
"new",
"ByteArrayDataSource",
"(",
"data",
",",
"\"application/octet-stream\"",
")",
")",
")",
";",
"if",
"(",
"Boolean",
".",
"getBoolean",
"(",
"\"java.awt.headless\"",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Running headless. Ignoring an Image property.\"",
")",
";",
"}",
"else",
"{",
"xop",
".",
"setImage",
"(",
"getImage",
"(",
"\"/java.jpg\"",
")",
")",
";",
"}",
"return",
"xop",
";",
"}"
] |
Creates a XopBean. The image on the disk is included as a byte array,
a DataHandler and java.awt.Image
@return the bean
@throws Exception
|
[
"Creates",
"a",
"XopBean",
".",
"The",
"image",
"on",
"the",
"disk",
"is",
"included",
"as",
"a",
"byte",
"array",
"a",
"DataHandler",
"and",
"java",
".",
"awt",
".",
"Image"
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/cxf/jaxrs-attachments/client/src/main/java/client/RESTClient.java#L191-L212
|
160,263 |
Talend/tesb-rt-se
|
examples/cxf/jaxrs-attachments/client/src/main/java/client/RESTClient.java
|
RESTClient.verifyXopResponse
|
private void verifyXopResponse(XopBean xopOriginal, XopBean xopResponse) {
if (!Arrays.equals(xopResponse.getBytes(), xopOriginal.getBytes())) {
throw new RuntimeException("Received XOP attachment is corrupted");
}
System.out.println();
System.out.println("XOP attachment has been successfully received");
}
|
java
|
private void verifyXopResponse(XopBean xopOriginal, XopBean xopResponse) {
if (!Arrays.equals(xopResponse.getBytes(), xopOriginal.getBytes())) {
throw new RuntimeException("Received XOP attachment is corrupted");
}
System.out.println();
System.out.println("XOP attachment has been successfully received");
}
|
[
"private",
"void",
"verifyXopResponse",
"(",
"XopBean",
"xopOriginal",
",",
"XopBean",
"xopResponse",
")",
"{",
"if",
"(",
"!",
"Arrays",
".",
"equals",
"(",
"xopResponse",
".",
"getBytes",
"(",
")",
",",
"xopOriginal",
".",
"getBytes",
"(",
")",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Received XOP attachment is corrupted\"",
")",
";",
"}",
"System",
".",
"out",
".",
"println",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"XOP attachment has been successfully received\"",
")",
";",
"}"
] |
Verifies that the received image is identical to the original one.
@param xopOriginal
@param xopResponse
|
[
"Verifies",
"that",
"the",
"received",
"image",
"is",
"identical",
"to",
"the",
"original",
"one",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/cxf/jaxrs-attachments/client/src/main/java/client/RESTClient.java#L219-L225
|
160,264 |
Talend/tesb-rt-se
|
sam/sam-service-soap/src/main/java/org/talend/esb/sam/service/soap/MonitoringWebService.java
|
MonitoringWebService.setMonitoringService
|
public void setMonitoringService(org.talend.esb.sam.common.service.MonitoringService monitoringService) {
this.monitoringService = monitoringService;
}
|
java
|
public void setMonitoringService(org.talend.esb.sam.common.service.MonitoringService monitoringService) {
this.monitoringService = monitoringService;
}
|
[
"public",
"void",
"setMonitoringService",
"(",
"org",
".",
"talend",
".",
"esb",
".",
"sam",
".",
"common",
".",
"service",
".",
"MonitoringService",
"monitoringService",
")",
"{",
"this",
".",
"monitoringService",
"=",
"monitoringService",
";",
"}"
] |
Sets the monitoring service.
@param monitoringService the new monitoring service
|
[
"Sets",
"the",
"monitoring",
"service",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-service-soap/src/main/java/org/talend/esb/sam/service/soap/MonitoringWebService.java#L50-L52
|
160,265 |
Talend/tesb-rt-se
|
sam/sam-service-soap/src/main/java/org/talend/esb/sam/service/soap/MonitoringWebService.java
|
MonitoringWebService.throwFault
|
private static void throwFault(String code, String message, Throwable t) throws PutEventsFault {
if (LOG.isLoggable(Level.SEVERE)) {
LOG.log(Level.SEVERE, "Throw Fault " + code + " " + message, t);
}
FaultType faultType = new FaultType();
faultType.setFaultCode(code);
faultType.setFaultMessage(message);
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
t.printStackTrace(printWriter);
faultType.setStackTrace(stringWriter.toString());
throw new PutEventsFault(message, faultType, t);
}
|
java
|
private static void throwFault(String code, String message, Throwable t) throws PutEventsFault {
if (LOG.isLoggable(Level.SEVERE)) {
LOG.log(Level.SEVERE, "Throw Fault " + code + " " + message, t);
}
FaultType faultType = new FaultType();
faultType.setFaultCode(code);
faultType.setFaultMessage(message);
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
t.printStackTrace(printWriter);
faultType.setStackTrace(stringWriter.toString());
throw new PutEventsFault(message, faultType, t);
}
|
[
"private",
"static",
"void",
"throwFault",
"(",
"String",
"code",
",",
"String",
"message",
",",
"Throwable",
"t",
")",
"throws",
"PutEventsFault",
"{",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"SEVERE",
")",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Throw Fault \"",
"+",
"code",
"+",
"\" \"",
"+",
"message",
",",
"t",
")",
";",
"}",
"FaultType",
"faultType",
"=",
"new",
"FaultType",
"(",
")",
";",
"faultType",
".",
"setFaultCode",
"(",
"code",
")",
";",
"faultType",
".",
"setFaultMessage",
"(",
"message",
")",
";",
"StringWriter",
"stringWriter",
"=",
"new",
"StringWriter",
"(",
")",
";",
"PrintWriter",
"printWriter",
"=",
"new",
"PrintWriter",
"(",
"stringWriter",
")",
";",
"t",
".",
"printStackTrace",
"(",
"printWriter",
")",
";",
"faultType",
".",
"setStackTrace",
"(",
"stringWriter",
".",
"toString",
"(",
")",
")",
";",
"throw",
"new",
"PutEventsFault",
"(",
"message",
",",
"faultType",
",",
"t",
")",
";",
"}"
] |
Throw fault.
@param code the fault code
@param message the message
@param t the throwable type
@throws PutEventsFault
|
[
"Throw",
"fault",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-service-soap/src/main/java/org/talend/esb/sam/service/soap/MonitoringWebService.java#L91-L108
|
160,266 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/serviceclient/MonitoringServiceWrapper.java
|
MonitoringServiceWrapper.putEvents
|
public void putEvents(List<Event> events) {
Exception lastException;
List<EventType> eventTypes = new ArrayList<EventType>();
for (Event event : events) {
EventType eventType = EventMapper.map(event);
eventTypes.add(eventType);
}
int i = 0;
lastException = null;
while (i < numberOfRetries) {
try {
monitoringService.putEvents(eventTypes);
break;
} catch (Exception e) {
lastException = e;
i++;
}
if(i < numberOfRetries) {
try {
Thread.sleep(delayBetweenRetry);
} catch (InterruptedException e) {
break;
}
}
}
if (i == numberOfRetries) {
throw new MonitoringException("1104", "Could not send events to monitoring service after "
+ numberOfRetries + " retries.", lastException, events);
}
}
|
java
|
public void putEvents(List<Event> events) {
Exception lastException;
List<EventType> eventTypes = new ArrayList<EventType>();
for (Event event : events) {
EventType eventType = EventMapper.map(event);
eventTypes.add(eventType);
}
int i = 0;
lastException = null;
while (i < numberOfRetries) {
try {
monitoringService.putEvents(eventTypes);
break;
} catch (Exception e) {
lastException = e;
i++;
}
if(i < numberOfRetries) {
try {
Thread.sleep(delayBetweenRetry);
} catch (InterruptedException e) {
break;
}
}
}
if (i == numberOfRetries) {
throw new MonitoringException("1104", "Could not send events to monitoring service after "
+ numberOfRetries + " retries.", lastException, events);
}
}
|
[
"public",
"void",
"putEvents",
"(",
"List",
"<",
"Event",
">",
"events",
")",
"{",
"Exception",
"lastException",
";",
"List",
"<",
"EventType",
">",
"eventTypes",
"=",
"new",
"ArrayList",
"<",
"EventType",
">",
"(",
")",
";",
"for",
"(",
"Event",
"event",
":",
"events",
")",
"{",
"EventType",
"eventType",
"=",
"EventMapper",
".",
"map",
"(",
"event",
")",
";",
"eventTypes",
".",
"add",
"(",
"eventType",
")",
";",
"}",
"int",
"i",
"=",
"0",
";",
"lastException",
"=",
"null",
";",
"while",
"(",
"i",
"<",
"numberOfRetries",
")",
"{",
"try",
"{",
"monitoringService",
".",
"putEvents",
"(",
"eventTypes",
")",
";",
"break",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"lastException",
"=",
"e",
";",
"i",
"++",
";",
"}",
"if",
"(",
"i",
"<",
"numberOfRetries",
")",
"{",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"delayBetweenRetry",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"i",
"==",
"numberOfRetries",
")",
"{",
"throw",
"new",
"MonitoringException",
"(",
"\"1104\"",
",",
"\"Could not send events to monitoring service after \"",
"+",
"numberOfRetries",
"+",
"\" retries.\"",
",",
"lastException",
",",
"events",
")",
";",
"}",
"}"
] |
Sends all events to the web service. Events will be transformed with mapper before sending.
@param events the events
|
[
"Sends",
"all",
"events",
"to",
"the",
"web",
"service",
".",
"Events",
"will",
"be",
"transformed",
"with",
"mapper",
"before",
"sending",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/serviceclient/MonitoringServiceWrapper.java#L89-L120
|
160,267 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/activator/AgentActivator.java
|
AgentActivator.createEventType
|
private EventType createEventType(EventEnumType type) {
EventType eventType = new EventType();
eventType.setTimestamp(Converter.convertDate(new Date()));
eventType.setEventType(type);
OriginatorType origType = new OriginatorType();
origType.setProcessId(Converter.getPID());
try {
InetAddress inetAddress = InetAddress.getLocalHost();
origType.setIp(inetAddress.getHostAddress());
origType.setHostname(inetAddress.getHostName());
} catch (UnknownHostException e) {
origType.setHostname("Unknown hostname");
origType.setIp("Unknown ip address");
}
eventType.setOriginator(origType);
String path = System.getProperty("karaf.home");
CustomInfoType ciType = new CustomInfoType();
CustomInfoType.Item cItem = new CustomInfoType.Item();
cItem.setKey("path");
cItem.setValue(path);
ciType.getItem().add(cItem);
eventType.setCustomInfo(ciType);
return eventType;
}
|
java
|
private EventType createEventType(EventEnumType type) {
EventType eventType = new EventType();
eventType.setTimestamp(Converter.convertDate(new Date()));
eventType.setEventType(type);
OriginatorType origType = new OriginatorType();
origType.setProcessId(Converter.getPID());
try {
InetAddress inetAddress = InetAddress.getLocalHost();
origType.setIp(inetAddress.getHostAddress());
origType.setHostname(inetAddress.getHostName());
} catch (UnknownHostException e) {
origType.setHostname("Unknown hostname");
origType.setIp("Unknown ip address");
}
eventType.setOriginator(origType);
String path = System.getProperty("karaf.home");
CustomInfoType ciType = new CustomInfoType();
CustomInfoType.Item cItem = new CustomInfoType.Item();
cItem.setKey("path");
cItem.setValue(path);
ciType.getItem().add(cItem);
eventType.setCustomInfo(ciType);
return eventType;
}
|
[
"private",
"EventType",
"createEventType",
"(",
"EventEnumType",
"type",
")",
"{",
"EventType",
"eventType",
"=",
"new",
"EventType",
"(",
")",
";",
"eventType",
".",
"setTimestamp",
"(",
"Converter",
".",
"convertDate",
"(",
"new",
"Date",
"(",
")",
")",
")",
";",
"eventType",
".",
"setEventType",
"(",
"type",
")",
";",
"OriginatorType",
"origType",
"=",
"new",
"OriginatorType",
"(",
")",
";",
"origType",
".",
"setProcessId",
"(",
"Converter",
".",
"getPID",
"(",
")",
")",
";",
"try",
"{",
"InetAddress",
"inetAddress",
"=",
"InetAddress",
".",
"getLocalHost",
"(",
")",
";",
"origType",
".",
"setIp",
"(",
"inetAddress",
".",
"getHostAddress",
"(",
")",
")",
";",
"origType",
".",
"setHostname",
"(",
"inetAddress",
".",
"getHostName",
"(",
")",
")",
";",
"}",
"catch",
"(",
"UnknownHostException",
"e",
")",
"{",
"origType",
".",
"setHostname",
"(",
"\"Unknown hostname\"",
")",
";",
"origType",
".",
"setIp",
"(",
"\"Unknown ip address\"",
")",
";",
"}",
"eventType",
".",
"setOriginator",
"(",
"origType",
")",
";",
"String",
"path",
"=",
"System",
".",
"getProperty",
"(",
"\"karaf.home\"",
")",
";",
"CustomInfoType",
"ciType",
"=",
"new",
"CustomInfoType",
"(",
")",
";",
"CustomInfoType",
".",
"Item",
"cItem",
"=",
"new",
"CustomInfoType",
".",
"Item",
"(",
")",
";",
"cItem",
".",
"setKey",
"(",
"\"path\"",
")",
";",
"cItem",
".",
"setValue",
"(",
"path",
")",
";",
"ciType",
".",
"getItem",
"(",
")",
".",
"add",
"(",
"cItem",
")",
";",
"eventType",
".",
"setCustomInfo",
"(",
"ciType",
")",
";",
"return",
"eventType",
";",
"}"
] |
Creates the event type.
@param type the EventEnumType
@return the event type
|
[
"Creates",
"the",
"event",
"type",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/activator/AgentActivator.java#L98-L124
|
160,268 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/activator/AgentActivator.java
|
AgentActivator.putEvent
|
private void putEvent(EventType eventType) throws Exception {
List<EventType> eventTypes = Collections.singletonList(eventType);
int i;
for (i = 0; i < retryNum; ++i) {
try {
monitoringService.putEvents(eventTypes);
break;
} catch (Exception e) {
LOG.log(Level.SEVERE, e.getMessage(), e);
}
Thread.sleep(retryDelay);
}
if (i == retryNum) {
LOG.warning("Could not send events to monitoring service after " + retryNum + " retries.");
throw new Exception("Send SERVER_START/SERVER_STOP event to SAM Server failed");
}
}
|
java
|
private void putEvent(EventType eventType) throws Exception {
List<EventType> eventTypes = Collections.singletonList(eventType);
int i;
for (i = 0; i < retryNum; ++i) {
try {
monitoringService.putEvents(eventTypes);
break;
} catch (Exception e) {
LOG.log(Level.SEVERE, e.getMessage(), e);
}
Thread.sleep(retryDelay);
}
if (i == retryNum) {
LOG.warning("Could not send events to monitoring service after " + retryNum + " retries.");
throw new Exception("Send SERVER_START/SERVER_STOP event to SAM Server failed");
}
}
|
[
"private",
"void",
"putEvent",
"(",
"EventType",
"eventType",
")",
"throws",
"Exception",
"{",
"List",
"<",
"EventType",
">",
"eventTypes",
"=",
"Collections",
".",
"singletonList",
"(",
"eventType",
")",
";",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"retryNum",
";",
"++",
"i",
")",
"{",
"try",
"{",
"monitoringService",
".",
"putEvents",
"(",
"eventTypes",
")",
";",
"break",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"Thread",
".",
"sleep",
"(",
"retryDelay",
")",
";",
"}",
"if",
"(",
"i",
"==",
"retryNum",
")",
"{",
"LOG",
".",
"warning",
"(",
"\"Could not send events to monitoring service after \"",
"+",
"retryNum",
"+",
"\" retries.\"",
")",
";",
"throw",
"new",
"Exception",
"(",
"\"Send SERVER_START/SERVER_STOP event to SAM Server failed\"",
")",
";",
"}",
"}"
] |
Put event.
@param eventType the event type
@throws Exception the exception
|
[
"Put",
"event",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/activator/AgentActivator.java#L132-L151
|
160,269 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/activator/AgentActivator.java
|
AgentActivator.checkConfig
|
private boolean checkConfig(BundleContext context) throws Exception {
ServiceReference serviceRef = context.getServiceReference(ConfigurationAdmin.class.getName());
ConfigurationAdmin cfgAdmin = (ConfigurationAdmin)context.getService(serviceRef);
Configuration config = cfgAdmin.getConfiguration("org.talend.esb.sam.agent");
return "true".equalsIgnoreCase((String)config.getProperties().get("collector.lifecycleEvent"));
}
|
java
|
private boolean checkConfig(BundleContext context) throws Exception {
ServiceReference serviceRef = context.getServiceReference(ConfigurationAdmin.class.getName());
ConfigurationAdmin cfgAdmin = (ConfigurationAdmin)context.getService(serviceRef);
Configuration config = cfgAdmin.getConfiguration("org.talend.esb.sam.agent");
return "true".equalsIgnoreCase((String)config.getProperties().get("collector.lifecycleEvent"));
}
|
[
"private",
"boolean",
"checkConfig",
"(",
"BundleContext",
"context",
")",
"throws",
"Exception",
"{",
"ServiceReference",
"serviceRef",
"=",
"context",
".",
"getServiceReference",
"(",
"ConfigurationAdmin",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"ConfigurationAdmin",
"cfgAdmin",
"=",
"(",
"ConfigurationAdmin",
")",
"context",
".",
"getService",
"(",
"serviceRef",
")",
";",
"Configuration",
"config",
"=",
"cfgAdmin",
".",
"getConfiguration",
"(",
"\"org.talend.esb.sam.agent\"",
")",
";",
"return",
"\"true\"",
".",
"equalsIgnoreCase",
"(",
"(",
"String",
")",
"config",
".",
"getProperties",
"(",
")",
".",
"get",
"(",
"\"collector.lifecycleEvent\"",
")",
")",
";",
"}"
] |
Check config.
@param context the context
@return true, if successful
@throws Exception the exception
|
[
"Check",
"config",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/activator/AgentActivator.java#L160-L166
|
160,270 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/activator/AgentActivator.java
|
AgentActivator.initWsClient
|
private void initWsClient(BundleContext context) throws Exception {
ServiceReference serviceRef = context.getServiceReference(ConfigurationAdmin.class.getName());
ConfigurationAdmin cfgAdmin = (ConfigurationAdmin)context.getService(serviceRef);
Configuration config = cfgAdmin.getConfiguration("org.talend.esb.sam.agent");
String serviceURL = (String)config.getProperties().get("service.url");
retryNum = Integer.parseInt((String)config.getProperties().get("service.retry.number"));
retryDelay = Long.parseLong((String)config.getProperties().get("service.retry.delay"));
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(org.talend.esb.sam.monitoringservice.v1.MonitoringService.class);
factory.setAddress(serviceURL);
monitoringService = (MonitoringService)factory.create();
}
|
java
|
private void initWsClient(BundleContext context) throws Exception {
ServiceReference serviceRef = context.getServiceReference(ConfigurationAdmin.class.getName());
ConfigurationAdmin cfgAdmin = (ConfigurationAdmin)context.getService(serviceRef);
Configuration config = cfgAdmin.getConfiguration("org.talend.esb.sam.agent");
String serviceURL = (String)config.getProperties().get("service.url");
retryNum = Integer.parseInt((String)config.getProperties().get("service.retry.number"));
retryDelay = Long.parseLong((String)config.getProperties().get("service.retry.delay"));
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(org.talend.esb.sam.monitoringservice.v1.MonitoringService.class);
factory.setAddress(serviceURL);
monitoringService = (MonitoringService)factory.create();
}
|
[
"private",
"void",
"initWsClient",
"(",
"BundleContext",
"context",
")",
"throws",
"Exception",
"{",
"ServiceReference",
"serviceRef",
"=",
"context",
".",
"getServiceReference",
"(",
"ConfigurationAdmin",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"ConfigurationAdmin",
"cfgAdmin",
"=",
"(",
"ConfigurationAdmin",
")",
"context",
".",
"getService",
"(",
"serviceRef",
")",
";",
"Configuration",
"config",
"=",
"cfgAdmin",
".",
"getConfiguration",
"(",
"\"org.talend.esb.sam.agent\"",
")",
";",
"String",
"serviceURL",
"=",
"(",
"String",
")",
"config",
".",
"getProperties",
"(",
")",
".",
"get",
"(",
"\"service.url\"",
")",
";",
"retryNum",
"=",
"Integer",
".",
"parseInt",
"(",
"(",
"String",
")",
"config",
".",
"getProperties",
"(",
")",
".",
"get",
"(",
"\"service.retry.number\"",
")",
")",
";",
"retryDelay",
"=",
"Long",
".",
"parseLong",
"(",
"(",
"String",
")",
"config",
".",
"getProperties",
"(",
")",
".",
"get",
"(",
"\"service.retry.delay\"",
")",
")",
";",
"JaxWsProxyFactoryBean",
"factory",
"=",
"new",
"JaxWsProxyFactoryBean",
"(",
")",
";",
"factory",
".",
"setServiceClass",
"(",
"org",
".",
"talend",
".",
"esb",
".",
"sam",
".",
"monitoringservice",
".",
"v1",
".",
"MonitoringService",
".",
"class",
")",
";",
"factory",
".",
"setAddress",
"(",
"serviceURL",
")",
";",
"monitoringService",
"=",
"(",
"MonitoringService",
")",
"factory",
".",
"create",
"(",
")",
";",
"}"
] |
Inits the ws client.
@param context the context
@throws Exception the exception
|
[
"Inits",
"the",
"ws",
"client",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/activator/AgentActivator.java#L174-L187
|
160,271 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/flowidprocessor/FlowIdProducerOut.java
|
FlowIdProducerOut.handleResponseOut
|
protected void handleResponseOut(T message) throws Fault {
Message reqMsg = message.getExchange().getInMessage();
if (reqMsg == null) {
LOG.warning("InMessage is null!");
return;
}
// No flowId for oneway message
Exchange ex = reqMsg.getExchange();
if (ex.isOneWay()) {
return;
}
String reqFid = FlowIdHelper.getFlowId(reqMsg);
// if some interceptor throws fault before FlowIdProducerIn fired
if (reqFid == null) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Some interceptor throws fault.Setting FlowId in response.");
}
reqFid = FlowIdProtocolHeaderCodec.readFlowId(message);
}
// write IN message to SAM repo in case fault
if (reqFid == null) {
Message inMsg = ex.getInMessage();
reqFid = FlowIdProtocolHeaderCodec.readFlowId(inMsg);
if (null != reqFid) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("FlowId '" + reqFid
+ "' found in message of fault incoming exchange.");
LOG.fine("Calling EventProducerInterceptor to log IN message");
}
handleINEvent(ex, reqFid);
}
}
if (reqFid == null) {
reqFid = FlowIdSoapCodec.readFlowId(message);
}
if (reqFid != null) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("FlowId '" + reqFid + "' found in incoming message.");
}
} else {
reqFid = ContextUtils.generateUUID();
// write IN message to SAM repo in case fault
if (null != ex.getOutFaultMessage()) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("FlowId '" + reqFid
+ "' generated for fault message.");
LOG.fine("Calling EventProducerInterceptor to log IN message");
}
handleINEvent(ex, reqFid);
}
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("No flowId found in incoming message! Generate new flowId "
+ reqFid);
}
}
FlowIdHelper.setFlowId(message, reqFid);
}
|
java
|
protected void handleResponseOut(T message) throws Fault {
Message reqMsg = message.getExchange().getInMessage();
if (reqMsg == null) {
LOG.warning("InMessage is null!");
return;
}
// No flowId for oneway message
Exchange ex = reqMsg.getExchange();
if (ex.isOneWay()) {
return;
}
String reqFid = FlowIdHelper.getFlowId(reqMsg);
// if some interceptor throws fault before FlowIdProducerIn fired
if (reqFid == null) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Some interceptor throws fault.Setting FlowId in response.");
}
reqFid = FlowIdProtocolHeaderCodec.readFlowId(message);
}
// write IN message to SAM repo in case fault
if (reqFid == null) {
Message inMsg = ex.getInMessage();
reqFid = FlowIdProtocolHeaderCodec.readFlowId(inMsg);
if (null != reqFid) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("FlowId '" + reqFid
+ "' found in message of fault incoming exchange.");
LOG.fine("Calling EventProducerInterceptor to log IN message");
}
handleINEvent(ex, reqFid);
}
}
if (reqFid == null) {
reqFid = FlowIdSoapCodec.readFlowId(message);
}
if (reqFid != null) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("FlowId '" + reqFid + "' found in incoming message.");
}
} else {
reqFid = ContextUtils.generateUUID();
// write IN message to SAM repo in case fault
if (null != ex.getOutFaultMessage()) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("FlowId '" + reqFid
+ "' generated for fault message.");
LOG.fine("Calling EventProducerInterceptor to log IN message");
}
handleINEvent(ex, reqFid);
}
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("No flowId found in incoming message! Generate new flowId "
+ reqFid);
}
}
FlowIdHelper.setFlowId(message, reqFid);
}
|
[
"protected",
"void",
"handleResponseOut",
"(",
"T",
"message",
")",
"throws",
"Fault",
"{",
"Message",
"reqMsg",
"=",
"message",
".",
"getExchange",
"(",
")",
".",
"getInMessage",
"(",
")",
";",
"if",
"(",
"reqMsg",
"==",
"null",
")",
"{",
"LOG",
".",
"warning",
"(",
"\"InMessage is null!\"",
")",
";",
"return",
";",
"}",
"// No flowId for oneway message",
"Exchange",
"ex",
"=",
"reqMsg",
".",
"getExchange",
"(",
")",
";",
"if",
"(",
"ex",
".",
"isOneWay",
"(",
")",
")",
"{",
"return",
";",
"}",
"String",
"reqFid",
"=",
"FlowIdHelper",
".",
"getFlowId",
"(",
"reqMsg",
")",
";",
"// if some interceptor throws fault before FlowIdProducerIn fired",
"if",
"(",
"reqFid",
"==",
"null",
")",
"{",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"Some interceptor throws fault.Setting FlowId in response.\"",
")",
";",
"}",
"reqFid",
"=",
"FlowIdProtocolHeaderCodec",
".",
"readFlowId",
"(",
"message",
")",
";",
"}",
"// write IN message to SAM repo in case fault",
"if",
"(",
"reqFid",
"==",
"null",
")",
"{",
"Message",
"inMsg",
"=",
"ex",
".",
"getInMessage",
"(",
")",
";",
"reqFid",
"=",
"FlowIdProtocolHeaderCodec",
".",
"readFlowId",
"(",
"inMsg",
")",
";",
"if",
"(",
"null",
"!=",
"reqFid",
")",
"{",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"FlowId '\"",
"+",
"reqFid",
"+",
"\"' found in message of fault incoming exchange.\"",
")",
";",
"LOG",
".",
"fine",
"(",
"\"Calling EventProducerInterceptor to log IN message\"",
")",
";",
"}",
"handleINEvent",
"(",
"ex",
",",
"reqFid",
")",
";",
"}",
"}",
"if",
"(",
"reqFid",
"==",
"null",
")",
"{",
"reqFid",
"=",
"FlowIdSoapCodec",
".",
"readFlowId",
"(",
"message",
")",
";",
"}",
"if",
"(",
"reqFid",
"!=",
"null",
")",
"{",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"FlowId '\"",
"+",
"reqFid",
"+",
"\"' found in incoming message.\"",
")",
";",
"}",
"}",
"else",
"{",
"reqFid",
"=",
"ContextUtils",
".",
"generateUUID",
"(",
")",
";",
"// write IN message to SAM repo in case fault",
"if",
"(",
"null",
"!=",
"ex",
".",
"getOutFaultMessage",
"(",
")",
")",
"{",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"FlowId '\"",
"+",
"reqFid",
"+",
"\"' generated for fault message.\"",
")",
";",
"LOG",
".",
"fine",
"(",
"\"Calling EventProducerInterceptor to log IN message\"",
")",
";",
"}",
"handleINEvent",
"(",
"ex",
",",
"reqFid",
")",
";",
"}",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"No flowId found in incoming message! Generate new flowId \"",
"+",
"reqFid",
")",
";",
"}",
"}",
"FlowIdHelper",
".",
"setFlowId",
"(",
"message",
",",
"reqFid",
")",
";",
"}"
] |
Handling out responce.
@param message
the message
@throws Fault
the fault
|
[
"Handling",
"out",
"responce",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/flowidprocessor/FlowIdProducerOut.java#L98-L164
|
160,272 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/flowidprocessor/FlowIdProducerOut.java
|
FlowIdProducerOut.handleRequestOut
|
protected void handleRequestOut(T message) throws Fault {
String flowId = FlowIdHelper.getFlowId(message);
if (flowId == null
&& message.containsKey(PhaseInterceptorChain.PREVIOUS_MESSAGE)) {
// Web Service consumer is acting as an intermediary
@SuppressWarnings("unchecked")
WeakReference<Message> wrPreviousMessage = (WeakReference<Message>) message
.get(PhaseInterceptorChain.PREVIOUS_MESSAGE);
Message previousMessage = (Message) wrPreviousMessage.get();
flowId = FlowIdHelper.getFlowId(previousMessage);
if (flowId != null && LOG.isLoggable(Level.FINE)) {
LOG.fine("flowId '" + flowId + "' found in previous message");
}
}
if (flowId == null) {
// No flowId found. Generate one.
flowId = ContextUtils.generateUUID();
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Generate new flowId '" + flowId + "'");
}
}
FlowIdHelper.setFlowId(message, flowId);
}
|
java
|
protected void handleRequestOut(T message) throws Fault {
String flowId = FlowIdHelper.getFlowId(message);
if (flowId == null
&& message.containsKey(PhaseInterceptorChain.PREVIOUS_MESSAGE)) {
// Web Service consumer is acting as an intermediary
@SuppressWarnings("unchecked")
WeakReference<Message> wrPreviousMessage = (WeakReference<Message>) message
.get(PhaseInterceptorChain.PREVIOUS_MESSAGE);
Message previousMessage = (Message) wrPreviousMessage.get();
flowId = FlowIdHelper.getFlowId(previousMessage);
if (flowId != null && LOG.isLoggable(Level.FINE)) {
LOG.fine("flowId '" + flowId + "' found in previous message");
}
}
if (flowId == null) {
// No flowId found. Generate one.
flowId = ContextUtils.generateUUID();
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Generate new flowId '" + flowId + "'");
}
}
FlowIdHelper.setFlowId(message, flowId);
}
|
[
"protected",
"void",
"handleRequestOut",
"(",
"T",
"message",
")",
"throws",
"Fault",
"{",
"String",
"flowId",
"=",
"FlowIdHelper",
".",
"getFlowId",
"(",
"message",
")",
";",
"if",
"(",
"flowId",
"==",
"null",
"&&",
"message",
".",
"containsKey",
"(",
"PhaseInterceptorChain",
".",
"PREVIOUS_MESSAGE",
")",
")",
"{",
"// Web Service consumer is acting as an intermediary",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"WeakReference",
"<",
"Message",
">",
"wrPreviousMessage",
"=",
"(",
"WeakReference",
"<",
"Message",
">",
")",
"message",
".",
"get",
"(",
"PhaseInterceptorChain",
".",
"PREVIOUS_MESSAGE",
")",
";",
"Message",
"previousMessage",
"=",
"(",
"Message",
")",
"wrPreviousMessage",
".",
"get",
"(",
")",
";",
"flowId",
"=",
"FlowIdHelper",
".",
"getFlowId",
"(",
"previousMessage",
")",
";",
"if",
"(",
"flowId",
"!=",
"null",
"&&",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"flowId '\"",
"+",
"flowId",
"+",
"\"' found in previous message\"",
")",
";",
"}",
"}",
"if",
"(",
"flowId",
"==",
"null",
")",
"{",
"// No flowId found. Generate one.",
"flowId",
"=",
"ContextUtils",
".",
"generateUUID",
"(",
")",
";",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"Generate new flowId '\"",
"+",
"flowId",
"+",
"\"'\"",
")",
";",
"}",
"}",
"FlowIdHelper",
".",
"setFlowId",
"(",
"message",
",",
"flowId",
")",
";",
"}"
] |
Handling out request.
@param message
the message
@throws Fault
the fault
|
[
"Handling",
"out",
"request",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/flowidprocessor/FlowIdProducerOut.java#L174-L198
|
160,273 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/flowidprocessor/FlowIdProducerOut.java
|
FlowIdProducerOut.handleINEvent
|
protected void handleINEvent(Exchange exchange, String reqFid) throws Fault {
Message inMsg = exchange.getInMessage();
EventProducerInterceptor epi = null;
FlowIdHelper.setFlowId(inMsg, reqFid);
ListIterator<Interceptor<? extends Message>> interceptors = inMsg
.getInterceptorChain().getIterator();
while (interceptors.hasNext() && epi == null) {
Interceptor<? extends Message> interceptor = interceptors.next();
if (interceptor instanceof EventProducerInterceptor) {
epi = (EventProducerInterceptor) interceptor;
epi.handleMessage(inMsg);
}
}
}
|
java
|
protected void handleINEvent(Exchange exchange, String reqFid) throws Fault {
Message inMsg = exchange.getInMessage();
EventProducerInterceptor epi = null;
FlowIdHelper.setFlowId(inMsg, reqFid);
ListIterator<Interceptor<? extends Message>> interceptors = inMsg
.getInterceptorChain().getIterator();
while (interceptors.hasNext() && epi == null) {
Interceptor<? extends Message> interceptor = interceptors.next();
if (interceptor instanceof EventProducerInterceptor) {
epi = (EventProducerInterceptor) interceptor;
epi.handleMessage(inMsg);
}
}
}
|
[
"protected",
"void",
"handleINEvent",
"(",
"Exchange",
"exchange",
",",
"String",
"reqFid",
")",
"throws",
"Fault",
"{",
"Message",
"inMsg",
"=",
"exchange",
".",
"getInMessage",
"(",
")",
";",
"EventProducerInterceptor",
"epi",
"=",
"null",
";",
"FlowIdHelper",
".",
"setFlowId",
"(",
"inMsg",
",",
"reqFid",
")",
";",
"ListIterator",
"<",
"Interceptor",
"<",
"?",
"extends",
"Message",
">",
">",
"interceptors",
"=",
"inMsg",
".",
"getInterceptorChain",
"(",
")",
".",
"getIterator",
"(",
")",
";",
"while",
"(",
"interceptors",
".",
"hasNext",
"(",
")",
"&&",
"epi",
"==",
"null",
")",
"{",
"Interceptor",
"<",
"?",
"extends",
"Message",
">",
"interceptor",
"=",
"interceptors",
".",
"next",
"(",
")",
";",
"if",
"(",
"interceptor",
"instanceof",
"EventProducerInterceptor",
")",
"{",
"epi",
"=",
"(",
"EventProducerInterceptor",
")",
"interceptor",
";",
"epi",
".",
"handleMessage",
"(",
"inMsg",
")",
";",
"}",
"}",
"}"
] |
Calling EventProducerInterceptor in case of logging faults.
@param exchange
the message exchange
@param reqFid
the FlowId
@throws Fault
the fault
|
[
"Calling",
"EventProducerInterceptor",
"in",
"case",
"of",
"logging",
"faults",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/flowidprocessor/FlowIdProducerOut.java#L211-L228
|
160,274 |
Talend/tesb-rt-se
|
sam/sam-server/src/main/java/org/talend/esb/sam/server/persistence/DBInitializer.java
|
DBInitializer.setDialect
|
public void setDialect(String dialect) {
String[] scripts = createScripts.get(dialect);
createSql = scripts[0];
createSqlInd = scripts[1];
}
|
java
|
public void setDialect(String dialect) {
String[] scripts = createScripts.get(dialect);
createSql = scripts[0];
createSqlInd = scripts[1];
}
|
[
"public",
"void",
"setDialect",
"(",
"String",
"dialect",
")",
"{",
"String",
"[",
"]",
"scripts",
"=",
"createScripts",
".",
"get",
"(",
"dialect",
")",
";",
"createSql",
"=",
"scripts",
"[",
"0",
"]",
";",
"createSqlInd",
"=",
"scripts",
"[",
"1",
"]",
";",
"}"
] |
Sets the database dialect.
@param dialect
the database dialect
|
[
"Sets",
"the",
"database",
"dialect",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-server/src/main/java/org/talend/esb/sam/server/persistence/DBInitializer.java#L63-L67
|
160,275 |
Talend/tesb-rt-se
|
sam/sam-service-soap/src/main/java/org/talend/esb/sam/service/soap/EventTypeMapper.java
|
EventTypeMapper.map
|
public static Event map(EventType eventType) {
Event event = new Event();
event.setEventType(mapEventTypeEnum(eventType.getEventType()));
Date date = (eventType.getTimestamp() == null)
? new Date() : eventType.getTimestamp().toGregorianCalendar().getTime();
event.setTimestamp(date);
event.setOriginator(mapOriginatorType(eventType.getOriginator()));
MessageInfo messageInfo = mapMessageInfo(eventType.getMessageInfo());
event.setMessageInfo(messageInfo);
String content = mapContent(eventType.getContent());
event.setContent(content);
event.getCustomInfo().clear();
event.getCustomInfo().putAll(mapCustomInfo(eventType.getCustomInfo()));
return event;
}
|
java
|
public static Event map(EventType eventType) {
Event event = new Event();
event.setEventType(mapEventTypeEnum(eventType.getEventType()));
Date date = (eventType.getTimestamp() == null)
? new Date() : eventType.getTimestamp().toGregorianCalendar().getTime();
event.setTimestamp(date);
event.setOriginator(mapOriginatorType(eventType.getOriginator()));
MessageInfo messageInfo = mapMessageInfo(eventType.getMessageInfo());
event.setMessageInfo(messageInfo);
String content = mapContent(eventType.getContent());
event.setContent(content);
event.getCustomInfo().clear();
event.getCustomInfo().putAll(mapCustomInfo(eventType.getCustomInfo()));
return event;
}
|
[
"public",
"static",
"Event",
"map",
"(",
"EventType",
"eventType",
")",
"{",
"Event",
"event",
"=",
"new",
"Event",
"(",
")",
";",
"event",
".",
"setEventType",
"(",
"mapEventTypeEnum",
"(",
"eventType",
".",
"getEventType",
"(",
")",
")",
")",
";",
"Date",
"date",
"=",
"(",
"eventType",
".",
"getTimestamp",
"(",
")",
"==",
"null",
")",
"?",
"new",
"Date",
"(",
")",
":",
"eventType",
".",
"getTimestamp",
"(",
")",
".",
"toGregorianCalendar",
"(",
")",
".",
"getTime",
"(",
")",
";",
"event",
".",
"setTimestamp",
"(",
"date",
")",
";",
"event",
".",
"setOriginator",
"(",
"mapOriginatorType",
"(",
"eventType",
".",
"getOriginator",
"(",
")",
")",
")",
";",
"MessageInfo",
"messageInfo",
"=",
"mapMessageInfo",
"(",
"eventType",
".",
"getMessageInfo",
"(",
")",
")",
";",
"event",
".",
"setMessageInfo",
"(",
"messageInfo",
")",
";",
"String",
"content",
"=",
"mapContent",
"(",
"eventType",
".",
"getContent",
"(",
")",
")",
";",
"event",
".",
"setContent",
"(",
"content",
")",
";",
"event",
".",
"getCustomInfo",
"(",
")",
".",
"clear",
"(",
")",
";",
"event",
".",
"getCustomInfo",
"(",
")",
".",
"putAll",
"(",
"mapCustomInfo",
"(",
"eventType",
".",
"getCustomInfo",
"(",
")",
")",
")",
";",
"return",
"event",
";",
"}"
] |
Map the EventType.
@param eventType the event type
@return the event
|
[
"Map",
"the",
"EventType",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-service-soap/src/main/java/org/talend/esb/sam/service/soap/EventTypeMapper.java#L58-L72
|
160,276 |
Talend/tesb-rt-se
|
sam/sam-service-soap/src/main/java/org/talend/esb/sam/service/soap/EventTypeMapper.java
|
EventTypeMapper.mapCustomInfo
|
private static Map<String, String> mapCustomInfo(CustomInfoType ciType){
Map<String, String> customInfo = new HashMap<String, String>();
if (ciType != null){
for (CustomInfoType.Item item : ciType.getItem()) {
customInfo.put(item.getKey(), item.getValue());
}
}
return customInfo;
}
|
java
|
private static Map<String, String> mapCustomInfo(CustomInfoType ciType){
Map<String, String> customInfo = new HashMap<String, String>();
if (ciType != null){
for (CustomInfoType.Item item : ciType.getItem()) {
customInfo.put(item.getKey(), item.getValue());
}
}
return customInfo;
}
|
[
"private",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"mapCustomInfo",
"(",
"CustomInfoType",
"ciType",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"customInfo",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"if",
"(",
"ciType",
"!=",
"null",
")",
"{",
"for",
"(",
"CustomInfoType",
".",
"Item",
"item",
":",
"ciType",
".",
"getItem",
"(",
")",
")",
"{",
"customInfo",
".",
"put",
"(",
"item",
".",
"getKey",
"(",
")",
",",
"item",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"return",
"customInfo",
";",
"}"
] |
Map custom info.
@param ciType the custom info type
@return the map
|
[
"Map",
"custom",
"info",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-service-soap/src/main/java/org/talend/esb/sam/service/soap/EventTypeMapper.java#L80-L88
|
160,277 |
Talend/tesb-rt-se
|
sam/sam-service-soap/src/main/java/org/talend/esb/sam/service/soap/EventTypeMapper.java
|
EventTypeMapper.mapContent
|
private static String mapContent(DataHandler dh) {
if (dh == null) {
return "";
}
try {
InputStream is = dh.getInputStream();
String content = IOUtils.toString(is);
is.close();
return content;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
java
|
private static String mapContent(DataHandler dh) {
if (dh == null) {
return "";
}
try {
InputStream is = dh.getInputStream();
String content = IOUtils.toString(is);
is.close();
return content;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
[
"private",
"static",
"String",
"mapContent",
"(",
"DataHandler",
"dh",
")",
"{",
"if",
"(",
"dh",
"==",
"null",
")",
"{",
"return",
"\"\"",
";",
"}",
"try",
"{",
"InputStream",
"is",
"=",
"dh",
".",
"getInputStream",
"(",
")",
";",
"String",
"content",
"=",
"IOUtils",
".",
"toString",
"(",
"is",
")",
";",
"is",
".",
"close",
"(",
")",
";",
"return",
"content",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
Map content.
@param dh the data handler
@return the string
|
[
"Map",
"content",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-service-soap/src/main/java/org/talend/esb/sam/service/soap/EventTypeMapper.java#L96-L108
|
160,278 |
Talend/tesb-rt-se
|
sam/sam-service-soap/src/main/java/org/talend/esb/sam/service/soap/EventTypeMapper.java
|
EventTypeMapper.mapMessageInfo
|
private static MessageInfo mapMessageInfo(MessageInfoType messageInfoType) {
MessageInfo messageInfo = new MessageInfo();
if (messageInfoType != null) {
messageInfo.setFlowId(messageInfoType.getFlowId());
messageInfo.setMessageId(messageInfoType.getMessageId());
messageInfo.setOperationName(messageInfoType.getOperationName());
messageInfo.setPortType(messageInfoType.getPorttype() == null
? "" : messageInfoType.getPorttype().toString());
messageInfo.setTransportType(messageInfoType.getTransport());
}
return messageInfo;
}
|
java
|
private static MessageInfo mapMessageInfo(MessageInfoType messageInfoType) {
MessageInfo messageInfo = new MessageInfo();
if (messageInfoType != null) {
messageInfo.setFlowId(messageInfoType.getFlowId());
messageInfo.setMessageId(messageInfoType.getMessageId());
messageInfo.setOperationName(messageInfoType.getOperationName());
messageInfo.setPortType(messageInfoType.getPorttype() == null
? "" : messageInfoType.getPorttype().toString());
messageInfo.setTransportType(messageInfoType.getTransport());
}
return messageInfo;
}
|
[
"private",
"static",
"MessageInfo",
"mapMessageInfo",
"(",
"MessageInfoType",
"messageInfoType",
")",
"{",
"MessageInfo",
"messageInfo",
"=",
"new",
"MessageInfo",
"(",
")",
";",
"if",
"(",
"messageInfoType",
"!=",
"null",
")",
"{",
"messageInfo",
".",
"setFlowId",
"(",
"messageInfoType",
".",
"getFlowId",
"(",
")",
")",
";",
"messageInfo",
".",
"setMessageId",
"(",
"messageInfoType",
".",
"getMessageId",
"(",
")",
")",
";",
"messageInfo",
".",
"setOperationName",
"(",
"messageInfoType",
".",
"getOperationName",
"(",
")",
")",
";",
"messageInfo",
".",
"setPortType",
"(",
"messageInfoType",
".",
"getPorttype",
"(",
")",
"==",
"null",
"?",
"\"\"",
":",
"messageInfoType",
".",
"getPorttype",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"messageInfo",
".",
"setTransportType",
"(",
"messageInfoType",
".",
"getTransport",
"(",
")",
")",
";",
"}",
"return",
"messageInfo",
";",
"}"
] |
Map message info.
@param messageInfoType the message info type
@return the message info
|
[
"Map",
"message",
"info",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-service-soap/src/main/java/org/talend/esb/sam/service/soap/EventTypeMapper.java#L116-L127
|
160,279 |
Talend/tesb-rt-se
|
sam/sam-service-soap/src/main/java/org/talend/esb/sam/service/soap/EventTypeMapper.java
|
EventTypeMapper.mapOriginatorType
|
private static Originator mapOriginatorType(OriginatorType originatorType) {
Originator originator = new Originator();
if (originatorType != null) {
originator.setCustomId(originatorType.getCustomId());
originator.setHostname(originatorType.getHostname());
originator.setIp(originatorType.getIp());
originator.setProcessId(originatorType.getProcessId());
originator.setPrincipal(originatorType.getPrincipal());
}
return originator;
}
|
java
|
private static Originator mapOriginatorType(OriginatorType originatorType) {
Originator originator = new Originator();
if (originatorType != null) {
originator.setCustomId(originatorType.getCustomId());
originator.setHostname(originatorType.getHostname());
originator.setIp(originatorType.getIp());
originator.setProcessId(originatorType.getProcessId());
originator.setPrincipal(originatorType.getPrincipal());
}
return originator;
}
|
[
"private",
"static",
"Originator",
"mapOriginatorType",
"(",
"OriginatorType",
"originatorType",
")",
"{",
"Originator",
"originator",
"=",
"new",
"Originator",
"(",
")",
";",
"if",
"(",
"originatorType",
"!=",
"null",
")",
"{",
"originator",
".",
"setCustomId",
"(",
"originatorType",
".",
"getCustomId",
"(",
")",
")",
";",
"originator",
".",
"setHostname",
"(",
"originatorType",
".",
"getHostname",
"(",
")",
")",
";",
"originator",
".",
"setIp",
"(",
"originatorType",
".",
"getIp",
"(",
")",
")",
";",
"originator",
".",
"setProcessId",
"(",
"originatorType",
".",
"getProcessId",
"(",
")",
")",
";",
"originator",
".",
"setPrincipal",
"(",
"originatorType",
".",
"getPrincipal",
"(",
")",
")",
";",
"}",
"return",
"originator",
";",
"}"
] |
Map originator type.
@param originatorType the originator type
@return the originator
|
[
"Map",
"originator",
"type",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-service-soap/src/main/java/org/talend/esb/sam/service/soap/EventTypeMapper.java#L135-L145
|
160,280 |
Talend/tesb-rt-se
|
sam/sam-service-soap/src/main/java/org/talend/esb/sam/service/soap/EventTypeMapper.java
|
EventTypeMapper.mapEventTypeEnum
|
private static EventTypeEnum mapEventTypeEnum(EventEnumType eventType) {
if (eventType != null) {
return EventTypeEnum.valueOf(eventType.name());
}
return EventTypeEnum.UNKNOWN;
}
|
java
|
private static EventTypeEnum mapEventTypeEnum(EventEnumType eventType) {
if (eventType != null) {
return EventTypeEnum.valueOf(eventType.name());
}
return EventTypeEnum.UNKNOWN;
}
|
[
"private",
"static",
"EventTypeEnum",
"mapEventTypeEnum",
"(",
"EventEnumType",
"eventType",
")",
"{",
"if",
"(",
"eventType",
"!=",
"null",
")",
"{",
"return",
"EventTypeEnum",
".",
"valueOf",
"(",
"eventType",
".",
"name",
"(",
")",
")",
";",
"}",
"return",
"EventTypeEnum",
".",
"UNKNOWN",
";",
"}"
] |
Map event type enum.
@param eventType the event type
@return the event type enum
|
[
"Map",
"event",
"type",
"enum",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-service-soap/src/main/java/org/talend/esb/sam/service/soap/EventTypeMapper.java#L153-L158
|
160,281 |
Talend/tesb-rt-se
|
examples/cxf/jaxrs-jaxws-transformations/client/src/main/java/client/SOAPClient.java
|
SOAPClient.useNewSOAPService
|
public void useNewSOAPService(boolean direct) throws Exception {
URL wsdlURL = getClass().getResource("/CustomerServiceNew.wsdl");
org.customer.service.CustomerServiceService service =
new org.customer.service.CustomerServiceService(wsdlURL);
org.customer.service.CustomerService customerService =
direct ? service.getCustomerServicePort() : service.getCustomerServiceNewPort();
System.out.println("Using new SOAP CustomerService with new client");
customer.v2.Customer customer = createNewCustomer("Barry New SOAP");
customerService.updateCustomer(customer);
customer = customerService.getCustomerByName("Barry New SOAP");
printNewCustomerDetails(customer);
}
|
java
|
public void useNewSOAPService(boolean direct) throws Exception {
URL wsdlURL = getClass().getResource("/CustomerServiceNew.wsdl");
org.customer.service.CustomerServiceService service =
new org.customer.service.CustomerServiceService(wsdlURL);
org.customer.service.CustomerService customerService =
direct ? service.getCustomerServicePort() : service.getCustomerServiceNewPort();
System.out.println("Using new SOAP CustomerService with new client");
customer.v2.Customer customer = createNewCustomer("Barry New SOAP");
customerService.updateCustomer(customer);
customer = customerService.getCustomerByName("Barry New SOAP");
printNewCustomerDetails(customer);
}
|
[
"public",
"void",
"useNewSOAPService",
"(",
"boolean",
"direct",
")",
"throws",
"Exception",
"{",
"URL",
"wsdlURL",
"=",
"getClass",
"(",
")",
".",
"getResource",
"(",
"\"/CustomerServiceNew.wsdl\"",
")",
";",
"org",
".",
"customer",
".",
"service",
".",
"CustomerServiceService",
"service",
"=",
"new",
"org",
".",
"customer",
".",
"service",
".",
"CustomerServiceService",
"(",
"wsdlURL",
")",
";",
"org",
".",
"customer",
".",
"service",
".",
"CustomerService",
"customerService",
"=",
"direct",
"?",
"service",
".",
"getCustomerServicePort",
"(",
")",
":",
"service",
".",
"getCustomerServiceNewPort",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Using new SOAP CustomerService with new client\"",
")",
";",
"customer",
".",
"v2",
".",
"Customer",
"customer",
"=",
"createNewCustomer",
"(",
"\"Barry New SOAP\"",
")",
";",
"customerService",
".",
"updateCustomer",
"(",
"customer",
")",
";",
"customer",
"=",
"customerService",
".",
"getCustomerByName",
"(",
"\"Barry New SOAP\"",
")",
";",
"printNewCustomerDetails",
"(",
"customer",
")",
";",
"}"
] |
New SOAP client uses new SOAP service.
|
[
"New",
"SOAP",
"client",
"uses",
"new",
"SOAP",
"service",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/cxf/jaxrs-jaxws-transformations/client/src/main/java/client/SOAPClient.java#L72-L86
|
160,282 |
Talend/tesb-rt-se
|
examples/cxf/jaxrs-jaxws-transformations/client/src/main/java/client/SOAPClient.java
|
SOAPClient.useNewSOAPServiceWithOldClient
|
public void useNewSOAPServiceWithOldClient() throws Exception {
URL wsdlURL = getClass().getResource("/CustomerServiceNew.wsdl");
com.example.customerservice.CustomerServiceService service =
new com.example.customerservice.CustomerServiceService(wsdlURL);
com.example.customerservice.CustomerService customerService =
service.getCustomerServicePort();
// The outgoing new Customer data needs to be transformed for
// the old service to understand it and the response from the old service
// needs to be transformed for this new client to understand it.
Client client = ClientProxy.getClient(customerService);
addTransformInterceptors(client.getInInterceptors(),
client.getOutInterceptors(),
false);
System.out.println("Using new SOAP CustomerService with old client");
customer.v1.Customer customer = createOldCustomer("Barry Old to New SOAP");
customerService.updateCustomer(customer);
customer = customerService.getCustomerByName("Barry Old to New SOAP");
printOldCustomerDetails(customer);
}
|
java
|
public void useNewSOAPServiceWithOldClient() throws Exception {
URL wsdlURL = getClass().getResource("/CustomerServiceNew.wsdl");
com.example.customerservice.CustomerServiceService service =
new com.example.customerservice.CustomerServiceService(wsdlURL);
com.example.customerservice.CustomerService customerService =
service.getCustomerServicePort();
// The outgoing new Customer data needs to be transformed for
// the old service to understand it and the response from the old service
// needs to be transformed for this new client to understand it.
Client client = ClientProxy.getClient(customerService);
addTransformInterceptors(client.getInInterceptors(),
client.getOutInterceptors(),
false);
System.out.println("Using new SOAP CustomerService with old client");
customer.v1.Customer customer = createOldCustomer("Barry Old to New SOAP");
customerService.updateCustomer(customer);
customer = customerService.getCustomerByName("Barry Old to New SOAP");
printOldCustomerDetails(customer);
}
|
[
"public",
"void",
"useNewSOAPServiceWithOldClient",
"(",
")",
"throws",
"Exception",
"{",
"URL",
"wsdlURL",
"=",
"getClass",
"(",
")",
".",
"getResource",
"(",
"\"/CustomerServiceNew.wsdl\"",
")",
";",
"com",
".",
"example",
".",
"customerservice",
".",
"CustomerServiceService",
"service",
"=",
"new",
"com",
".",
"example",
".",
"customerservice",
".",
"CustomerServiceService",
"(",
"wsdlURL",
")",
";",
"com",
".",
"example",
".",
"customerservice",
".",
"CustomerService",
"customerService",
"=",
"service",
".",
"getCustomerServicePort",
"(",
")",
";",
"// The outgoing new Customer data needs to be transformed for ",
"// the old service to understand it and the response from the old service",
"// needs to be transformed for this new client to understand it.",
"Client",
"client",
"=",
"ClientProxy",
".",
"getClient",
"(",
"customerService",
")",
";",
"addTransformInterceptors",
"(",
"client",
".",
"getInInterceptors",
"(",
")",
",",
"client",
".",
"getOutInterceptors",
"(",
")",
",",
"false",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Using new SOAP CustomerService with old client\"",
")",
";",
"customer",
".",
"v1",
".",
"Customer",
"customer",
"=",
"createOldCustomer",
"(",
"\"Barry Old to New SOAP\"",
")",
";",
"customerService",
".",
"updateCustomer",
"(",
"customer",
")",
";",
"customer",
"=",
"customerService",
".",
"getCustomerByName",
"(",
"\"Barry Old to New SOAP\"",
")",
";",
"printOldCustomerDetails",
"(",
"customer",
")",
";",
"}"
] |
Old SOAP client uses new SOAP service
|
[
"Old",
"SOAP",
"client",
"uses",
"new",
"SOAP",
"service"
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/cxf/jaxrs-jaxws-transformations/client/src/main/java/client/SOAPClient.java#L91-L114
|
160,283 |
Talend/tesb-rt-se
|
examples/cxf/jaxrs-jaxws-transformations/client/src/main/java/client/SOAPClient.java
|
SOAPClient.useNewSOAPServiceWithOldClientAndRedirection
|
public void useNewSOAPServiceWithOldClientAndRedirection() throws Exception {
URL wsdlURL = getClass().getResource("/CustomerService.wsdl");
com.example.customerservice.CustomerServiceService service =
new com.example.customerservice.CustomerServiceService(wsdlURL);
com.example.customerservice.CustomerService customerService =
service.getCustomerServiceRedirectPort();
System.out.println("Using new SOAP CustomerService with old client and the redirection");
customer.v1.Customer customer = createOldCustomer("Barry Old to New SOAP With Redirection");
customerService.updateCustomer(customer);
customer = customerService.getCustomerByName("Barry Old to New SOAP With Redirection");
printOldCustomerDetails(customer);
}
|
java
|
public void useNewSOAPServiceWithOldClientAndRedirection() throws Exception {
URL wsdlURL = getClass().getResource("/CustomerService.wsdl");
com.example.customerservice.CustomerServiceService service =
new com.example.customerservice.CustomerServiceService(wsdlURL);
com.example.customerservice.CustomerService customerService =
service.getCustomerServiceRedirectPort();
System.out.println("Using new SOAP CustomerService with old client and the redirection");
customer.v1.Customer customer = createOldCustomer("Barry Old to New SOAP With Redirection");
customerService.updateCustomer(customer);
customer = customerService.getCustomerByName("Barry Old to New SOAP With Redirection");
printOldCustomerDetails(customer);
}
|
[
"public",
"void",
"useNewSOAPServiceWithOldClientAndRedirection",
"(",
")",
"throws",
"Exception",
"{",
"URL",
"wsdlURL",
"=",
"getClass",
"(",
")",
".",
"getResource",
"(",
"\"/CustomerService.wsdl\"",
")",
";",
"com",
".",
"example",
".",
"customerservice",
".",
"CustomerServiceService",
"service",
"=",
"new",
"com",
".",
"example",
".",
"customerservice",
".",
"CustomerServiceService",
"(",
"wsdlURL",
")",
";",
"com",
".",
"example",
".",
"customerservice",
".",
"CustomerService",
"customerService",
"=",
"service",
".",
"getCustomerServiceRedirectPort",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Using new SOAP CustomerService with old client and the redirection\"",
")",
";",
"customer",
".",
"v1",
".",
"Customer",
"customer",
"=",
"createOldCustomer",
"(",
"\"Barry Old to New SOAP With Redirection\"",
")",
";",
"customerService",
".",
"updateCustomer",
"(",
"customer",
")",
";",
"customer",
"=",
"customerService",
".",
"getCustomerByName",
"(",
"\"Barry Old to New SOAP With Redirection\"",
")",
";",
"printOldCustomerDetails",
"(",
"customer",
")",
";",
"}"
] |
Old SOAP client uses new SOAP service with the
redirection to the new endpoint and transformation
on the server side
|
[
"Old",
"SOAP",
"client",
"uses",
"new",
"SOAP",
"service",
"with",
"the",
"redirection",
"to",
"the",
"new",
"endpoint",
"and",
"transformation",
"on",
"the",
"server",
"side"
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/cxf/jaxrs-jaxws-transformations/client/src/main/java/client/SOAPClient.java#L146-L160
|
160,284 |
Talend/tesb-rt-se
|
examples/cxf/jaxrs-jaxws-transformations/client/src/main/java/client/SOAPClient.java
|
SOAPClient.addTransformInterceptors
|
private void addTransformInterceptors(List<Interceptor<?>> inInterceptors,
List<Interceptor<?>> outInterceptors,
boolean newClient) {
// The old service expects the Customer data be qualified with
// the 'http://customer/v1' namespace.
// The new service expects the Customer data be qualified with
// the 'http://customer/v2' namespace.
// If it is an old client talking to the new service then:
// - the out transformation interceptor is configured for
// 'http://customer/v1' qualified data be transformed into
// 'http://customer/v2' qualified data.
// - the in transformation interceptor is configured for
// 'http://customer/v2' qualified response data be transformed into
// 'http://customer/v1' qualified data.
// If it is a new client talking to the old service then:
// - the out transformation interceptor is configured for
// 'http://customer/v2' qualified data be transformed into
// 'http://customer/v1' qualified data.
// - the in transformation interceptor is configured for
// 'http://customer/v1' qualified response data be transformed into
// 'http://customer/v2' qualified data.
// - new Customer type also introduces a briefDescription property
// which needs to be dropped for the old service validation to succeed
// this configuration can be provided externally
Map<String, String> newToOldTransformMap = new HashMap<String, String>();
newToOldTransformMap.put("{http://customer/v2}*", "{http://customer/v1}*");
Map<String, String> oldToNewTransformMap =
Collections.singletonMap("{http://customer/v1}*", "{http://customer/v2}*");
TransformOutInterceptor outTransform = new TransformOutInterceptor();
outTransform.setOutTransformElements(newClient ? newToOldTransformMap
: oldToNewTransformMap);
if (newClient) {
newToOldTransformMap.put("{http://customer/v2}briefDescription", "");
//outTransform.setOutDropElements(
// Collections.singletonList("{http://customer/v2}briefDescription"));
}
TransformInInterceptor inTransform = new TransformInInterceptor();
inTransform.setInTransformElements(newClient ? oldToNewTransformMap
: newToOldTransformMap);
inInterceptors.add(inTransform);
outInterceptors.add(outTransform);
}
|
java
|
private void addTransformInterceptors(List<Interceptor<?>> inInterceptors,
List<Interceptor<?>> outInterceptors,
boolean newClient) {
// The old service expects the Customer data be qualified with
// the 'http://customer/v1' namespace.
// The new service expects the Customer data be qualified with
// the 'http://customer/v2' namespace.
// If it is an old client talking to the new service then:
// - the out transformation interceptor is configured for
// 'http://customer/v1' qualified data be transformed into
// 'http://customer/v2' qualified data.
// - the in transformation interceptor is configured for
// 'http://customer/v2' qualified response data be transformed into
// 'http://customer/v1' qualified data.
// If it is a new client talking to the old service then:
// - the out transformation interceptor is configured for
// 'http://customer/v2' qualified data be transformed into
// 'http://customer/v1' qualified data.
// - the in transformation interceptor is configured for
// 'http://customer/v1' qualified response data be transformed into
// 'http://customer/v2' qualified data.
// - new Customer type also introduces a briefDescription property
// which needs to be dropped for the old service validation to succeed
// this configuration can be provided externally
Map<String, String> newToOldTransformMap = new HashMap<String, String>();
newToOldTransformMap.put("{http://customer/v2}*", "{http://customer/v1}*");
Map<String, String> oldToNewTransformMap =
Collections.singletonMap("{http://customer/v1}*", "{http://customer/v2}*");
TransformOutInterceptor outTransform = new TransformOutInterceptor();
outTransform.setOutTransformElements(newClient ? newToOldTransformMap
: oldToNewTransformMap);
if (newClient) {
newToOldTransformMap.put("{http://customer/v2}briefDescription", "");
//outTransform.setOutDropElements(
// Collections.singletonList("{http://customer/v2}briefDescription"));
}
TransformInInterceptor inTransform = new TransformInInterceptor();
inTransform.setInTransformElements(newClient ? oldToNewTransformMap
: newToOldTransformMap);
inInterceptors.add(inTransform);
outInterceptors.add(outTransform);
}
|
[
"private",
"void",
"addTransformInterceptors",
"(",
"List",
"<",
"Interceptor",
"<",
"?",
">",
">",
"inInterceptors",
",",
"List",
"<",
"Interceptor",
"<",
"?",
">",
">",
"outInterceptors",
",",
"boolean",
"newClient",
")",
"{",
"// The old service expects the Customer data be qualified with",
"// the 'http://customer/v1' namespace.",
"// The new service expects the Customer data be qualified with",
"// the 'http://customer/v2' namespace.",
"// If it is an old client talking to the new service then:",
"// - the out transformation interceptor is configured for ",
"// 'http://customer/v1' qualified data be transformed into",
"// 'http://customer/v2' qualified data.",
"// - the in transformation interceptor is configured for ",
"// 'http://customer/v2' qualified response data be transformed into",
"// 'http://customer/v1' qualified data.",
"// If it is a new client talking to the old service then:",
"// - the out transformation interceptor is configured for ",
"// 'http://customer/v2' qualified data be transformed into",
"// 'http://customer/v1' qualified data.",
"// - the in transformation interceptor is configured for ",
"// 'http://customer/v1' qualified response data be transformed into",
"// 'http://customer/v2' qualified data.",
"// - new Customer type also introduces a briefDescription property",
"// which needs to be dropped for the old service validation to succeed",
"// this configuration can be provided externally",
"Map",
"<",
"String",
",",
"String",
">",
"newToOldTransformMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"newToOldTransformMap",
".",
"put",
"(",
"\"{http://customer/v2}*\"",
",",
"\"{http://customer/v1}*\"",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"oldToNewTransformMap",
"=",
"Collections",
".",
"singletonMap",
"(",
"\"{http://customer/v1}*\"",
",",
"\"{http://customer/v2}*\"",
")",
";",
"TransformOutInterceptor",
"outTransform",
"=",
"new",
"TransformOutInterceptor",
"(",
")",
";",
"outTransform",
".",
"setOutTransformElements",
"(",
"newClient",
"?",
"newToOldTransformMap",
":",
"oldToNewTransformMap",
")",
";",
"if",
"(",
"newClient",
")",
"{",
"newToOldTransformMap",
".",
"put",
"(",
"\"{http://customer/v2}briefDescription\"",
",",
"\"\"",
")",
";",
"//outTransform.setOutDropElements(",
"// Collections.singletonList(\"{http://customer/v2}briefDescription\")); ",
"}",
"TransformInInterceptor",
"inTransform",
"=",
"new",
"TransformInInterceptor",
"(",
")",
";",
"inTransform",
".",
"setInTransformElements",
"(",
"newClient",
"?",
"oldToNewTransformMap",
":",
"newToOldTransformMap",
")",
";",
"inInterceptors",
".",
"add",
"(",
"inTransform",
")",
";",
"outInterceptors",
".",
"add",
"(",
"outTransform",
")",
";",
"}"
] |
Prepares transformation interceptors for a client.
@param clientConfig the client configuration
@param newClient indicates if it is a new/updated client
|
[
"Prepares",
"transformation",
"interceptors",
"for",
"a",
"client",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/cxf/jaxrs-jaxws-transformations/client/src/main/java/client/SOAPClient.java#L169-L223
|
160,285 |
Talend/tesb-rt-se
|
examples/cxf/jaxrs-advanced/common/src/main/java/common/advanced/Person.java
|
Person.getXmlID
|
@SuppressWarnings("unused")
@XmlID
@XmlAttribute(name = "id")
private String getXmlID(){
return String.format("%s-%s", this.getClass().getSimpleName(), Long.valueOf(id));
}
|
java
|
@SuppressWarnings("unused")
@XmlID
@XmlAttribute(name = "id")
private String getXmlID(){
return String.format("%s-%s", this.getClass().getSimpleName(), Long.valueOf(id));
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unused\"",
")",
"@",
"XmlID",
"@",
"XmlAttribute",
"(",
"name",
"=",
"\"id\"",
")",
"private",
"String",
"getXmlID",
"(",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"%s-%s\"",
",",
"this",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
",",
"Long",
".",
"valueOf",
"(",
"id",
")",
")",
";",
"}"
] |
to do with XmlId value being strictly of type 'String'
|
[
"to",
"do",
"with",
"XmlId",
"value",
"being",
"strictly",
"of",
"type",
"String"
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/cxf/jaxrs-advanced/common/src/main/java/common/advanced/Person.java#L212-L217
|
160,286 |
Talend/tesb-rt-se
|
locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/LocatorLifecycleStrategy.java
|
LocatorLifecycleStrategy.stopAllServersAndRemoveCamelContext
|
private void stopAllServersAndRemoveCamelContext(CamelContext camelContext) {
log.debug("Stopping all servers associated with {}", camelContext);
List<SingleBusLocatorRegistrar> registrars = locatorRegistrar.getAllRegistars(camelContext);
registrars.forEach(registrar -> registrar.stopAllServersAndRemoveCamelContext());
}
|
java
|
private void stopAllServersAndRemoveCamelContext(CamelContext camelContext) {
log.debug("Stopping all servers associated with {}", camelContext);
List<SingleBusLocatorRegistrar> registrars = locatorRegistrar.getAllRegistars(camelContext);
registrars.forEach(registrar -> registrar.stopAllServersAndRemoveCamelContext());
}
|
[
"private",
"void",
"stopAllServersAndRemoveCamelContext",
"(",
"CamelContext",
"camelContext",
")",
"{",
"log",
".",
"debug",
"(",
"\"Stopping all servers associated with {}\"",
",",
"camelContext",
")",
";",
"List",
"<",
"SingleBusLocatorRegistrar",
">",
"registrars",
"=",
"locatorRegistrar",
".",
"getAllRegistars",
"(",
"camelContext",
")",
";",
"registrars",
".",
"forEach",
"(",
"registrar",
"->",
"registrar",
".",
"stopAllServersAndRemoveCamelContext",
"(",
")",
")",
";",
"}"
] |
Stops all servers linked with the current camel context
@param camelContext
|
[
"Stops",
"all",
"servers",
"linked",
"with",
"the",
"current",
"camel",
"context"
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/LocatorLifecycleStrategy.java#L76-L80
|
160,287 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/serviceclient/EventMapper.java
|
EventMapper.map
|
public static EventType map(Event event) {
EventType eventType = new EventType();
eventType.setTimestamp(Converter.convertDate(event.getTimestamp()));
eventType.setEventType(convertEventType(event.getEventType()));
OriginatorType origType = mapOriginator(event.getOriginator());
eventType.setOriginator(origType);
MessageInfoType miType = mapMessageInfo(event.getMessageInfo());
eventType.setMessageInfo(miType);
eventType.setCustomInfo(convertCustomInfo(event.getCustomInfo()));
eventType.setContentCut(event.isContentCut());
if (event.getContent() != null) {
DataHandler datHandler = getDataHandlerForString(event);
eventType.setContent(datHandler);
}
return eventType;
}
|
java
|
public static EventType map(Event event) {
EventType eventType = new EventType();
eventType.setTimestamp(Converter.convertDate(event.getTimestamp()));
eventType.setEventType(convertEventType(event.getEventType()));
OriginatorType origType = mapOriginator(event.getOriginator());
eventType.setOriginator(origType);
MessageInfoType miType = mapMessageInfo(event.getMessageInfo());
eventType.setMessageInfo(miType);
eventType.setCustomInfo(convertCustomInfo(event.getCustomInfo()));
eventType.setContentCut(event.isContentCut());
if (event.getContent() != null) {
DataHandler datHandler = getDataHandlerForString(event);
eventType.setContent(datHandler);
}
return eventType;
}
|
[
"public",
"static",
"EventType",
"map",
"(",
"Event",
"event",
")",
"{",
"EventType",
"eventType",
"=",
"new",
"EventType",
"(",
")",
";",
"eventType",
".",
"setTimestamp",
"(",
"Converter",
".",
"convertDate",
"(",
"event",
".",
"getTimestamp",
"(",
")",
")",
")",
";",
"eventType",
".",
"setEventType",
"(",
"convertEventType",
"(",
"event",
".",
"getEventType",
"(",
")",
")",
")",
";",
"OriginatorType",
"origType",
"=",
"mapOriginator",
"(",
"event",
".",
"getOriginator",
"(",
")",
")",
";",
"eventType",
".",
"setOriginator",
"(",
"origType",
")",
";",
"MessageInfoType",
"miType",
"=",
"mapMessageInfo",
"(",
"event",
".",
"getMessageInfo",
"(",
")",
")",
";",
"eventType",
".",
"setMessageInfo",
"(",
"miType",
")",
";",
"eventType",
".",
"setCustomInfo",
"(",
"convertCustomInfo",
"(",
"event",
".",
"getCustomInfo",
"(",
")",
")",
")",
";",
"eventType",
".",
"setContentCut",
"(",
"event",
".",
"isContentCut",
"(",
")",
")",
";",
"if",
"(",
"event",
".",
"getContent",
"(",
")",
"!=",
"null",
")",
"{",
"DataHandler",
"datHandler",
"=",
"getDataHandlerForString",
"(",
"event",
")",
";",
"eventType",
".",
"setContent",
"(",
"datHandler",
")",
";",
"}",
"return",
"eventType",
";",
"}"
] |
convert Event bean to EventType manually.
@param event the event
@return the event type
|
[
"convert",
"Event",
"bean",
"to",
"EventType",
"manually",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/serviceclient/EventMapper.java#L57-L72
|
160,288 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/serviceclient/EventMapper.java
|
EventMapper.getDataHandlerForString
|
private static DataHandler getDataHandlerForString(Event event) {
try {
return new DataHandler(new ByteDataSource(event.getContent().getBytes("UTF-8")));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
|
java
|
private static DataHandler getDataHandlerForString(Event event) {
try {
return new DataHandler(new ByteDataSource(event.getContent().getBytes("UTF-8")));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
|
[
"private",
"static",
"DataHandler",
"getDataHandlerForString",
"(",
"Event",
"event",
")",
"{",
"try",
"{",
"return",
"new",
"DataHandler",
"(",
"new",
"ByteDataSource",
"(",
"event",
".",
"getContent",
"(",
")",
".",
"getBytes",
"(",
"\"UTF-8\"",
")",
")",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
Gets the data handler from event.
@param event the event
@return the data handler
|
[
"Gets",
"the",
"data",
"handler",
"from",
"event",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/serviceclient/EventMapper.java#L80-L86
|
160,289 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/serviceclient/EventMapper.java
|
EventMapper.mapMessageInfo
|
private static MessageInfoType mapMessageInfo(MessageInfo messageInfo) {
if (messageInfo == null) {
return null;
}
MessageInfoType miType = new MessageInfoType();
miType.setMessageId(messageInfo.getMessageId());
miType.setFlowId(messageInfo.getFlowId());
miType.setPorttype(convertString(messageInfo.getPortType()));
miType.setOperationName(messageInfo.getOperationName());
miType.setTransport(messageInfo.getTransportType());
return miType;
}
|
java
|
private static MessageInfoType mapMessageInfo(MessageInfo messageInfo) {
if (messageInfo == null) {
return null;
}
MessageInfoType miType = new MessageInfoType();
miType.setMessageId(messageInfo.getMessageId());
miType.setFlowId(messageInfo.getFlowId());
miType.setPorttype(convertString(messageInfo.getPortType()));
miType.setOperationName(messageInfo.getOperationName());
miType.setTransport(messageInfo.getTransportType());
return miType;
}
|
[
"private",
"static",
"MessageInfoType",
"mapMessageInfo",
"(",
"MessageInfo",
"messageInfo",
")",
"{",
"if",
"(",
"messageInfo",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"MessageInfoType",
"miType",
"=",
"new",
"MessageInfoType",
"(",
")",
";",
"miType",
".",
"setMessageId",
"(",
"messageInfo",
".",
"getMessageId",
"(",
")",
")",
";",
"miType",
".",
"setFlowId",
"(",
"messageInfo",
".",
"getFlowId",
"(",
")",
")",
";",
"miType",
".",
"setPorttype",
"(",
"convertString",
"(",
"messageInfo",
".",
"getPortType",
"(",
")",
")",
")",
";",
"miType",
".",
"setOperationName",
"(",
"messageInfo",
".",
"getOperationName",
"(",
")",
")",
";",
"miType",
".",
"setTransport",
"(",
"messageInfo",
".",
"getTransportType",
"(",
")",
")",
";",
"return",
"miType",
";",
"}"
] |
Mapping message info.
@param messageInfo the message info
@return the message info type
|
[
"Mapping",
"message",
"info",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/serviceclient/EventMapper.java#L94-L105
|
160,290 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/serviceclient/EventMapper.java
|
EventMapper.mapOriginator
|
private static OriginatorType mapOriginator(Originator originator) {
if (originator == null) {
return null;
}
OriginatorType origType = new OriginatorType();
origType.setProcessId(originator.getProcessId());
origType.setIp(originator.getIp());
origType.setHostname(originator.getHostname());
origType.setCustomId(originator.getCustomId());
origType.setPrincipal(originator.getPrincipal());
return origType;
}
|
java
|
private static OriginatorType mapOriginator(Originator originator) {
if (originator == null) {
return null;
}
OriginatorType origType = new OriginatorType();
origType.setProcessId(originator.getProcessId());
origType.setIp(originator.getIp());
origType.setHostname(originator.getHostname());
origType.setCustomId(originator.getCustomId());
origType.setPrincipal(originator.getPrincipal());
return origType;
}
|
[
"private",
"static",
"OriginatorType",
"mapOriginator",
"(",
"Originator",
"originator",
")",
"{",
"if",
"(",
"originator",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"OriginatorType",
"origType",
"=",
"new",
"OriginatorType",
"(",
")",
";",
"origType",
".",
"setProcessId",
"(",
"originator",
".",
"getProcessId",
"(",
")",
")",
";",
"origType",
".",
"setIp",
"(",
"originator",
".",
"getIp",
"(",
")",
")",
";",
"origType",
".",
"setHostname",
"(",
"originator",
".",
"getHostname",
"(",
")",
")",
";",
"origType",
".",
"setCustomId",
"(",
"originator",
".",
"getCustomId",
"(",
")",
")",
";",
"origType",
".",
"setPrincipal",
"(",
"originator",
".",
"getPrincipal",
"(",
")",
")",
";",
"return",
"origType",
";",
"}"
] |
Mapping originator.
@param originator the originator
@return the originator type
|
[
"Mapping",
"originator",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/serviceclient/EventMapper.java#L113-L124
|
160,291 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/serviceclient/EventMapper.java
|
EventMapper.convertCustomInfo
|
private static CustomInfoType convertCustomInfo(Map<String, String> customInfo) {
if (customInfo == null) {
return null;
}
CustomInfoType ciType = new CustomInfoType();
for (Entry<String, String> entry : customInfo.entrySet()) {
CustomInfoType.Item cItem = new CustomInfoType.Item();
cItem.setKey(entry.getKey());
cItem.setValue(entry.getValue());
ciType.getItem().add(cItem);
}
return ciType;
}
|
java
|
private static CustomInfoType convertCustomInfo(Map<String, String> customInfo) {
if (customInfo == null) {
return null;
}
CustomInfoType ciType = new CustomInfoType();
for (Entry<String, String> entry : customInfo.entrySet()) {
CustomInfoType.Item cItem = new CustomInfoType.Item();
cItem.setKey(entry.getKey());
cItem.setValue(entry.getValue());
ciType.getItem().add(cItem);
}
return ciType;
}
|
[
"private",
"static",
"CustomInfoType",
"convertCustomInfo",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"customInfo",
")",
"{",
"if",
"(",
"customInfo",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"CustomInfoType",
"ciType",
"=",
"new",
"CustomInfoType",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"customInfo",
".",
"entrySet",
"(",
")",
")",
"{",
"CustomInfoType",
".",
"Item",
"cItem",
"=",
"new",
"CustomInfoType",
".",
"Item",
"(",
")",
";",
"cItem",
".",
"setKey",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"cItem",
".",
"setValue",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"ciType",
".",
"getItem",
"(",
")",
".",
"add",
"(",
"cItem",
")",
";",
"}",
"return",
"ciType",
";",
"}"
] |
Convert custom info.
@param customInfo the custom info map
@return the custom info type
|
[
"Convert",
"custom",
"info",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/serviceclient/EventMapper.java#L132-L146
|
160,292 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/serviceclient/EventMapper.java
|
EventMapper.convertEventType
|
private static EventEnumType convertEventType(org.talend.esb.sam.common.event.EventTypeEnum eventType) {
if (eventType == null) {
return null;
}
return EventEnumType.valueOf(eventType.name());
}
|
java
|
private static EventEnumType convertEventType(org.talend.esb.sam.common.event.EventTypeEnum eventType) {
if (eventType == null) {
return null;
}
return EventEnumType.valueOf(eventType.name());
}
|
[
"private",
"static",
"EventEnumType",
"convertEventType",
"(",
"org",
".",
"talend",
".",
"esb",
".",
"sam",
".",
"common",
".",
"event",
".",
"EventTypeEnum",
"eventType",
")",
"{",
"if",
"(",
"eventType",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"EventEnumType",
".",
"valueOf",
"(",
"eventType",
".",
"name",
"(",
")",
")",
";",
"}"
] |
Convert event type.
@param eventType the event type
@return the event enum type
|
[
"Convert",
"event",
"type",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/serviceclient/EventMapper.java#L154-L159
|
160,293 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/serviceclient/EventMapper.java
|
EventMapper.convertString
|
private static QName convertString(String str) {
if (str != null) {
return QName.valueOf(str);
} else {
return null;
}
}
|
java
|
private static QName convertString(String str) {
if (str != null) {
return QName.valueOf(str);
} else {
return null;
}
}
|
[
"private",
"static",
"QName",
"convertString",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"str",
"!=",
"null",
")",
"{",
"return",
"QName",
".",
"valueOf",
"(",
"str",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Convert string to qname.
@param str the string
@return the qname
|
[
"Convert",
"string",
"to",
"qname",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/serviceclient/EventMapper.java#L167-L173
|
160,294 |
Talend/tesb-rt-se
|
sam/sam-common/src/main/java/org/talend/esb/sam/common/event/MonitoringException.java
|
MonitoringException.logException
|
public void logException(Level level) {
if (!LOG.isLoggable(level)) {
return;
}
final StringBuilder builder = new StringBuilder();
builder.append("\n----------------------------------------------------");
builder.append("\nMonitoringException");
builder.append("\n----------------------------------------------------");
builder.append("\nCode: ").append(code);
builder.append("\nMessage: ").append(message);
builder.append("\n----------------------------------------------------");
if (events != null) {
for (Event event : events) {
builder.append("\nEvent:");
if (event.getMessageInfo() != null) {
builder.append("\nMessage id: ").append(event.getMessageInfo().getMessageId());
builder.append("\nFlow id: ").append(event.getMessageInfo().getFlowId());
builder.append("\n----------------------------------------------------");
} else {
builder.append("\nNo message id and no flow id");
}
}
}
builder.append("\n----------------------------------------------------\n");
LOG.log(level, builder.toString(), this);
}
|
java
|
public void logException(Level level) {
if (!LOG.isLoggable(level)) {
return;
}
final StringBuilder builder = new StringBuilder();
builder.append("\n----------------------------------------------------");
builder.append("\nMonitoringException");
builder.append("\n----------------------------------------------------");
builder.append("\nCode: ").append(code);
builder.append("\nMessage: ").append(message);
builder.append("\n----------------------------------------------------");
if (events != null) {
for (Event event : events) {
builder.append("\nEvent:");
if (event.getMessageInfo() != null) {
builder.append("\nMessage id: ").append(event.getMessageInfo().getMessageId());
builder.append("\nFlow id: ").append(event.getMessageInfo().getFlowId());
builder.append("\n----------------------------------------------------");
} else {
builder.append("\nNo message id and no flow id");
}
}
}
builder.append("\n----------------------------------------------------\n");
LOG.log(level, builder.toString(), this);
}
|
[
"public",
"void",
"logException",
"(",
"Level",
"level",
")",
"{",
"if",
"(",
"!",
"LOG",
".",
"isLoggable",
"(",
"level",
")",
")",
"{",
"return",
";",
"}",
"final",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"builder",
".",
"append",
"(",
"\"\\n----------------------------------------------------\"",
")",
";",
"builder",
".",
"append",
"(",
"\"\\nMonitoringException\"",
")",
";",
"builder",
".",
"append",
"(",
"\"\\n----------------------------------------------------\"",
")",
";",
"builder",
".",
"append",
"(",
"\"\\nCode: \"",
")",
".",
"append",
"(",
"code",
")",
";",
"builder",
".",
"append",
"(",
"\"\\nMessage: \"",
")",
".",
"append",
"(",
"message",
")",
";",
"builder",
".",
"append",
"(",
"\"\\n----------------------------------------------------\"",
")",
";",
"if",
"(",
"events",
"!=",
"null",
")",
"{",
"for",
"(",
"Event",
"event",
":",
"events",
")",
"{",
"builder",
".",
"append",
"(",
"\"\\nEvent:\"",
")",
";",
"if",
"(",
"event",
".",
"getMessageInfo",
"(",
")",
"!=",
"null",
")",
"{",
"builder",
".",
"append",
"(",
"\"\\nMessage id: \"",
")",
".",
"append",
"(",
"event",
".",
"getMessageInfo",
"(",
")",
".",
"getMessageId",
"(",
")",
")",
";",
"builder",
".",
"append",
"(",
"\"\\nFlow id: \"",
")",
".",
"append",
"(",
"event",
".",
"getMessageInfo",
"(",
")",
".",
"getFlowId",
"(",
")",
")",
";",
"builder",
".",
"append",
"(",
"\"\\n----------------------------------------------------\"",
")",
";",
"}",
"else",
"{",
"builder",
".",
"append",
"(",
"\"\\nNo message id and no flow id\"",
")",
";",
"}",
"}",
"}",
"builder",
".",
"append",
"(",
"\"\\n----------------------------------------------------\\n\"",
")",
";",
"LOG",
".",
"log",
"(",
"level",
",",
"builder",
".",
"toString",
"(",
")",
",",
"this",
")",
";",
"}"
] |
Prints the error message as log message.
@param level the log level
|
[
"Prints",
"the",
"error",
"message",
"as",
"log",
"message",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-common/src/main/java/org/talend/esb/sam/common/event/MonitoringException.java#L103-L128
|
160,295 |
Talend/tesb-rt-se
|
locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/LocatorClientEnabler.java
|
LocatorClientEnabler.getLocatorSelectionStrategy
|
private LocatorSelectionStrategy getLocatorSelectionStrategy(String locatorSelectionStrategy) {
if (null == locatorSelectionStrategy) {
return locatorSelectionStrategyMap.get(DEFAULT_STRATEGY).getInstance();
}
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "Strategy " + locatorSelectionStrategy
+ " was set for LocatorClientRegistrar.");
}
if (locatorSelectionStrategyMap.containsKey(locatorSelectionStrategy)) {
return locatorSelectionStrategyMap.get(locatorSelectionStrategy).getInstance();
} else {
if (LOG.isLoggable(Level.WARNING)) {
LOG.log(Level.WARNING, "LocatorSelectionStrategy " + locatorSelectionStrategy
+ " not registered at LocatorClientEnabler.");
}
return locatorSelectionStrategyMap.get(DEFAULT_STRATEGY).getInstance();
}
}
|
java
|
private LocatorSelectionStrategy getLocatorSelectionStrategy(String locatorSelectionStrategy) {
if (null == locatorSelectionStrategy) {
return locatorSelectionStrategyMap.get(DEFAULT_STRATEGY).getInstance();
}
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "Strategy " + locatorSelectionStrategy
+ " was set for LocatorClientRegistrar.");
}
if (locatorSelectionStrategyMap.containsKey(locatorSelectionStrategy)) {
return locatorSelectionStrategyMap.get(locatorSelectionStrategy).getInstance();
} else {
if (LOG.isLoggable(Level.WARNING)) {
LOG.log(Level.WARNING, "LocatorSelectionStrategy " + locatorSelectionStrategy
+ " not registered at LocatorClientEnabler.");
}
return locatorSelectionStrategyMap.get(DEFAULT_STRATEGY).getInstance();
}
}
|
[
"private",
"LocatorSelectionStrategy",
"getLocatorSelectionStrategy",
"(",
"String",
"locatorSelectionStrategy",
")",
"{",
"if",
"(",
"null",
"==",
"locatorSelectionStrategy",
")",
"{",
"return",
"locatorSelectionStrategyMap",
".",
"get",
"(",
"DEFAULT_STRATEGY",
")",
".",
"getInstance",
"(",
")",
";",
"}",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"Strategy \"",
"+",
"locatorSelectionStrategy",
"+",
"\" was set for LocatorClientRegistrar.\"",
")",
";",
"}",
"if",
"(",
"locatorSelectionStrategyMap",
".",
"containsKey",
"(",
"locatorSelectionStrategy",
")",
")",
"{",
"return",
"locatorSelectionStrategyMap",
".",
"get",
"(",
"locatorSelectionStrategy",
")",
".",
"getInstance",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"WARNING",
")",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"\"LocatorSelectionStrategy \"",
"+",
"locatorSelectionStrategy",
"+",
"\" not registered at LocatorClientEnabler.\"",
")",
";",
"}",
"return",
"locatorSelectionStrategyMap",
".",
"get",
"(",
"DEFAULT_STRATEGY",
")",
".",
"getInstance",
"(",
")",
";",
"}",
"}"
] |
If the String argument locatorSelectionStrategy is as key in the map representing the locatorSelectionStrategies, the
corresponding strategy is selected, else it remains unchanged.
@param locatorSelectionStrategy
|
[
"If",
"the",
"String",
"argument",
"locatorSelectionStrategy",
"is",
"as",
"key",
"in",
"the",
"map",
"representing",
"the",
"locatorSelectionStrategies",
"the",
"corresponding",
"strategy",
"is",
"selected",
"else",
"it",
"remains",
"unchanged",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/LocatorClientEnabler.java#L71-L90
|
160,296 |
Talend/tesb-rt-se
|
locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/LocatorClientEnabler.java
|
LocatorClientEnabler.setDefaultLocatorSelectionStrategy
|
@Value("${locator.strategy}")
public void setDefaultLocatorSelectionStrategy(String defaultLocatorSelectionStrategy) {
this.defaultLocatorSelectionStrategy = defaultLocatorSelectionStrategy;
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "Default strategy " + defaultLocatorSelectionStrategy
+ " was set for LocatorClientRegistrar.");
}
}
|
java
|
@Value("${locator.strategy}")
public void setDefaultLocatorSelectionStrategy(String defaultLocatorSelectionStrategy) {
this.defaultLocatorSelectionStrategy = defaultLocatorSelectionStrategy;
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "Default strategy " + defaultLocatorSelectionStrategy
+ " was set for LocatorClientRegistrar.");
}
}
|
[
"@",
"Value",
"(",
"\"${locator.strategy}\"",
")",
"public",
"void",
"setDefaultLocatorSelectionStrategy",
"(",
"String",
"defaultLocatorSelectionStrategy",
")",
"{",
"this",
".",
"defaultLocatorSelectionStrategy",
"=",
"defaultLocatorSelectionStrategy",
";",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"Default strategy \"",
"+",
"defaultLocatorSelectionStrategy",
"+",
"\" was set for LocatorClientRegistrar.\"",
")",
";",
"}",
"}"
] |
If the String argument defaultLocatorSelectionStrategy is as key in the map representing the locatorSelectionStrategies, the
corresponding strategy is selected and set as default strategy, else both the selected strategy and the default strategy remain
unchanged.
@param defaultLocatorSelectionStrategy
|
[
"If",
"the",
"String",
"argument",
"defaultLocatorSelectionStrategy",
"is",
"as",
"key",
"in",
"the",
"map",
"representing",
"the",
"locatorSelectionStrategies",
"the",
"corresponding",
"strategy",
"is",
"selected",
"and",
"set",
"as",
"default",
"strategy",
"else",
"both",
"the",
"selected",
"strategy",
"and",
"the",
"default",
"strategy",
"remain",
"unchanged",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/LocatorClientEnabler.java#L98-L105
|
160,297 |
Talend/tesb-rt-se
|
locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/LocatorClientEnabler.java
|
LocatorClientEnabler.enable
|
public void enable(ConduitSelectorHolder conduitSelectorHolder, SLPropertiesMatcher matcher,
String selectionStrategy) {
LocatorTargetSelector selector = new LocatorTargetSelector();
selector.setEndpoint(conduitSelectorHolder.getConduitSelector().getEndpoint());
String actualStrategy = selectionStrategy != null ? selectionStrategy : defaultLocatorSelectionStrategy;
LocatorSelectionStrategy locatorSelectionStrategy = getLocatorSelectionStrategy(actualStrategy);
locatorSelectionStrategy.setServiceLocator(locatorClient);
if (matcher != null) {
locatorSelectionStrategy.setMatcher(matcher);
}
selector.setLocatorSelectionStrategy(locatorSelectionStrategy);
if (LOG.isLoggable(Level.INFO)) {
LOG.log(Level.INFO, "Client enabled with strategy "
+ locatorSelectionStrategy.getClass().getName() + ".");
}
conduitSelectorHolder.setConduitSelector(selector);
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "Successfully enabled client " + conduitSelectorHolder
+ " for the service locator");
}
}
|
java
|
public void enable(ConduitSelectorHolder conduitSelectorHolder, SLPropertiesMatcher matcher,
String selectionStrategy) {
LocatorTargetSelector selector = new LocatorTargetSelector();
selector.setEndpoint(conduitSelectorHolder.getConduitSelector().getEndpoint());
String actualStrategy = selectionStrategy != null ? selectionStrategy : defaultLocatorSelectionStrategy;
LocatorSelectionStrategy locatorSelectionStrategy = getLocatorSelectionStrategy(actualStrategy);
locatorSelectionStrategy.setServiceLocator(locatorClient);
if (matcher != null) {
locatorSelectionStrategy.setMatcher(matcher);
}
selector.setLocatorSelectionStrategy(locatorSelectionStrategy);
if (LOG.isLoggable(Level.INFO)) {
LOG.log(Level.INFO, "Client enabled with strategy "
+ locatorSelectionStrategy.getClass().getName() + ".");
}
conduitSelectorHolder.setConduitSelector(selector);
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "Successfully enabled client " + conduitSelectorHolder
+ " for the service locator");
}
}
|
[
"public",
"void",
"enable",
"(",
"ConduitSelectorHolder",
"conduitSelectorHolder",
",",
"SLPropertiesMatcher",
"matcher",
",",
"String",
"selectionStrategy",
")",
"{",
"LocatorTargetSelector",
"selector",
"=",
"new",
"LocatorTargetSelector",
"(",
")",
";",
"selector",
".",
"setEndpoint",
"(",
"conduitSelectorHolder",
".",
"getConduitSelector",
"(",
")",
".",
"getEndpoint",
"(",
")",
")",
";",
"String",
"actualStrategy",
"=",
"selectionStrategy",
"!=",
"null",
"?",
"selectionStrategy",
":",
"defaultLocatorSelectionStrategy",
";",
"LocatorSelectionStrategy",
"locatorSelectionStrategy",
"=",
"getLocatorSelectionStrategy",
"(",
"actualStrategy",
")",
";",
"locatorSelectionStrategy",
".",
"setServiceLocator",
"(",
"locatorClient",
")",
";",
"if",
"(",
"matcher",
"!=",
"null",
")",
"{",
"locatorSelectionStrategy",
".",
"setMatcher",
"(",
"matcher",
")",
";",
"}",
"selector",
".",
"setLocatorSelectionStrategy",
"(",
"locatorSelectionStrategy",
")",
";",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"INFO",
")",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"INFO",
",",
"\"Client enabled with strategy \"",
"+",
"locatorSelectionStrategy",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\".\"",
")",
";",
"}",
"conduitSelectorHolder",
".",
"setConduitSelector",
"(",
"selector",
")",
";",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"Successfully enabled client \"",
"+",
"conduitSelectorHolder",
"+",
"\" for the service locator\"",
")",
";",
"}",
"}"
] |
The selectionStrategy given as String argument is selected as locatorSelectionStrategy.
If selectionStrategy is null, the defaultLocatorSelectionStrategy is used instead.
Then the new locatorSelectionStrategy is connected to the locatorClient and the matcher.
A new LocatorTargetSelector is created, set to the locatorSelectionStrategy and then set
as selector in the conduitSelectorHolder.
@param conduitSelectorHolder
@param matcher
@param selectionStrategy
|
[
"The",
"selectionStrategy",
"given",
"as",
"String",
"argument",
"is",
"selected",
"as",
"locatorSelectionStrategy",
".",
"If",
"selectionStrategy",
"is",
"null",
"the",
"defaultLocatorSelectionStrategy",
"is",
"used",
"instead",
".",
"Then",
"the",
"new",
"locatorSelectionStrategy",
"is",
"connected",
"to",
"the",
"locatorClient",
"and",
"the",
"matcher",
".",
"A",
"new",
"LocatorTargetSelector",
"is",
"created",
"set",
"to",
"the",
"locatorSelectionStrategy",
"and",
"then",
"set",
"as",
"selector",
"in",
"the",
"conduitSelectorHolder",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/LocatorClientEnabler.java#L126-L150
|
160,298 |
Talend/tesb-rt-se
|
request-callback/src/main/java/org/talend/esb/mep/requestcallback/feature/RequestCallbackFeature.java
|
RequestCallbackFeature.applyWsdlExtensions
|
public static void applyWsdlExtensions(Bus bus) {
ExtensionRegistry registry = bus.getExtension(WSDLManager.class).getExtensionRegistry();
try {
JAXBExtensionHelper.addExtensions(registry,
javax.wsdl.Definition.class,
org.talend.esb.mep.requestcallback.impl.wsdl.PLType.class);
JAXBExtensionHelper.addExtensions(registry,
javax.wsdl.Binding.class,
org.talend.esb.mep.requestcallback.impl.wsdl.CallbackExtension.class);
} catch (JAXBException e) {
throw new RuntimeException("Failed to add WSDL JAXB extensions", e);
}
}
|
java
|
public static void applyWsdlExtensions(Bus bus) {
ExtensionRegistry registry = bus.getExtension(WSDLManager.class).getExtensionRegistry();
try {
JAXBExtensionHelper.addExtensions(registry,
javax.wsdl.Definition.class,
org.talend.esb.mep.requestcallback.impl.wsdl.PLType.class);
JAXBExtensionHelper.addExtensions(registry,
javax.wsdl.Binding.class,
org.talend.esb.mep.requestcallback.impl.wsdl.CallbackExtension.class);
} catch (JAXBException e) {
throw new RuntimeException("Failed to add WSDL JAXB extensions", e);
}
}
|
[
"public",
"static",
"void",
"applyWsdlExtensions",
"(",
"Bus",
"bus",
")",
"{",
"ExtensionRegistry",
"registry",
"=",
"bus",
".",
"getExtension",
"(",
"WSDLManager",
".",
"class",
")",
".",
"getExtensionRegistry",
"(",
")",
";",
"try",
"{",
"JAXBExtensionHelper",
".",
"addExtensions",
"(",
"registry",
",",
"javax",
".",
"wsdl",
".",
"Definition",
".",
"class",
",",
"org",
".",
"talend",
".",
"esb",
".",
"mep",
".",
"requestcallback",
".",
"impl",
".",
"wsdl",
".",
"PLType",
".",
"class",
")",
";",
"JAXBExtensionHelper",
".",
"addExtensions",
"(",
"registry",
",",
"javax",
".",
"wsdl",
".",
"Binding",
".",
"class",
",",
"org",
".",
"talend",
".",
"esb",
".",
"mep",
".",
"requestcallback",
".",
"impl",
".",
"wsdl",
".",
"CallbackExtension",
".",
"class",
")",
";",
"}",
"catch",
"(",
"JAXBException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to add WSDL JAXB extensions\"",
",",
"e",
")",
";",
"}",
"}"
] |
Adds JAXB WSDL extensions to allow work with custom
WSDL elements such as \"partner-link\"
@param bus CXF bus
|
[
"Adds",
"JAXB",
"WSDL",
"extensions",
"to",
"allow",
"work",
"with",
"custom",
"WSDL",
"elements",
"such",
"as",
"\\",
"partner",
"-",
"link",
"\\"
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/request-callback/src/main/java/org/talend/esb/mep/requestcallback/feature/RequestCallbackFeature.java#L84-L101
|
160,299 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/feature/EventFeatureImpl.java
|
EventFeatureImpl.setQueue
|
@Inject
public void setQueue(EventQueue queue) {
if (epi == null) {
MessageToEventMapper mapper = new MessageToEventMapper();
mapper.setMaxContentLength(maxContentLength);
epi = new EventProducerInterceptor(mapper, queue);
}
}
|
java
|
@Inject
public void setQueue(EventQueue queue) {
if (epi == null) {
MessageToEventMapper mapper = new MessageToEventMapper();
mapper.setMaxContentLength(maxContentLength);
epi = new EventProducerInterceptor(mapper, queue);
}
}
|
[
"@",
"Inject",
"public",
"void",
"setQueue",
"(",
"EventQueue",
"queue",
")",
"{",
"if",
"(",
"epi",
"==",
"null",
")",
"{",
"MessageToEventMapper",
"mapper",
"=",
"new",
"MessageToEventMapper",
"(",
")",
";",
"mapper",
".",
"setMaxContentLength",
"(",
"maxContentLength",
")",
";",
"epi",
"=",
"new",
"EventProducerInterceptor",
"(",
"mapper",
",",
"queue",
")",
";",
"}",
"}"
] |
Sets the queue.
@param queue the new queue
|
[
"Sets",
"the",
"queue",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/feature/EventFeatureImpl.java#L164-L172
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.