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
sequence | docstring
stringlengths 3
16k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 105
339
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/logging/LoggerFactoryImpl.java | LoggerFactoryImpl.getLogger | public Logger getLogger(String loggerName)
{
Logger logger;
//lookup in the cache first
logger = (Logger) cache.get(loggerName);
if(logger == null)
{
try
{
// get the configuration (not from the configurator because this is independent)
logger = createLoggerInstance(loggerName);
if(getBootLogger().isDebugEnabled())
{
getBootLogger().debug("Using logger class '"
+ (getConfiguration() != null ? getConfiguration().getLoggerClass() : null)
+ "' for " + loggerName);
}
// configure the logger
getBootLogger().debug("Initializing logger instance " + loggerName);
logger.configure(conf);
}
catch(Throwable t)
{
// do reassign check and signal logger creation failure
reassignBootLogger(true);
logger = getBootLogger();
getBootLogger().error("[" + this.getClass().getName()
+ "] Could not initialize logger " + (conf != null ? conf.getLoggerClass() : null), t);
}
//cache it so we can get it faster the next time
cache.put(loggerName, logger);
// do reassign check
reassignBootLogger(false);
}
return logger;
} | java | public Logger getLogger(String loggerName)
{
Logger logger;
//lookup in the cache first
logger = (Logger) cache.get(loggerName);
if(logger == null)
{
try
{
// get the configuration (not from the configurator because this is independent)
logger = createLoggerInstance(loggerName);
if(getBootLogger().isDebugEnabled())
{
getBootLogger().debug("Using logger class '"
+ (getConfiguration() != null ? getConfiguration().getLoggerClass() : null)
+ "' for " + loggerName);
}
// configure the logger
getBootLogger().debug("Initializing logger instance " + loggerName);
logger.configure(conf);
}
catch(Throwable t)
{
// do reassign check and signal logger creation failure
reassignBootLogger(true);
logger = getBootLogger();
getBootLogger().error("[" + this.getClass().getName()
+ "] Could not initialize logger " + (conf != null ? conf.getLoggerClass() : null), t);
}
//cache it so we can get it faster the next time
cache.put(loggerName, logger);
// do reassign check
reassignBootLogger(false);
}
return logger;
} | [
"public",
"Logger",
"getLogger",
"(",
"String",
"loggerName",
")",
"{",
"Logger",
"logger",
";",
"//lookup in the cache first\r",
"logger",
"=",
"(",
"Logger",
")",
"cache",
".",
"get",
"(",
"loggerName",
")",
";",
"if",
"(",
"logger",
"==",
"null",
")",
"{",
"try",
"{",
"// get the configuration (not from the configurator because this is independent)\r",
"logger",
"=",
"createLoggerInstance",
"(",
"loggerName",
")",
";",
"if",
"(",
"getBootLogger",
"(",
")",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"getBootLogger",
"(",
")",
".",
"debug",
"(",
"\"Using logger class '\"",
"+",
"(",
"getConfiguration",
"(",
")",
"!=",
"null",
"?",
"getConfiguration",
"(",
")",
".",
"getLoggerClass",
"(",
")",
":",
"null",
")",
"+",
"\"' for \"",
"+",
"loggerName",
")",
";",
"}",
"// configure the logger\r",
"getBootLogger",
"(",
")",
".",
"debug",
"(",
"\"Initializing logger instance \"",
"+",
"loggerName",
")",
";",
"logger",
".",
"configure",
"(",
"conf",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"// do reassign check and signal logger creation failure\r",
"reassignBootLogger",
"(",
"true",
")",
";",
"logger",
"=",
"getBootLogger",
"(",
")",
";",
"getBootLogger",
"(",
")",
".",
"error",
"(",
"\"[\"",
"+",
"this",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"] Could not initialize logger \"",
"+",
"(",
"conf",
"!=",
"null",
"?",
"conf",
".",
"getLoggerClass",
"(",
")",
":",
"null",
")",
",",
"t",
")",
";",
"}",
"//cache it so we can get it faster the next time\r",
"cache",
".",
"put",
"(",
"loggerName",
",",
"logger",
")",
";",
"// do reassign check\r",
"reassignBootLogger",
"(",
"false",
")",
";",
"}",
"return",
"logger",
";",
"}"
] | returns a Logger.
@param loggerName the name of the Logger
@return Logger the returned Logger | [
"returns",
"a",
"Logger",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/logging/LoggerFactoryImpl.java#L128-L164 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/logging/LoggerFactoryImpl.java | LoggerFactoryImpl.createLoggerInstance | private Logger createLoggerInstance(String loggerName) throws Exception
{
Class loggerClass = getConfiguration().getLoggerClass();
Logger log = (Logger) ClassHelper.newInstance(loggerClass, String.class, loggerName);
log.configure(getConfiguration());
return log;
} | java | private Logger createLoggerInstance(String loggerName) throws Exception
{
Class loggerClass = getConfiguration().getLoggerClass();
Logger log = (Logger) ClassHelper.newInstance(loggerClass, String.class, loggerName);
log.configure(getConfiguration());
return log;
} | [
"private",
"Logger",
"createLoggerInstance",
"(",
"String",
"loggerName",
")",
"throws",
"Exception",
"{",
"Class",
"loggerClass",
"=",
"getConfiguration",
"(",
")",
".",
"getLoggerClass",
"(",
")",
";",
"Logger",
"log",
"=",
"(",
"Logger",
")",
"ClassHelper",
".",
"newInstance",
"(",
"loggerClass",
",",
"String",
".",
"class",
",",
"loggerName",
")",
";",
"log",
".",
"configure",
"(",
"getConfiguration",
"(",
")",
")",
";",
"return",
"log",
";",
"}"
] | Creates a new Logger instance for the specified name. | [
"Creates",
"a",
"new",
"Logger",
"instance",
"for",
"the",
"specified",
"name",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/logging/LoggerFactoryImpl.java#L169-L175 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldBase.java | PersistentFieldBase.getFieldRecursive | private Field getFieldRecursive(Class c, String name) throws NoSuchFieldException
{
try
{
return c.getDeclaredField(name);
}
catch (NoSuchFieldException e)
{
// if field could not be found in the inheritance hierarchy, signal error
if ((c == Object.class) || (c.getSuperclass() == null) || c.isInterface())
{
throw e;
}
// if field could not be found in class c try in superclass
else
{
return getFieldRecursive(c.getSuperclass(), name);
}
}
} | java | private Field getFieldRecursive(Class c, String name) throws NoSuchFieldException
{
try
{
return c.getDeclaredField(name);
}
catch (NoSuchFieldException e)
{
// if field could not be found in the inheritance hierarchy, signal error
if ((c == Object.class) || (c.getSuperclass() == null) || c.isInterface())
{
throw e;
}
// if field could not be found in class c try in superclass
else
{
return getFieldRecursive(c.getSuperclass(), name);
}
}
} | [
"private",
"Field",
"getFieldRecursive",
"(",
"Class",
"c",
",",
"String",
"name",
")",
"throws",
"NoSuchFieldException",
"{",
"try",
"{",
"return",
"c",
".",
"getDeclaredField",
"(",
"name",
")",
";",
"}",
"catch",
"(",
"NoSuchFieldException",
"e",
")",
"{",
"// if field could not be found in the inheritance hierarchy, signal error\r",
"if",
"(",
"(",
"c",
"==",
"Object",
".",
"class",
")",
"||",
"(",
"c",
".",
"getSuperclass",
"(",
")",
"==",
"null",
")",
"||",
"c",
".",
"isInterface",
"(",
")",
")",
"{",
"throw",
"e",
";",
"}",
"// if field could not be found in class c try in superclass\r",
"else",
"{",
"return",
"getFieldRecursive",
"(",
"c",
".",
"getSuperclass",
"(",
")",
",",
"name",
")",
";",
"}",
"}",
"}"
] | try to find a field in class c, recurse through class hierarchy if necessary
@throws NoSuchFieldException if no Field was found into the class hierarchy | [
"try",
"to",
"find",
"a",
"field",
"in",
"class",
"c",
"recurse",
"through",
"class",
"hierarchy",
"if",
"necessary"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldBase.java#L113-L132 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldBase.java | PersistentFieldBase.buildErrorSetMsg | protected String buildErrorSetMsg(Object obj, Object value, Field aField)
{
String eol = SystemUtils.LINE_SEPARATOR;
StringBuffer buf = new StringBuffer();
buf
.append(eol + "[try to set 'object value' in 'target object'")
.append(eol + "target obj class: " + (obj != null ? obj.getClass().getName() : null))
.append(eol + "target field name: " + (aField != null ? aField.getName() : null))
.append(eol + "target field type: " + (aField != null ? aField.getType() : null))
.append(eol + "target field declared in: " + (aField != null ? aField.getDeclaringClass().getName() : null))
.append(eol + "object value class: " + (value != null ? value.getClass().getName() : null))
.append(eol + "object value: " + (value != null ? value : null))
.append(eol + "]");
return buf.toString();
} | java | protected String buildErrorSetMsg(Object obj, Object value, Field aField)
{
String eol = SystemUtils.LINE_SEPARATOR;
StringBuffer buf = new StringBuffer();
buf
.append(eol + "[try to set 'object value' in 'target object'")
.append(eol + "target obj class: " + (obj != null ? obj.getClass().getName() : null))
.append(eol + "target field name: " + (aField != null ? aField.getName() : null))
.append(eol + "target field type: " + (aField != null ? aField.getType() : null))
.append(eol + "target field declared in: " + (aField != null ? aField.getDeclaringClass().getName() : null))
.append(eol + "object value class: " + (value != null ? value.getClass().getName() : null))
.append(eol + "object value: " + (value != null ? value : null))
.append(eol + "]");
return buf.toString();
} | [
"protected",
"String",
"buildErrorSetMsg",
"(",
"Object",
"obj",
",",
"Object",
"value",
",",
"Field",
"aField",
")",
"{",
"String",
"eol",
"=",
"SystemUtils",
".",
"LINE_SEPARATOR",
";",
"StringBuffer",
"buf",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"buf",
".",
"append",
"(",
"eol",
"+",
"\"[try to set 'object value' in 'target object'\"",
")",
".",
"append",
"(",
"eol",
"+",
"\"target obj class: \"",
"+",
"(",
"obj",
"!=",
"null",
"?",
"obj",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
":",
"null",
")",
")",
".",
"append",
"(",
"eol",
"+",
"\"target field name: \"",
"+",
"(",
"aField",
"!=",
"null",
"?",
"aField",
".",
"getName",
"(",
")",
":",
"null",
")",
")",
".",
"append",
"(",
"eol",
"+",
"\"target field type: \"",
"+",
"(",
"aField",
"!=",
"null",
"?",
"aField",
".",
"getType",
"(",
")",
":",
"null",
")",
")",
".",
"append",
"(",
"eol",
"+",
"\"target field declared in: \"",
"+",
"(",
"aField",
"!=",
"null",
"?",
"aField",
".",
"getDeclaringClass",
"(",
")",
".",
"getName",
"(",
")",
":",
"null",
")",
")",
".",
"append",
"(",
"eol",
"+",
"\"object value class: \"",
"+",
"(",
"value",
"!=",
"null",
"?",
"value",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
":",
"null",
")",
")",
".",
"append",
"(",
"eol",
"+",
"\"object value: \"",
"+",
"(",
"value",
"!=",
"null",
"?",
"value",
":",
"null",
")",
")",
".",
"append",
"(",
"eol",
"+",
"\"]\"",
")",
";",
"return",
"buf",
".",
"toString",
"(",
")",
";",
"}"
] | Build a String representation of given arguments. | [
"Build",
"a",
"String",
"representation",
"of",
"given",
"arguments",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldBase.java#L150-L164 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/PersistenceBrokerFactoryBaseImpl.java | PersistenceBrokerFactoryBaseImpl.createNewBrokerInstance | protected PersistenceBrokerInternal createNewBrokerInstance(PBKey key) throws PBFactoryException
{
if (key == null) throw new PBFactoryException("Could not create new broker with PBkey argument 'null'");
// check if the given key really exists
if (MetadataManager.getInstance().connectionRepository().getDescriptor(key) == null)
{
throw new PBFactoryException("Given PBKey " + key + " does not match in metadata configuration");
}
if (log.isEnabledFor(Logger.INFO))
{
// only count created instances when INFO-Log-Level
log.info("Create new PB instance for PBKey " + key +
", already created persistence broker instances: " + instanceCount);
// useful for testing
++this.instanceCount;
}
PersistenceBrokerInternal instance = null;
Class[] types = {PBKey.class, PersistenceBrokerFactoryIF.class};
Object[] args = {key, this};
try
{
instance = (PersistenceBrokerInternal) ClassHelper.newInstance(implementationClass, types, args);
OjbConfigurator.getInstance().configure(instance);
instance = (PersistenceBrokerInternal) InterceptorFactory.getInstance().createInterceptorFor(instance);
}
catch (Exception e)
{
log.error("Creation of a new PB instance failed", e);
throw new PBFactoryException("Creation of a new PB instance failed", e);
}
return instance;
} | java | protected PersistenceBrokerInternal createNewBrokerInstance(PBKey key) throws PBFactoryException
{
if (key == null) throw new PBFactoryException("Could not create new broker with PBkey argument 'null'");
// check if the given key really exists
if (MetadataManager.getInstance().connectionRepository().getDescriptor(key) == null)
{
throw new PBFactoryException("Given PBKey " + key + " does not match in metadata configuration");
}
if (log.isEnabledFor(Logger.INFO))
{
// only count created instances when INFO-Log-Level
log.info("Create new PB instance for PBKey " + key +
", already created persistence broker instances: " + instanceCount);
// useful for testing
++this.instanceCount;
}
PersistenceBrokerInternal instance = null;
Class[] types = {PBKey.class, PersistenceBrokerFactoryIF.class};
Object[] args = {key, this};
try
{
instance = (PersistenceBrokerInternal) ClassHelper.newInstance(implementationClass, types, args);
OjbConfigurator.getInstance().configure(instance);
instance = (PersistenceBrokerInternal) InterceptorFactory.getInstance().createInterceptorFor(instance);
}
catch (Exception e)
{
log.error("Creation of a new PB instance failed", e);
throw new PBFactoryException("Creation of a new PB instance failed", e);
}
return instance;
} | [
"protected",
"PersistenceBrokerInternal",
"createNewBrokerInstance",
"(",
"PBKey",
"key",
")",
"throws",
"PBFactoryException",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"throw",
"new",
"PBFactoryException",
"(",
"\"Could not create new broker with PBkey argument 'null'\"",
")",
";",
"// check if the given key really exists\r",
"if",
"(",
"MetadataManager",
".",
"getInstance",
"(",
")",
".",
"connectionRepository",
"(",
")",
".",
"getDescriptor",
"(",
"key",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"PBFactoryException",
"(",
"\"Given PBKey \"",
"+",
"key",
"+",
"\" does not match in metadata configuration\"",
")",
";",
"}",
"if",
"(",
"log",
".",
"isEnabledFor",
"(",
"Logger",
".",
"INFO",
")",
")",
"{",
"// only count created instances when INFO-Log-Level\r",
"log",
".",
"info",
"(",
"\"Create new PB instance for PBKey \"",
"+",
"key",
"+",
"\", already created persistence broker instances: \"",
"+",
"instanceCount",
")",
";",
"// useful for testing\r",
"++",
"this",
".",
"instanceCount",
";",
"}",
"PersistenceBrokerInternal",
"instance",
"=",
"null",
";",
"Class",
"[",
"]",
"types",
"=",
"{",
"PBKey",
".",
"class",
",",
"PersistenceBrokerFactoryIF",
".",
"class",
"}",
";",
"Object",
"[",
"]",
"args",
"=",
"{",
"key",
",",
"this",
"}",
";",
"try",
"{",
"instance",
"=",
"(",
"PersistenceBrokerInternal",
")",
"ClassHelper",
".",
"newInstance",
"(",
"implementationClass",
",",
"types",
",",
"args",
")",
";",
"OjbConfigurator",
".",
"getInstance",
"(",
")",
".",
"configure",
"(",
"instance",
")",
";",
"instance",
"=",
"(",
"PersistenceBrokerInternal",
")",
"InterceptorFactory",
".",
"getInstance",
"(",
")",
".",
"createInterceptorFor",
"(",
"instance",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Creation of a new PB instance failed\"",
",",
"e",
")",
";",
"throw",
"new",
"PBFactoryException",
"(",
"\"Creation of a new PB instance failed\"",
",",
"e",
")",
";",
"}",
"return",
"instance",
";",
"}"
] | For internal use! This method creates real new PB instances | [
"For",
"internal",
"use!",
"This",
"method",
"creates",
"real",
"new",
"PB",
"instances"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/PersistenceBrokerFactoryBaseImpl.java#L83-L115 | train |
kuali/ojb-1.0.4 | src/tools/org/apache/ojb/tools/mapping/reversedb2/ojbmetatreemodel/actions/ActionAddClassDescriptor.java | ActionAddClassDescriptor.actionPerformed | public void actionPerformed(java.awt.event.ActionEvent e)
{
System.out.println("Action Command: " + e.getActionCommand());
System.out.println("Action Params : " + e.paramString());
System.out.println("Action Source : " + e.getSource());
System.out.println("Action SrcCls : " + e.getSource().getClass().getName());
org.apache.ojb.broker.metadata.ClassDescriptor cld =
new org.apache.ojb.broker.metadata.ClassDescriptor(rootNode.getRepository());
// cld.setClassNameOfObject("New Class");
cld.setTableName("New Table");
rootNode.addClassDescriptor(cld);
} | java | public void actionPerformed(java.awt.event.ActionEvent e)
{
System.out.println("Action Command: " + e.getActionCommand());
System.out.println("Action Params : " + e.paramString());
System.out.println("Action Source : " + e.getSource());
System.out.println("Action SrcCls : " + e.getSource().getClass().getName());
org.apache.ojb.broker.metadata.ClassDescriptor cld =
new org.apache.ojb.broker.metadata.ClassDescriptor(rootNode.getRepository());
// cld.setClassNameOfObject("New Class");
cld.setTableName("New Table");
rootNode.addClassDescriptor(cld);
} | [
"public",
"void",
"actionPerformed",
"(",
"java",
".",
"awt",
".",
"event",
".",
"ActionEvent",
"e",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Action Command: \"",
"+",
"e",
".",
"getActionCommand",
"(",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Action Params : \"",
"+",
"e",
".",
"paramString",
"(",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Action Source : \"",
"+",
"e",
".",
"getSource",
"(",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Action SrcCls : \"",
"+",
"e",
".",
"getSource",
"(",
")",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"org",
".",
"apache",
".",
"ojb",
".",
"broker",
".",
"metadata",
".",
"ClassDescriptor",
"cld",
"=",
"new",
"org",
".",
"apache",
".",
"ojb",
".",
"broker",
".",
"metadata",
".",
"ClassDescriptor",
"(",
"rootNode",
".",
"getRepository",
"(",
")",
")",
";",
"// cld.setClassNameOfObject(\"New Class\");\r",
"cld",
".",
"setTableName",
"(",
"\"New Table\"",
")",
";",
"rootNode",
".",
"addClassDescriptor",
"(",
"cld",
")",
";",
"}"
] | Invoked when an action occurs. | [
"Invoked",
"when",
"an",
"action",
"occurs",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/tools/org/apache/ojb/tools/mapping/reversedb2/ojbmetatreemodel/actions/ActionAddClassDescriptor.java#L35-L46 | train |
geomajas/geomajas-project-server | plugin/layer-common/layer-common/src/main/java/org/geomajas/layer/common/proxy/LayerAuthentication.java | LayerAuthentication.getMethod | @Override
public ProxyAuthenticationMethod getMethod() {
switch (authenticationMethod) {
case BASIC:
return ProxyAuthenticationMethod.BASIC;
case DIGEST:
return ProxyAuthenticationMethod.DIGEST;
case URL:
return ProxyAuthenticationMethod.URL;
default:
return null;
}
} | java | @Override
public ProxyAuthenticationMethod getMethod() {
switch (authenticationMethod) {
case BASIC:
return ProxyAuthenticationMethod.BASIC;
case DIGEST:
return ProxyAuthenticationMethod.DIGEST;
case URL:
return ProxyAuthenticationMethod.URL;
default:
return null;
}
} | [
"@",
"Override",
"public",
"ProxyAuthenticationMethod",
"getMethod",
"(",
")",
"{",
"switch",
"(",
"authenticationMethod",
")",
"{",
"case",
"BASIC",
":",
"return",
"ProxyAuthenticationMethod",
".",
"BASIC",
";",
"case",
"DIGEST",
":",
"return",
"ProxyAuthenticationMethod",
".",
"DIGEST",
";",
"case",
"URL",
":",
"return",
"ProxyAuthenticationMethod",
".",
"URL",
";",
"default",
":",
"return",
"null",
";",
"}",
"}"
] | Get the authentication method to use.
@return authentication method | [
"Get",
"the",
"authentication",
"method",
"to",
"use",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/layer-common/layer-common/src/main/java/org/geomajas/layer/common/proxy/LayerAuthentication.java#L173-L185 | train |
caligin/tinytypes | meta/src/main/java/tech/anima/tinytypes/meta/MetaTinyTypes.java | MetaTinyTypes.metaFor | public static <T> MetaTinyType<T> metaFor(Class<?> candidate) {
for (MetaTinyType meta : metas) {
if (meta.isMetaOf(candidate)) {
return meta;
}
}
throw new IllegalArgumentException(String.format("not a tinytype: %s", candidate == null ? "null" : candidate.getCanonicalName()));
} | java | public static <T> MetaTinyType<T> metaFor(Class<?> candidate) {
for (MetaTinyType meta : metas) {
if (meta.isMetaOf(candidate)) {
return meta;
}
}
throw new IllegalArgumentException(String.format("not a tinytype: %s", candidate == null ? "null" : candidate.getCanonicalName()));
} | [
"public",
"static",
"<",
"T",
">",
"MetaTinyType",
"<",
"T",
">",
"metaFor",
"(",
"Class",
"<",
"?",
">",
"candidate",
")",
"{",
"for",
"(",
"MetaTinyType",
"meta",
":",
"metas",
")",
"{",
"if",
"(",
"meta",
".",
"isMetaOf",
"(",
"candidate",
")",
")",
"{",
"return",
"meta",
";",
"}",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"not a tinytype: %s\"",
",",
"candidate",
"==",
"null",
"?",
"\"null\"",
":",
"candidate",
".",
"getCanonicalName",
"(",
")",
")",
")",
";",
"}"
] | Provides a type-specific Meta class for the given TinyType.
@param <T> the TinyType class type
@param candidate the TinyType class to obtain a Meta for
@return a Meta implementation suitable for the candidate
@throws IllegalArgumentException for null or a non-TinyType | [
"Provides",
"a",
"type",
"-",
"specific",
"Meta",
"class",
"for",
"the",
"given",
"TinyType",
"."
] | 3f79b3b35e241770a9ea0a72782210b0c2b79eb0 | https://github.com/caligin/tinytypes/blob/3f79b3b35e241770a9ea0a72782210b0c2b79eb0/meta/src/main/java/tech/anima/tinytypes/meta/MetaTinyTypes.java#L25-L32 | train |
geomajas/geomajas-project-server | api/src/main/java/org/geomajas/configuration/VectorLayerInfo.java | VectorLayerInfo.getNamedStyleInfo | public NamedStyleInfo getNamedStyleInfo(String name) {
for (NamedStyleInfo info : namedStyleInfos) {
if (info.getName().equals(name)) {
return info;
}
}
return null;
} | java | public NamedStyleInfo getNamedStyleInfo(String name) {
for (NamedStyleInfo info : namedStyleInfos) {
if (info.getName().equals(name)) {
return info;
}
}
return null;
} | [
"public",
"NamedStyleInfo",
"getNamedStyleInfo",
"(",
"String",
"name",
")",
"{",
"for",
"(",
"NamedStyleInfo",
"info",
":",
"namedStyleInfos",
")",
"{",
"if",
"(",
"info",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"name",
")",
")",
"{",
"return",
"info",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Get layer style by name.
@param name layer style name
@return layer style | [
"Get",
"layer",
"style",
"by",
"name",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/api/src/main/java/org/geomajas/configuration/VectorLayerInfo.java#L101-L108 | train |
foundation-runtime/logging | logging-api/src/main/java/com/cisco/oss/foundation/logging/structured/AbstractFoundationLoggingMarker.java | AbstractFoundationLoggingMarker.scanClassPathForFormattingAnnotations | public static void scanClassPathForFormattingAnnotations() {
ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);
// scan classpath and filter out classes that don't begin with "com.nds"
Reflections reflections = new Reflections("com.nds","com.cisco");
Set<Class<?>> annotated = reflections.getTypesAnnotatedWith(DefaultFormat.class);
// Reflections ciscoReflections = new Reflections("com.cisco");
//
// annotated.addAll(ciscoReflections.getTypesAnnotatedWith(DefaultFormat.class));
for (Class<?> markerClass : annotated) {
// if the marker class is indeed implementing FoundationLoggingMarker
// interface
if (FoundationLoggingMarker.class.isAssignableFrom(markerClass)) {
final Class<? extends FoundationLoggingMarker> clazz = (Class<? extends FoundationLoggingMarker>) markerClass;
executorService.execute(new Runnable() {
@Override
public void run() {
if (markersMap.get(clazz) == null) {
try {
// generate formatter class for this marker
// class
generateAndUpdateFormatterInMap(clazz);
} catch (Exception e) {
LOGGER.trace("problem generating formatter class from static scan method. error is: " + e.toString());
}
}
}
});
} else {// if marker class does not implement FoundationLoggingMarker
// interface, log ERROR
// verify the LOGGER was initialized. It might not be as this
// Method is called in a static block
if (LOGGER == null) {
LOGGER = LoggerFactory.getLogger(AbstractFoundationLoggingMarker.class);
}
LOGGER.error("Formatter annotations should only appear on foundationLoggingMarker implementations");
}
}
try {
TimeUnit.SECONDS.sleep(30);
} catch (InterruptedException e) {
LOGGER.trace(e.toString(), e);
}
executorService.shutdown();
// try {
// executorService.awaitTermination(15, TimeUnit.SECONDS);
// } catch (InterruptedException e) {
// LOGGER.error("creation of formatters has been interrupted");
// }
} | java | public static void scanClassPathForFormattingAnnotations() {
ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);
// scan classpath and filter out classes that don't begin with "com.nds"
Reflections reflections = new Reflections("com.nds","com.cisco");
Set<Class<?>> annotated = reflections.getTypesAnnotatedWith(DefaultFormat.class);
// Reflections ciscoReflections = new Reflections("com.cisco");
//
// annotated.addAll(ciscoReflections.getTypesAnnotatedWith(DefaultFormat.class));
for (Class<?> markerClass : annotated) {
// if the marker class is indeed implementing FoundationLoggingMarker
// interface
if (FoundationLoggingMarker.class.isAssignableFrom(markerClass)) {
final Class<? extends FoundationLoggingMarker> clazz = (Class<? extends FoundationLoggingMarker>) markerClass;
executorService.execute(new Runnable() {
@Override
public void run() {
if (markersMap.get(clazz) == null) {
try {
// generate formatter class for this marker
// class
generateAndUpdateFormatterInMap(clazz);
} catch (Exception e) {
LOGGER.trace("problem generating formatter class from static scan method. error is: " + e.toString());
}
}
}
});
} else {// if marker class does not implement FoundationLoggingMarker
// interface, log ERROR
// verify the LOGGER was initialized. It might not be as this
// Method is called in a static block
if (LOGGER == null) {
LOGGER = LoggerFactory.getLogger(AbstractFoundationLoggingMarker.class);
}
LOGGER.error("Formatter annotations should only appear on foundationLoggingMarker implementations");
}
}
try {
TimeUnit.SECONDS.sleep(30);
} catch (InterruptedException e) {
LOGGER.trace(e.toString(), e);
}
executorService.shutdown();
// try {
// executorService.awaitTermination(15, TimeUnit.SECONDS);
// } catch (InterruptedException e) {
// LOGGER.error("creation of formatters has been interrupted");
// }
} | [
"public",
"static",
"void",
"scanClassPathForFormattingAnnotations",
"(",
")",
"{",
"ExecutorService",
"executorService",
"=",
"Executors",
".",
"newFixedThreadPool",
"(",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"availableProcessors",
"(",
")",
"*",
"2",
")",
";",
"// scan classpath and filter out classes that don't begin with \"com.nds\"",
"Reflections",
"reflections",
"=",
"new",
"Reflections",
"(",
"\"com.nds\"",
",",
"\"com.cisco\"",
")",
";",
"Set",
"<",
"Class",
"<",
"?",
">",
">",
"annotated",
"=",
"reflections",
".",
"getTypesAnnotatedWith",
"(",
"DefaultFormat",
".",
"class",
")",
";",
"// Reflections ciscoReflections = new Reflections(\"com.cisco\");",
"//",
"// annotated.addAll(ciscoReflections.getTypesAnnotatedWith(DefaultFormat.class));",
"for",
"(",
"Class",
"<",
"?",
">",
"markerClass",
":",
"annotated",
")",
"{",
"// if the marker class is indeed implementing FoundationLoggingMarker",
"// interface",
"if",
"(",
"FoundationLoggingMarker",
".",
"class",
".",
"isAssignableFrom",
"(",
"markerClass",
")",
")",
"{",
"final",
"Class",
"<",
"?",
"extends",
"FoundationLoggingMarker",
">",
"clazz",
"=",
"(",
"Class",
"<",
"?",
"extends",
"FoundationLoggingMarker",
">",
")",
"markerClass",
";",
"executorService",
".",
"execute",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"if",
"(",
"markersMap",
".",
"get",
"(",
"clazz",
")",
"==",
"null",
")",
"{",
"try",
"{",
"// generate formatter class for this marker",
"// class",
"generateAndUpdateFormatterInMap",
"(",
"clazz",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOGGER",
".",
"trace",
"(",
"\"problem generating formatter class from static scan method. error is: \"",
"+",
"e",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
")",
";",
"}",
"else",
"{",
"// if marker class does not implement FoundationLoggingMarker",
"// interface, log ERROR",
"// verify the LOGGER was initialized. It might not be as this",
"// Method is called in a static block",
"if",
"(",
"LOGGER",
"==",
"null",
")",
"{",
"LOGGER",
"=",
"LoggerFactory",
".",
"getLogger",
"(",
"AbstractFoundationLoggingMarker",
".",
"class",
")",
";",
"}",
"LOGGER",
".",
"error",
"(",
"\"Formatter annotations should only appear on foundationLoggingMarker implementations\"",
")",
";",
"}",
"}",
"try",
"{",
"TimeUnit",
".",
"SECONDS",
".",
"sleep",
"(",
"30",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"LOGGER",
".",
"trace",
"(",
"e",
".",
"toString",
"(",
")",
",",
"e",
")",
";",
"}",
"executorService",
".",
"shutdown",
"(",
")",
";",
"// try {",
"// executorService.awaitTermination(15, TimeUnit.SECONDS);",
"// } catch (InterruptedException e) {",
"// LOGGER.error(\"creation of formatters has been interrupted\");",
"// }",
"}"
] | Scan all the class path and look for all classes that have the Format
Annotations. | [
"Scan",
"all",
"the",
"class",
"path",
"and",
"look",
"for",
"all",
"classes",
"that",
"have",
"the",
"Format",
"Annotations",
"."
] | cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6 | https://github.com/foundation-runtime/logging/blob/cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6/logging-api/src/main/java/com/cisco/oss/foundation/logging/structured/AbstractFoundationLoggingMarker.java#L544-L606 | train |
foundation-runtime/logging | logging-log4j/src/main/java/com/cisco/oss/foundation/logging/FoundationHierarchyEventListener.java | FoundationHierarchyEventListener.addAppenderEvent | public void addAppenderEvent(final Category cat, final Appender appender) {
updateDefaultLayout(appender);
if (appender instanceof FoundationFileRollingAppender) {
final FoundationFileRollingAppender timeSizeRollingAppender = (FoundationFileRollingAppender) appender;
// update the appender with default vales such as logging pattern, file size etc.
//updateDefaultTimeAndSizeRollingAppender(timeSizeRollingAppender);
// read teh proeprties and determine if archiving should be enabled.
updateArchivingSupport(timeSizeRollingAppender);
// by default add the rolling file listener to enable application
// state.
timeSizeRollingAppender.setFileRollEventListener(FoundationRollEventListener.class.getName());
boolean rollOnStartup = true;
if (FoundationLogger.log4jConfigProps != null && FoundationLogger.log4jConfigProps.containsKey(FoundationLoggerConstants.Foundation_ROLL_ON_STARTUP.toString())) {
rollOnStartup = Boolean.valueOf(FoundationLogger.log4jConfigProps.getProperty(FoundationLoggerConstants.Foundation_ROLL_ON_STARTUP.toString()));
}
timeSizeRollingAppender.setRollOnStartup(rollOnStartup);
// refresh the appender
timeSizeRollingAppender.activateOptions();
// timeSizeRollingAppender.setOriginalLayout(); //So application state will not make any problems
}else if(!(appender instanceof FoundationFileRollingAppender) && (appender instanceof TimeAndSizeRollingAppender)){ //TimeAndSizeRollingAppender
final TimeAndSizeRollingAppender timeSizeRollingAppender = (TimeAndSizeRollingAppender) appender;
// update the appender with default vales such as logging pattern, file size etc.
updateDefaultTimeAndSizeRollingAppender(timeSizeRollingAppender);
// read teh proeprties and determine if archiving should be enabled.
updateArchivingSupport(timeSizeRollingAppender);
// by default add the rolling file listener to enable application
// state.
timeSizeRollingAppender.setFileRollEventListener(FoundationRollEventListener.class.getName());
boolean rollOnStartup = true;
if (FoundationLogger.log4jConfigProps != null && FoundationLogger.log4jConfigProps.containsKey(FoundationLoggerConstants.Foundation_ROLL_ON_STARTUP.toString())) {
rollOnStartup = Boolean.valueOf(FoundationLogger.log4jConfigProps.getProperty(FoundationLoggerConstants.Foundation_ROLL_ON_STARTUP.toString()));
}
timeSizeRollingAppender.setRollOnStartup(rollOnStartup);
// refresh the appender
timeSizeRollingAppender.activateOptions();
// timeSizeRollingAppender.setOriginalLayout();
}
if ( ! (appender instanceof org.apache.log4j.AsyncAppender))
initiateAsyncSupport(appender);
} | java | public void addAppenderEvent(final Category cat, final Appender appender) {
updateDefaultLayout(appender);
if (appender instanceof FoundationFileRollingAppender) {
final FoundationFileRollingAppender timeSizeRollingAppender = (FoundationFileRollingAppender) appender;
// update the appender with default vales such as logging pattern, file size etc.
//updateDefaultTimeAndSizeRollingAppender(timeSizeRollingAppender);
// read teh proeprties and determine if archiving should be enabled.
updateArchivingSupport(timeSizeRollingAppender);
// by default add the rolling file listener to enable application
// state.
timeSizeRollingAppender.setFileRollEventListener(FoundationRollEventListener.class.getName());
boolean rollOnStartup = true;
if (FoundationLogger.log4jConfigProps != null && FoundationLogger.log4jConfigProps.containsKey(FoundationLoggerConstants.Foundation_ROLL_ON_STARTUP.toString())) {
rollOnStartup = Boolean.valueOf(FoundationLogger.log4jConfigProps.getProperty(FoundationLoggerConstants.Foundation_ROLL_ON_STARTUP.toString()));
}
timeSizeRollingAppender.setRollOnStartup(rollOnStartup);
// refresh the appender
timeSizeRollingAppender.activateOptions();
// timeSizeRollingAppender.setOriginalLayout(); //So application state will not make any problems
}else if(!(appender instanceof FoundationFileRollingAppender) && (appender instanceof TimeAndSizeRollingAppender)){ //TimeAndSizeRollingAppender
final TimeAndSizeRollingAppender timeSizeRollingAppender = (TimeAndSizeRollingAppender) appender;
// update the appender with default vales such as logging pattern, file size etc.
updateDefaultTimeAndSizeRollingAppender(timeSizeRollingAppender);
// read teh proeprties and determine if archiving should be enabled.
updateArchivingSupport(timeSizeRollingAppender);
// by default add the rolling file listener to enable application
// state.
timeSizeRollingAppender.setFileRollEventListener(FoundationRollEventListener.class.getName());
boolean rollOnStartup = true;
if (FoundationLogger.log4jConfigProps != null && FoundationLogger.log4jConfigProps.containsKey(FoundationLoggerConstants.Foundation_ROLL_ON_STARTUP.toString())) {
rollOnStartup = Boolean.valueOf(FoundationLogger.log4jConfigProps.getProperty(FoundationLoggerConstants.Foundation_ROLL_ON_STARTUP.toString()));
}
timeSizeRollingAppender.setRollOnStartup(rollOnStartup);
// refresh the appender
timeSizeRollingAppender.activateOptions();
// timeSizeRollingAppender.setOriginalLayout();
}
if ( ! (appender instanceof org.apache.log4j.AsyncAppender))
initiateAsyncSupport(appender);
} | [
"public",
"void",
"addAppenderEvent",
"(",
"final",
"Category",
"cat",
",",
"final",
"Appender",
"appender",
")",
"{",
"updateDefaultLayout",
"(",
"appender",
")",
";",
"if",
"(",
"appender",
"instanceof",
"FoundationFileRollingAppender",
")",
"{",
"final",
"FoundationFileRollingAppender",
"timeSizeRollingAppender",
"=",
"(",
"FoundationFileRollingAppender",
")",
"appender",
";",
"// update the appender with default vales such as logging pattern, file size etc.",
"//updateDefaultTimeAndSizeRollingAppender(timeSizeRollingAppender);",
"// read teh proeprties and determine if archiving should be enabled.",
"updateArchivingSupport",
"(",
"timeSizeRollingAppender",
")",
";",
"// by default add the rolling file listener to enable application",
"// state.",
"timeSizeRollingAppender",
".",
"setFileRollEventListener",
"(",
"FoundationRollEventListener",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"boolean",
"rollOnStartup",
"=",
"true",
";",
"if",
"(",
"FoundationLogger",
".",
"log4jConfigProps",
"!=",
"null",
"&&",
"FoundationLogger",
".",
"log4jConfigProps",
".",
"containsKey",
"(",
"FoundationLoggerConstants",
".",
"Foundation_ROLL_ON_STARTUP",
".",
"toString",
"(",
")",
")",
")",
"{",
"rollOnStartup",
"=",
"Boolean",
".",
"valueOf",
"(",
"FoundationLogger",
".",
"log4jConfigProps",
".",
"getProperty",
"(",
"FoundationLoggerConstants",
".",
"Foundation_ROLL_ON_STARTUP",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"timeSizeRollingAppender",
".",
"setRollOnStartup",
"(",
"rollOnStartup",
")",
";",
"// refresh the appender",
"timeSizeRollingAppender",
".",
"activateOptions",
"(",
")",
";",
"//\ttimeSizeRollingAppender.setOriginalLayout(); //So application state will not make any problems",
"}",
"else",
"if",
"(",
"!",
"(",
"appender",
"instanceof",
"FoundationFileRollingAppender",
")",
"&&",
"(",
"appender",
"instanceof",
"TimeAndSizeRollingAppender",
")",
")",
"{",
"//TimeAndSizeRollingAppender",
"final",
"TimeAndSizeRollingAppender",
"timeSizeRollingAppender",
"=",
"(",
"TimeAndSizeRollingAppender",
")",
"appender",
";",
"// update the appender with default vales such as logging pattern, file size etc.",
"updateDefaultTimeAndSizeRollingAppender",
"(",
"timeSizeRollingAppender",
")",
";",
"// read teh proeprties and determine if archiving should be enabled.",
"updateArchivingSupport",
"(",
"timeSizeRollingAppender",
")",
";",
"// by default add the rolling file listener to enable application",
"// state.",
"timeSizeRollingAppender",
".",
"setFileRollEventListener",
"(",
"FoundationRollEventListener",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"boolean",
"rollOnStartup",
"=",
"true",
";",
"if",
"(",
"FoundationLogger",
".",
"log4jConfigProps",
"!=",
"null",
"&&",
"FoundationLogger",
".",
"log4jConfigProps",
".",
"containsKey",
"(",
"FoundationLoggerConstants",
".",
"Foundation_ROLL_ON_STARTUP",
".",
"toString",
"(",
")",
")",
")",
"{",
"rollOnStartup",
"=",
"Boolean",
".",
"valueOf",
"(",
"FoundationLogger",
".",
"log4jConfigProps",
".",
"getProperty",
"(",
"FoundationLoggerConstants",
".",
"Foundation_ROLL_ON_STARTUP",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"timeSizeRollingAppender",
".",
"setRollOnStartup",
"(",
"rollOnStartup",
")",
";",
"// refresh the appender",
"timeSizeRollingAppender",
".",
"activateOptions",
"(",
")",
";",
"//\ttimeSizeRollingAppender.setOriginalLayout();",
"}",
"if",
"(",
"!",
"(",
"appender",
"instanceof",
"org",
".",
"apache",
".",
"log4j",
".",
"AsyncAppender",
")",
")",
"initiateAsyncSupport",
"(",
"appender",
")",
";",
"}"
] | In this method perform the actual override in runtime.
@see org.apache.log4j.spi.HierarchyEventListener#addAppenderEvent(org.apache.log4j.Category, org.apache.log4j.Appender) | [
"In",
"this",
"method",
"perform",
"the",
"actual",
"override",
"in",
"runtime",
"."
] | cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6 | https://github.com/foundation-runtime/logging/blob/cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6/logging-log4j/src/main/java/com/cisco/oss/foundation/logging/FoundationHierarchyEventListener.java#L55-L116 | train |
foundation-runtime/logging | logging-log4j/src/main/java/com/cisco/oss/foundation/logging/FoundationHierarchyEventListener.java | FoundationHierarchyEventListener.updateDefaultTimeAndSizeRollingAppender | private void updateDefaultTimeAndSizeRollingAppender(final FoundationFileRollingAppender appender) {
if (appender.getDatePattern().trim().length() == 0) {
appender.setDatePattern(FoundationLoggerConstants.DEFAULT_DATE_PATTERN.toString());
}
String maxFileSizeKey = "log4j.appender."+appender.getName()+".MaxFileSize";
appender.setMaxFileSize(FoundationLogger.log4jConfigProps.getProperty(maxFileSizeKey, FoundationLoggerConstants.Foundation_MAX_FILE_SIZE.toString()));
// if (appender.getMaxFileSize() == null || appender.getMaxFileSize().equals(FoundationLoggerConstants.DEFAULT_FILE_SIZE.toString())) {
// appender.setMaxFileSize(FoundationLoggerConstants.Foundation_MAX_FILE_SIZE.toString());
// }
String maxRollCountKey = "log4j.appender."+appender.getName()+".MaxRollFileCount";
appender.setMaxRollFileCount(Integer.parseInt(FoundationLogger.log4jConfigProps.getProperty(maxRollCountKey,"100")));
} | java | private void updateDefaultTimeAndSizeRollingAppender(final FoundationFileRollingAppender appender) {
if (appender.getDatePattern().trim().length() == 0) {
appender.setDatePattern(FoundationLoggerConstants.DEFAULT_DATE_PATTERN.toString());
}
String maxFileSizeKey = "log4j.appender."+appender.getName()+".MaxFileSize";
appender.setMaxFileSize(FoundationLogger.log4jConfigProps.getProperty(maxFileSizeKey, FoundationLoggerConstants.Foundation_MAX_FILE_SIZE.toString()));
// if (appender.getMaxFileSize() == null || appender.getMaxFileSize().equals(FoundationLoggerConstants.DEFAULT_FILE_SIZE.toString())) {
// appender.setMaxFileSize(FoundationLoggerConstants.Foundation_MAX_FILE_SIZE.toString());
// }
String maxRollCountKey = "log4j.appender."+appender.getName()+".MaxRollFileCount";
appender.setMaxRollFileCount(Integer.parseInt(FoundationLogger.log4jConfigProps.getProperty(maxRollCountKey,"100")));
} | [
"private",
"void",
"updateDefaultTimeAndSizeRollingAppender",
"(",
"final",
"FoundationFileRollingAppender",
"appender",
")",
"{",
"if",
"(",
"appender",
".",
"getDatePattern",
"(",
")",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"appender",
".",
"setDatePattern",
"(",
"FoundationLoggerConstants",
".",
"DEFAULT_DATE_PATTERN",
".",
"toString",
"(",
")",
")",
";",
"}",
"String",
"maxFileSizeKey",
"=",
"\"log4j.appender.\"",
"+",
"appender",
".",
"getName",
"(",
")",
"+",
"\".MaxFileSize\"",
";",
"appender",
".",
"setMaxFileSize",
"(",
"FoundationLogger",
".",
"log4jConfigProps",
".",
"getProperty",
"(",
"maxFileSizeKey",
",",
"FoundationLoggerConstants",
".",
"Foundation_MAX_FILE_SIZE",
".",
"toString",
"(",
")",
")",
")",
";",
"//\t\tif (appender.getMaxFileSize() == null || appender.getMaxFileSize().equals(FoundationLoggerConstants.DEFAULT_FILE_SIZE.toString())) {",
"//\t\t\tappender.setMaxFileSize(FoundationLoggerConstants.Foundation_MAX_FILE_SIZE.toString());",
"//\t\t}",
"String",
"maxRollCountKey",
"=",
"\"log4j.appender.\"",
"+",
"appender",
".",
"getName",
"(",
")",
"+",
"\".MaxRollFileCount\"",
";",
"appender",
".",
"setMaxRollFileCount",
"(",
"Integer",
".",
"parseInt",
"(",
"FoundationLogger",
".",
"log4jConfigProps",
".",
"getProperty",
"(",
"maxRollCountKey",
",",
"\"100\"",
")",
")",
")",
";",
"}"
] | Set default values for the TimeAndSizeRollingAppender appender
@param appender | [
"Set",
"default",
"values",
"for",
"the",
"TimeAndSizeRollingAppender",
"appender"
] | cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6 | https://github.com/foundation-runtime/logging/blob/cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6/logging-log4j/src/main/java/com/cisco/oss/foundation/logging/FoundationHierarchyEventListener.java#L289-L304 | train |
foundation-runtime/logging | logging-log4j/src/main/java/com/cisco/oss/foundation/logging/appender/FileRollEvent.java | FileRollEvent.dispatchToAppender | final void dispatchToAppender(final String message) {
// dispatch a copy, since events should be treated as being immutable
final FoundationFileRollingAppender appender = this.getSource();
if (appender != null) {
appender.append(new FileRollEvent(this, message));
}
} | java | final void dispatchToAppender(final String message) {
// dispatch a copy, since events should be treated as being immutable
final FoundationFileRollingAppender appender = this.getSource();
if (appender != null) {
appender.append(new FileRollEvent(this, message));
}
} | [
"final",
"void",
"dispatchToAppender",
"(",
"final",
"String",
"message",
")",
"{",
"// dispatch a copy, since events should be treated as being immutable",
"final",
"FoundationFileRollingAppender",
"appender",
"=",
"this",
".",
"getSource",
"(",
")",
";",
"if",
"(",
"appender",
"!=",
"null",
")",
"{",
"appender",
".",
"append",
"(",
"new",
"FileRollEvent",
"(",
"this",
",",
"message",
")",
")",
";",
"}",
"}"
] | Convenience method dispatches this object to the source appender, which
will result in the custom message being appended to the new file.
@param message
The custom logging message to be appended. | [
"Convenience",
"method",
"dispatches",
"this",
"object",
"to",
"the",
"source",
"appender",
"which",
"will",
"result",
"in",
"the",
"custom",
"message",
"being",
"appended",
"to",
"the",
"new",
"file",
"."
] | cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6 | https://github.com/foundation-runtime/logging/blob/cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6/logging-log4j/src/main/java/com/cisco/oss/foundation/logging/appender/FileRollEvent.java#L124-L130 | train |
foundation-runtime/logging | logging-log4j/src/main/java/com/cisco/oss/foundation/logging/appender/FileRollEvent.java | FileRollEvent.dispatchToAppender | final void dispatchToAppender(final LoggingEvent customLoggingEvent) {
// wrap the LoggingEvent in a FileRollEvent to prevent recursion bug
final FoundationFileRollingAppender appender = this.getSource();
if (appender != null) {
appender.append(new FileRollEvent(customLoggingEvent, this));
}
} | java | final void dispatchToAppender(final LoggingEvent customLoggingEvent) {
// wrap the LoggingEvent in a FileRollEvent to prevent recursion bug
final FoundationFileRollingAppender appender = this.getSource();
if (appender != null) {
appender.append(new FileRollEvent(customLoggingEvent, this));
}
} | [
"final",
"void",
"dispatchToAppender",
"(",
"final",
"LoggingEvent",
"customLoggingEvent",
")",
"{",
"// wrap the LoggingEvent in a FileRollEvent to prevent recursion bug",
"final",
"FoundationFileRollingAppender",
"appender",
"=",
"this",
".",
"getSource",
"(",
")",
";",
"if",
"(",
"appender",
"!=",
"null",
")",
"{",
"appender",
".",
"append",
"(",
"new",
"FileRollEvent",
"(",
"customLoggingEvent",
",",
"this",
")",
")",
";",
"}",
"}"
] | Convenience method dispatches the specified event to the source appender,
which will result in the custom event data being appended to the new file.
@param customLoggingEvent
The custom Log4J event to be appended. | [
"Convenience",
"method",
"dispatches",
"the",
"specified",
"event",
"to",
"the",
"source",
"appender",
"which",
"will",
"result",
"in",
"the",
"custom",
"event",
"data",
"being",
"appended",
"to",
"the",
"new",
"file",
"."
] | cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6 | https://github.com/foundation-runtime/logging/blob/cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6/logging-log4j/src/main/java/com/cisco/oss/foundation/logging/appender/FileRollEvent.java#L150-L156 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlExistStatement.java | SqlExistStatement.getStatement | public String getStatement()
{
if(sql == null)
{
StringBuffer stmt = new StringBuffer(128);
ClassDescriptor cld = getClassDescriptor();
FieldDescriptor[] fieldDescriptors = cld.getPkFields();
if(fieldDescriptors == null || fieldDescriptors.length == 0)
{
throw new OJBRuntimeException("No PK fields defined in metadata for " + cld.getClassNameOfObject());
}
FieldDescriptor field = fieldDescriptors[0];
stmt.append(SELECT);
stmt.append(field.getColumnName());
stmt.append(FROM);
stmt.append(cld.getFullTableName());
appendWhereClause(cld, false, stmt);
sql = stmt.toString();
}
return sql;
} | java | public String getStatement()
{
if(sql == null)
{
StringBuffer stmt = new StringBuffer(128);
ClassDescriptor cld = getClassDescriptor();
FieldDescriptor[] fieldDescriptors = cld.getPkFields();
if(fieldDescriptors == null || fieldDescriptors.length == 0)
{
throw new OJBRuntimeException("No PK fields defined in metadata for " + cld.getClassNameOfObject());
}
FieldDescriptor field = fieldDescriptors[0];
stmt.append(SELECT);
stmt.append(field.getColumnName());
stmt.append(FROM);
stmt.append(cld.getFullTableName());
appendWhereClause(cld, false, stmt);
sql = stmt.toString();
}
return sql;
} | [
"public",
"String",
"getStatement",
"(",
")",
"{",
"if",
"(",
"sql",
"==",
"null",
")",
"{",
"StringBuffer",
"stmt",
"=",
"new",
"StringBuffer",
"(",
"128",
")",
";",
"ClassDescriptor",
"cld",
"=",
"getClassDescriptor",
"(",
")",
";",
"FieldDescriptor",
"[",
"]",
"fieldDescriptors",
"=",
"cld",
".",
"getPkFields",
"(",
")",
";",
"if",
"(",
"fieldDescriptors",
"==",
"null",
"||",
"fieldDescriptors",
".",
"length",
"==",
"0",
")",
"{",
"throw",
"new",
"OJBRuntimeException",
"(",
"\"No PK fields defined in metadata for \"",
"+",
"cld",
".",
"getClassNameOfObject",
"(",
")",
")",
";",
"}",
"FieldDescriptor",
"field",
"=",
"fieldDescriptors",
"[",
"0",
"]",
";",
"stmt",
".",
"append",
"(",
"SELECT",
")",
";",
"stmt",
".",
"append",
"(",
"field",
".",
"getColumnName",
"(",
")",
")",
";",
"stmt",
".",
"append",
"(",
"FROM",
")",
";",
"stmt",
".",
"append",
"(",
"cld",
".",
"getFullTableName",
"(",
")",
")",
";",
"appendWhereClause",
"(",
"cld",
",",
"false",
",",
"stmt",
")",
";",
"sql",
"=",
"stmt",
".",
"toString",
"(",
")",
";",
"}",
"return",
"sql",
";",
"}"
] | Return SELECT clause for object existence call | [
"Return",
"SELECT",
"clause",
"for",
"object",
"existence",
"call"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlExistStatement.java#L43-L66 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java | FieldDescriptor.getComparator | public static Comparator getComparator()
{
return new Comparator()
{
public int compare(Object o1, Object o2)
{
FieldDescriptor fmd1 = (FieldDescriptor) o1;
FieldDescriptor fmd2 = (FieldDescriptor) o2;
if (fmd1.getColNo() < fmd2.getColNo())
{
return -1;
}
else if (fmd1.getColNo() > fmd2.getColNo())
{
return 1;
}
else
{
return 0;
}
}
};
} | java | public static Comparator getComparator()
{
return new Comparator()
{
public int compare(Object o1, Object o2)
{
FieldDescriptor fmd1 = (FieldDescriptor) o1;
FieldDescriptor fmd2 = (FieldDescriptor) o2;
if (fmd1.getColNo() < fmd2.getColNo())
{
return -1;
}
else if (fmd1.getColNo() > fmd2.getColNo())
{
return 1;
}
else
{
return 0;
}
}
};
} | [
"public",
"static",
"Comparator",
"getComparator",
"(",
")",
"{",
"return",
"new",
"Comparator",
"(",
")",
"{",
"public",
"int",
"compare",
"(",
"Object",
"o1",
",",
"Object",
"o2",
")",
"{",
"FieldDescriptor",
"fmd1",
"=",
"(",
"FieldDescriptor",
")",
"o1",
";",
"FieldDescriptor",
"fmd2",
"=",
"(",
"FieldDescriptor",
")",
"o2",
";",
"if",
"(",
"fmd1",
".",
"getColNo",
"(",
")",
"<",
"fmd2",
".",
"getColNo",
"(",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"fmd1",
".",
"getColNo",
"(",
")",
">",
"fmd2",
".",
"getColNo",
"(",
")",
")",
"{",
"return",
"1",
";",
"}",
"else",
"{",
"return",
"0",
";",
"}",
"}",
"}",
";",
"}"
] | returns a comparator that allows to sort a Vector of FieldMappingDecriptors
according to their m_Order entries. | [
"returns",
"a",
"comparator",
"that",
"allows",
"to",
"sort",
"a",
"Vector",
"of",
"FieldMappingDecriptors",
"according",
"to",
"their",
"m_Order",
"entries",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java#L79-L101 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java | FieldDescriptor.setFieldConversionClassName | public void setFieldConversionClassName(String fieldConversionClassName)
{
try
{
this.fieldConversion = (FieldConversion) ClassHelper.newInstance(fieldConversionClassName);
}
catch (Exception e)
{
throw new MetadataException(
"Could not instantiate FieldConversion class using default constructor", e);
}
} | java | public void setFieldConversionClassName(String fieldConversionClassName)
{
try
{
this.fieldConversion = (FieldConversion) ClassHelper.newInstance(fieldConversionClassName);
}
catch (Exception e)
{
throw new MetadataException(
"Could not instantiate FieldConversion class using default constructor", e);
}
} | [
"public",
"void",
"setFieldConversionClassName",
"(",
"String",
"fieldConversionClassName",
")",
"{",
"try",
"{",
"this",
".",
"fieldConversion",
"=",
"(",
"FieldConversion",
")",
"ClassHelper",
".",
"newInstance",
"(",
"fieldConversionClassName",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"MetadataException",
"(",
"\"Could not instantiate FieldConversion class using default constructor\"",
",",
"e",
")",
";",
"}",
"}"
] | Sets the fieldConversion.
@param fieldConversionClassName The fieldConversion to set | [
"Sets",
"the",
"fieldConversion",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java#L260-L271 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java | TorqueDBHandling.setConnection | public void setConnection(JdbcConnectionDescriptor jcd) throws PlatformException
{
_jcd = jcd;
String targetDatabase = (String)_dbmsToTorqueDb.get(_jcd.getDbms().toLowerCase());
if (targetDatabase == null)
{
throw new PlatformException("Database "+_jcd.getDbms()+" is not supported by torque");
}
if (!targetDatabase.equals(_targetDatabase))
{
_targetDatabase = targetDatabase;
_creationScript = null;
_initScripts.clear();
}
} | java | public void setConnection(JdbcConnectionDescriptor jcd) throws PlatformException
{
_jcd = jcd;
String targetDatabase = (String)_dbmsToTorqueDb.get(_jcd.getDbms().toLowerCase());
if (targetDatabase == null)
{
throw new PlatformException("Database "+_jcd.getDbms()+" is not supported by torque");
}
if (!targetDatabase.equals(_targetDatabase))
{
_targetDatabase = targetDatabase;
_creationScript = null;
_initScripts.clear();
}
} | [
"public",
"void",
"setConnection",
"(",
"JdbcConnectionDescriptor",
"jcd",
")",
"throws",
"PlatformException",
"{",
"_jcd",
"=",
"jcd",
";",
"String",
"targetDatabase",
"=",
"(",
"String",
")",
"_dbmsToTorqueDb",
".",
"get",
"(",
"_jcd",
".",
"getDbms",
"(",
")",
".",
"toLowerCase",
"(",
")",
")",
";",
"if",
"(",
"targetDatabase",
"==",
"null",
")",
"{",
"throw",
"new",
"PlatformException",
"(",
"\"Database \"",
"+",
"_jcd",
".",
"getDbms",
"(",
")",
"+",
"\" is not supported by torque\"",
")",
";",
"}",
"if",
"(",
"!",
"targetDatabase",
".",
"equals",
"(",
"_targetDatabase",
")",
")",
"{",
"_targetDatabase",
"=",
"targetDatabase",
";",
"_creationScript",
"=",
"null",
";",
"_initScripts",
".",
"clear",
"(",
")",
";",
"}",
"}"
] | Sets the jdbc connection to use.
@param jcd The connection to use
@throws PlatformException If the target database cannot be handled with torque | [
"Sets",
"the",
"jdbc",
"connection",
"to",
"use",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java#L102-L118 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java | TorqueDBHandling.writeSchemata | private String writeSchemata(File dir) throws IOException
{
writeCompressedTexts(dir, _torqueSchemata);
StringBuffer includes = new StringBuffer();
for (Iterator it = _torqueSchemata.keySet().iterator(); it.hasNext();)
{
includes.append((String)it.next());
if (it.hasNext())
{
includes.append(",");
}
}
return includes.toString();
} | java | private String writeSchemata(File dir) throws IOException
{
writeCompressedTexts(dir, _torqueSchemata);
StringBuffer includes = new StringBuffer();
for (Iterator it = _torqueSchemata.keySet().iterator(); it.hasNext();)
{
includes.append((String)it.next());
if (it.hasNext())
{
includes.append(",");
}
}
return includes.toString();
} | [
"private",
"String",
"writeSchemata",
"(",
"File",
"dir",
")",
"throws",
"IOException",
"{",
"writeCompressedTexts",
"(",
"dir",
",",
"_torqueSchemata",
")",
";",
"StringBuffer",
"includes",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"for",
"(",
"Iterator",
"it",
"=",
"_torqueSchemata",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"includes",
".",
"append",
"(",
"(",
"String",
")",
"it",
".",
"next",
"(",
")",
")",
";",
"if",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"includes",
".",
"append",
"(",
"\",\"",
")",
";",
"}",
"}",
"return",
"includes",
".",
"toString",
"(",
")",
";",
"}"
] | Writes the torque schemata to files in the given directory and returns
a comma-separated list of the filenames.
@param dir The directory to write the files to
@return The list of filenames
@throws IOException If an error occurred | [
"Writes",
"the",
"torque",
"schemata",
"to",
"files",
"in",
"the",
"given",
"directory",
"and",
"returns",
"a",
"comma",
"-",
"separated",
"list",
"of",
"the",
"filenames",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java#L182-L197 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java | TorqueDBHandling.createDB | public void createDB() throws PlatformException
{
if (_creationScript == null)
{
createCreationScript();
}
Project project = new Project();
TorqueDataModelTask modelTask = new TorqueDataModelTask();
File tmpDir = null;
File scriptFile = null;
try
{
tmpDir = new File(getWorkDir(), "schemas");
tmpDir.mkdir();
scriptFile = new File(tmpDir, CREATION_SCRIPT_NAME);
writeCompressedText(scriptFile, _creationScript);
project.setBasedir(tmpDir.getAbsolutePath());
// we use the ant task 'sql' to perform the creation script
SQLExec sqlTask = new SQLExec();
SQLExec.OnError onError = new SQLExec.OnError();
onError.setValue("continue");
sqlTask.setProject(project);
sqlTask.setAutocommit(true);
sqlTask.setDriver(_jcd.getDriver());
sqlTask.setOnerror(onError);
sqlTask.setUserid(_jcd.getUserName());
sqlTask.setPassword(_jcd.getPassWord() == null ? "" : _jcd.getPassWord());
sqlTask.setUrl(getDBCreationUrl());
sqlTask.setSrc(scriptFile);
sqlTask.execute();
deleteDir(tmpDir);
}
catch (Exception ex)
{
// clean-up
if ((tmpDir != null) && tmpDir.exists())
{
try
{
scriptFile.delete();
}
catch (NullPointerException e)
{
LoggerFactory.getLogger(this.getClass()).error("NPE While deleting scriptFile [" + scriptFile.getName() + "]", e);
}
}
throw new PlatformException(ex);
}
} | java | public void createDB() throws PlatformException
{
if (_creationScript == null)
{
createCreationScript();
}
Project project = new Project();
TorqueDataModelTask modelTask = new TorqueDataModelTask();
File tmpDir = null;
File scriptFile = null;
try
{
tmpDir = new File(getWorkDir(), "schemas");
tmpDir.mkdir();
scriptFile = new File(tmpDir, CREATION_SCRIPT_NAME);
writeCompressedText(scriptFile, _creationScript);
project.setBasedir(tmpDir.getAbsolutePath());
// we use the ant task 'sql' to perform the creation script
SQLExec sqlTask = new SQLExec();
SQLExec.OnError onError = new SQLExec.OnError();
onError.setValue("continue");
sqlTask.setProject(project);
sqlTask.setAutocommit(true);
sqlTask.setDriver(_jcd.getDriver());
sqlTask.setOnerror(onError);
sqlTask.setUserid(_jcd.getUserName());
sqlTask.setPassword(_jcd.getPassWord() == null ? "" : _jcd.getPassWord());
sqlTask.setUrl(getDBCreationUrl());
sqlTask.setSrc(scriptFile);
sqlTask.execute();
deleteDir(tmpDir);
}
catch (Exception ex)
{
// clean-up
if ((tmpDir != null) && tmpDir.exists())
{
try
{
scriptFile.delete();
}
catch (NullPointerException e)
{
LoggerFactory.getLogger(this.getClass()).error("NPE While deleting scriptFile [" + scriptFile.getName() + "]", e);
}
}
throw new PlatformException(ex);
}
} | [
"public",
"void",
"createDB",
"(",
")",
"throws",
"PlatformException",
"{",
"if",
"(",
"_creationScript",
"==",
"null",
")",
"{",
"createCreationScript",
"(",
")",
";",
"}",
"Project",
"project",
"=",
"new",
"Project",
"(",
")",
";",
"TorqueDataModelTask",
"modelTask",
"=",
"new",
"TorqueDataModelTask",
"(",
")",
";",
"File",
"tmpDir",
"=",
"null",
";",
"File",
"scriptFile",
"=",
"null",
";",
"try",
"{",
"tmpDir",
"=",
"new",
"File",
"(",
"getWorkDir",
"(",
")",
",",
"\"schemas\"",
")",
";",
"tmpDir",
".",
"mkdir",
"(",
")",
";",
"scriptFile",
"=",
"new",
"File",
"(",
"tmpDir",
",",
"CREATION_SCRIPT_NAME",
")",
";",
"writeCompressedText",
"(",
"scriptFile",
",",
"_creationScript",
")",
";",
"project",
".",
"setBasedir",
"(",
"tmpDir",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"// we use the ant task 'sql' to perform the creation script\r",
"SQLExec",
"sqlTask",
"=",
"new",
"SQLExec",
"(",
")",
";",
"SQLExec",
".",
"OnError",
"onError",
"=",
"new",
"SQLExec",
".",
"OnError",
"(",
")",
";",
"onError",
".",
"setValue",
"(",
"\"continue\"",
")",
";",
"sqlTask",
".",
"setProject",
"(",
"project",
")",
";",
"sqlTask",
".",
"setAutocommit",
"(",
"true",
")",
";",
"sqlTask",
".",
"setDriver",
"(",
"_jcd",
".",
"getDriver",
"(",
")",
")",
";",
"sqlTask",
".",
"setOnerror",
"(",
"onError",
")",
";",
"sqlTask",
".",
"setUserid",
"(",
"_jcd",
".",
"getUserName",
"(",
")",
")",
";",
"sqlTask",
".",
"setPassword",
"(",
"_jcd",
".",
"getPassWord",
"(",
")",
"==",
"null",
"?",
"\"\"",
":",
"_jcd",
".",
"getPassWord",
"(",
")",
")",
";",
"sqlTask",
".",
"setUrl",
"(",
"getDBCreationUrl",
"(",
")",
")",
";",
"sqlTask",
".",
"setSrc",
"(",
"scriptFile",
")",
";",
"sqlTask",
".",
"execute",
"(",
")",
";",
"deleteDir",
"(",
"tmpDir",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"// clean-up\r",
"if",
"(",
"(",
"tmpDir",
"!=",
"null",
")",
"&&",
"tmpDir",
".",
"exists",
"(",
")",
")",
"{",
"try",
"{",
"scriptFile",
".",
"delete",
"(",
")",
";",
"}",
"catch",
"(",
"NullPointerException",
"e",
")",
"{",
"LoggerFactory",
".",
"getLogger",
"(",
"this",
".",
"getClass",
"(",
")",
")",
".",
"error",
"(",
"\"NPE While deleting scriptFile [\"",
"+",
"scriptFile",
".",
"getName",
"(",
")",
"+",
"\"]\"",
",",
"e",
")",
";",
"}",
"}",
"throw",
"new",
"PlatformException",
"(",
"ex",
")",
";",
"}",
"}"
] | Creates the database.
@throws PlatformException If some error occurred | [
"Creates",
"the",
"database",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java#L258-L314 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java | TorqueDBHandling.initDB | public void initDB() throws PlatformException
{
if (_initScripts.isEmpty())
{
createInitScripts();
}
Project project = new Project();
TorqueSQLTask sqlTask = new TorqueSQLTask();
File outputDir = null;
try
{
outputDir = new File(getWorkDir(), "sql");
outputDir.mkdir();
writeCompressedTexts(outputDir, _initScripts);
project.setBasedir(outputDir.getAbsolutePath());
// executing the generated sql, but this time with a torque task
TorqueSQLExec sqlExec = new TorqueSQLExec();
TorqueSQLExec.OnError onError = new TorqueSQLExec.OnError();
sqlExec.setProject(project);
onError.setValue("continue");
sqlExec.setAutocommit(true);
sqlExec.setDriver(_jcd.getDriver());
sqlExec.setOnerror(onError);
sqlExec.setUserid(_jcd.getUserName());
sqlExec.setPassword(_jcd.getPassWord() == null ? "" : _jcd.getPassWord());
sqlExec.setUrl(getDBManipulationUrl());
sqlExec.setSrcDir(outputDir.getAbsolutePath());
sqlExec.setSqlDbMap(SQL_DB_MAP_NAME);
sqlExec.execute();
deleteDir(outputDir);
}
catch (Exception ex)
{
// clean-up
if (outputDir != null)
{
deleteDir(outputDir);
}
throw new PlatformException(ex);
}
} | java | public void initDB() throws PlatformException
{
if (_initScripts.isEmpty())
{
createInitScripts();
}
Project project = new Project();
TorqueSQLTask sqlTask = new TorqueSQLTask();
File outputDir = null;
try
{
outputDir = new File(getWorkDir(), "sql");
outputDir.mkdir();
writeCompressedTexts(outputDir, _initScripts);
project.setBasedir(outputDir.getAbsolutePath());
// executing the generated sql, but this time with a torque task
TorqueSQLExec sqlExec = new TorqueSQLExec();
TorqueSQLExec.OnError onError = new TorqueSQLExec.OnError();
sqlExec.setProject(project);
onError.setValue("continue");
sqlExec.setAutocommit(true);
sqlExec.setDriver(_jcd.getDriver());
sqlExec.setOnerror(onError);
sqlExec.setUserid(_jcd.getUserName());
sqlExec.setPassword(_jcd.getPassWord() == null ? "" : _jcd.getPassWord());
sqlExec.setUrl(getDBManipulationUrl());
sqlExec.setSrcDir(outputDir.getAbsolutePath());
sqlExec.setSqlDbMap(SQL_DB_MAP_NAME);
sqlExec.execute();
deleteDir(outputDir);
}
catch (Exception ex)
{
// clean-up
if (outputDir != null)
{
deleteDir(outputDir);
}
throw new PlatformException(ex);
}
} | [
"public",
"void",
"initDB",
"(",
")",
"throws",
"PlatformException",
"{",
"if",
"(",
"_initScripts",
".",
"isEmpty",
"(",
")",
")",
"{",
"createInitScripts",
"(",
")",
";",
"}",
"Project",
"project",
"=",
"new",
"Project",
"(",
")",
";",
"TorqueSQLTask",
"sqlTask",
"=",
"new",
"TorqueSQLTask",
"(",
")",
";",
"File",
"outputDir",
"=",
"null",
";",
"try",
"{",
"outputDir",
"=",
"new",
"File",
"(",
"getWorkDir",
"(",
")",
",",
"\"sql\"",
")",
";",
"outputDir",
".",
"mkdir",
"(",
")",
";",
"writeCompressedTexts",
"(",
"outputDir",
",",
"_initScripts",
")",
";",
"project",
".",
"setBasedir",
"(",
"outputDir",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"// executing the generated sql, but this time with a torque task \r",
"TorqueSQLExec",
"sqlExec",
"=",
"new",
"TorqueSQLExec",
"(",
")",
";",
"TorqueSQLExec",
".",
"OnError",
"onError",
"=",
"new",
"TorqueSQLExec",
".",
"OnError",
"(",
")",
";",
"sqlExec",
".",
"setProject",
"(",
"project",
")",
";",
"onError",
".",
"setValue",
"(",
"\"continue\"",
")",
";",
"sqlExec",
".",
"setAutocommit",
"(",
"true",
")",
";",
"sqlExec",
".",
"setDriver",
"(",
"_jcd",
".",
"getDriver",
"(",
")",
")",
";",
"sqlExec",
".",
"setOnerror",
"(",
"onError",
")",
";",
"sqlExec",
".",
"setUserid",
"(",
"_jcd",
".",
"getUserName",
"(",
")",
")",
";",
"sqlExec",
".",
"setPassword",
"(",
"_jcd",
".",
"getPassWord",
"(",
")",
"==",
"null",
"?",
"\"\"",
":",
"_jcd",
".",
"getPassWord",
"(",
")",
")",
";",
"sqlExec",
".",
"setUrl",
"(",
"getDBManipulationUrl",
"(",
")",
")",
";",
"sqlExec",
".",
"setSrcDir",
"(",
"outputDir",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"sqlExec",
".",
"setSqlDbMap",
"(",
"SQL_DB_MAP_NAME",
")",
";",
"sqlExec",
".",
"execute",
"(",
")",
";",
"deleteDir",
"(",
"outputDir",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"// clean-up\r",
"if",
"(",
"outputDir",
"!=",
"null",
")",
"{",
"deleteDir",
"(",
"outputDir",
")",
";",
"}",
"throw",
"new",
"PlatformException",
"(",
"ex",
")",
";",
"}",
"}"
] | Creates the tables according to the schema files.
@throws PlatformException If some error occurred | [
"Creates",
"the",
"tables",
"according",
"to",
"the",
"schema",
"files",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java#L388-L435 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java | TorqueDBHandling.getDBManipulationUrl | protected String getDBManipulationUrl()
{
JdbcConnectionDescriptor jcd = getConnection();
return jcd.getProtocol()+":"+jcd.getSubProtocol()+":"+jcd.getDbAlias();
} | java | protected String getDBManipulationUrl()
{
JdbcConnectionDescriptor jcd = getConnection();
return jcd.getProtocol()+":"+jcd.getSubProtocol()+":"+jcd.getDbAlias();
} | [
"protected",
"String",
"getDBManipulationUrl",
"(",
")",
"{",
"JdbcConnectionDescriptor",
"jcd",
"=",
"getConnection",
"(",
")",
";",
"return",
"jcd",
".",
"getProtocol",
"(",
")",
"+",
"\":\"",
"+",
"jcd",
".",
"getSubProtocol",
"(",
")",
"+",
"\":\"",
"+",
"jcd",
".",
"getDbAlias",
"(",
")",
";",
"}"
] | Template-and-Hook method for generating the url required by the jdbc driver
to allow for modifying an existing database. | [
"Template",
"-",
"and",
"-",
"Hook",
"method",
"for",
"generating",
"the",
"url",
"required",
"by",
"the",
"jdbc",
"driver",
"to",
"allow",
"for",
"modifying",
"an",
"existing",
"database",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java#L516-L521 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java | TorqueDBHandling.readStreamCompressed | private byte[] readStreamCompressed(InputStream stream) throws IOException
{
ByteArrayOutputStream bao = new ByteArrayOutputStream();
GZIPOutputStream gos = new GZIPOutputStream(bao);
OutputStreamWriter output = new OutputStreamWriter(gos);
BufferedReader input = new BufferedReader(new InputStreamReader(stream));
String line;
while ((line = input.readLine()) != null)
{
output.write(line);
output.write('\n');
}
input.close();
stream.close();
output.close();
gos.close();
bao.close();
return bao.toByteArray();
} | java | private byte[] readStreamCompressed(InputStream stream) throws IOException
{
ByteArrayOutputStream bao = new ByteArrayOutputStream();
GZIPOutputStream gos = new GZIPOutputStream(bao);
OutputStreamWriter output = new OutputStreamWriter(gos);
BufferedReader input = new BufferedReader(new InputStreamReader(stream));
String line;
while ((line = input.readLine()) != null)
{
output.write(line);
output.write('\n');
}
input.close();
stream.close();
output.close();
gos.close();
bao.close();
return bao.toByteArray();
} | [
"private",
"byte",
"[",
"]",
"readStreamCompressed",
"(",
"InputStream",
"stream",
")",
"throws",
"IOException",
"{",
"ByteArrayOutputStream",
"bao",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"GZIPOutputStream",
"gos",
"=",
"new",
"GZIPOutputStream",
"(",
"bao",
")",
";",
"OutputStreamWriter",
"output",
"=",
"new",
"OutputStreamWriter",
"(",
"gos",
")",
";",
"BufferedReader",
"input",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"stream",
")",
")",
";",
"String",
"line",
";",
"while",
"(",
"(",
"line",
"=",
"input",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"output",
".",
"write",
"(",
"line",
")",
";",
"output",
".",
"write",
"(",
"'",
"'",
")",
";",
"}",
"input",
".",
"close",
"(",
")",
";",
"stream",
".",
"close",
"(",
")",
";",
"output",
".",
"close",
"(",
")",
";",
"gos",
".",
"close",
"(",
")",
";",
"bao",
".",
"close",
"(",
")",
";",
"return",
"bao",
".",
"toByteArray",
"(",
")",
";",
"}"
] | Reads the given text stream and compressed its content.
@param stream The input stream
@return A byte array containing the GZIP-compressed content of the stream
@throws IOException If an error ocurred | [
"Reads",
"the",
"given",
"text",
"stream",
"and",
"compressed",
"its",
"content",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java#L542-L561 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java | TorqueDBHandling.readTextsCompressed | private void readTextsCompressed(File dir, HashMap results) throws IOException
{
if (dir.exists() && dir.isDirectory())
{
File[] files = dir.listFiles();
for (int idx = 0; idx < files.length; idx++)
{
if (files[idx].isDirectory())
{
continue;
}
results.put(files[idx].getName(), readTextCompressed(files[idx]));
}
}
} | java | private void readTextsCompressed(File dir, HashMap results) throws IOException
{
if (dir.exists() && dir.isDirectory())
{
File[] files = dir.listFiles();
for (int idx = 0; idx < files.length; idx++)
{
if (files[idx].isDirectory())
{
continue;
}
results.put(files[idx].getName(), readTextCompressed(files[idx]));
}
}
} | [
"private",
"void",
"readTextsCompressed",
"(",
"File",
"dir",
",",
"HashMap",
"results",
")",
"throws",
"IOException",
"{",
"if",
"(",
"dir",
".",
"exists",
"(",
")",
"&&",
"dir",
".",
"isDirectory",
"(",
")",
")",
"{",
"File",
"[",
"]",
"files",
"=",
"dir",
".",
"listFiles",
"(",
")",
";",
"for",
"(",
"int",
"idx",
"=",
"0",
";",
"idx",
"<",
"files",
".",
"length",
";",
"idx",
"++",
")",
"{",
"if",
"(",
"files",
"[",
"idx",
"]",
".",
"isDirectory",
"(",
")",
")",
"{",
"continue",
";",
"}",
"results",
".",
"put",
"(",
"files",
"[",
"idx",
"]",
".",
"getName",
"(",
")",
",",
"readTextCompressed",
"(",
"files",
"[",
"idx",
"]",
")",
")",
";",
"}",
"}",
"}"
] | Reads the text files in the given directory and puts their content
in the given map after compressing it. Note that this method does not
traverse recursivly into sub-directories.
@param dir The directory to process
@param results Map that will receive the contents (indexed by the relative filenames)
@throws IOException If an error ocurred | [
"Reads",
"the",
"text",
"files",
"in",
"the",
"given",
"directory",
"and",
"puts",
"their",
"content",
"in",
"the",
"given",
"map",
"after",
"compressing",
"it",
".",
"Note",
"that",
"this",
"method",
"does",
"not",
"traverse",
"recursivly",
"into",
"sub",
"-",
"directories",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java#L572-L587 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java | TorqueDBHandling.writeCompressedText | private void writeCompressedText(File file, byte[] compressedContent) throws IOException
{
ByteArrayInputStream bais = new ByteArrayInputStream(compressedContent);
GZIPInputStream gis = new GZIPInputStream(bais);
BufferedReader input = new BufferedReader(new InputStreamReader(gis));
BufferedWriter output = new BufferedWriter(new FileWriter(file));
String line;
while ((line = input.readLine()) != null)
{
output.write(line);
output.write('\n');
}
input.close();
gis.close();
bais.close();
output.close();
} | java | private void writeCompressedText(File file, byte[] compressedContent) throws IOException
{
ByteArrayInputStream bais = new ByteArrayInputStream(compressedContent);
GZIPInputStream gis = new GZIPInputStream(bais);
BufferedReader input = new BufferedReader(new InputStreamReader(gis));
BufferedWriter output = new BufferedWriter(new FileWriter(file));
String line;
while ((line = input.readLine()) != null)
{
output.write(line);
output.write('\n');
}
input.close();
gis.close();
bais.close();
output.close();
} | [
"private",
"void",
"writeCompressedText",
"(",
"File",
"file",
",",
"byte",
"[",
"]",
"compressedContent",
")",
"throws",
"IOException",
"{",
"ByteArrayInputStream",
"bais",
"=",
"new",
"ByteArrayInputStream",
"(",
"compressedContent",
")",
";",
"GZIPInputStream",
"gis",
"=",
"new",
"GZIPInputStream",
"(",
"bais",
")",
";",
"BufferedReader",
"input",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"gis",
")",
")",
";",
"BufferedWriter",
"output",
"=",
"new",
"BufferedWriter",
"(",
"new",
"FileWriter",
"(",
"file",
")",
")",
";",
"String",
"line",
";",
"while",
"(",
"(",
"line",
"=",
"input",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"output",
".",
"write",
"(",
"line",
")",
";",
"output",
".",
"write",
"(",
"'",
"'",
")",
";",
"}",
"input",
".",
"close",
"(",
")",
";",
"gis",
".",
"close",
"(",
")",
";",
"bais",
".",
"close",
"(",
")",
";",
"output",
".",
"close",
"(",
")",
";",
"}"
] | Uncompresses the given textual content and writes it to the given file.
@param file The file to write to
@param compressedContent The content
@throws IOException If an error occurred | [
"Uncompresses",
"the",
"given",
"textual",
"content",
"and",
"writes",
"it",
"to",
"the",
"given",
"file",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java#L596-L613 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java | TorqueDBHandling.writeCompressedTexts | private void writeCompressedTexts(File dir, HashMap contents) throws IOException
{
String filename;
for (Iterator nameIt = contents.keySet().iterator(); nameIt.hasNext();)
{
filename = (String)nameIt.next();
writeCompressedText(new File(dir, filename), (byte[])contents.get(filename));
}
} | java | private void writeCompressedTexts(File dir, HashMap contents) throws IOException
{
String filename;
for (Iterator nameIt = contents.keySet().iterator(); nameIt.hasNext();)
{
filename = (String)nameIt.next();
writeCompressedText(new File(dir, filename), (byte[])contents.get(filename));
}
} | [
"private",
"void",
"writeCompressedTexts",
"(",
"File",
"dir",
",",
"HashMap",
"contents",
")",
"throws",
"IOException",
"{",
"String",
"filename",
";",
"for",
"(",
"Iterator",
"nameIt",
"=",
"contents",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"nameIt",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"filename",
"=",
"(",
"String",
")",
"nameIt",
".",
"next",
"(",
")",
";",
"writeCompressedText",
"(",
"new",
"File",
"(",
"dir",
",",
"filename",
")",
",",
"(",
"byte",
"[",
"]",
")",
"contents",
".",
"get",
"(",
"filename",
")",
")",
";",
"}",
"}"
] | Uncompresses the textual contents in the given map and and writes them to the files
denoted by the keys of the map.
@param dir The base directory into which the files will be written
@param contents The map containing the contents indexed by the filename
@throws IOException If an error occurred | [
"Uncompresses",
"the",
"textual",
"contents",
"in",
"the",
"given",
"map",
"and",
"and",
"writes",
"them",
"to",
"the",
"files",
"denoted",
"by",
"the",
"keys",
"of",
"the",
"map",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java#L623-L632 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java | TorqueDBHandling.setWorkDir | public void setWorkDir(String dir) throws IOException
{
File workDir = new File(dir);
if (!workDir.exists() || !workDir.canWrite() || !workDir.canRead())
{
throw new IOException("Cannot access directory "+dir);
}
_workDir = workDir;
} | java | public void setWorkDir(String dir) throws IOException
{
File workDir = new File(dir);
if (!workDir.exists() || !workDir.canWrite() || !workDir.canRead())
{
throw new IOException("Cannot access directory "+dir);
}
_workDir = workDir;
} | [
"public",
"void",
"setWorkDir",
"(",
"String",
"dir",
")",
"throws",
"IOException",
"{",
"File",
"workDir",
"=",
"new",
"File",
"(",
"dir",
")",
";",
"if",
"(",
"!",
"workDir",
".",
"exists",
"(",
")",
"||",
"!",
"workDir",
".",
"canWrite",
"(",
")",
"||",
"!",
"workDir",
".",
"canRead",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Cannot access directory \"",
"+",
"dir",
")",
";",
"}",
"_workDir",
"=",
"workDir",
";",
"}"
] | Sets the working directory.
@param dir The directory
@throws IOException If the directory does not exist or cannot be written/read | [
"Sets",
"the",
"working",
"directory",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java#L640-L649 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java | TorqueDBHandling.getWorkDir | private File getWorkDir() throws IOException
{
if (_workDir == null)
{
File dummy = File.createTempFile("dummy", ".log");
String workDir = dummy.getPath().substring(0, dummy.getPath().lastIndexOf(File.separatorChar));
if ((workDir == null) || (workDir.length() == 0))
{
workDir = ".";
}
dummy.delete();
_workDir = new File(workDir);
}
return _workDir;
} | java | private File getWorkDir() throws IOException
{
if (_workDir == null)
{
File dummy = File.createTempFile("dummy", ".log");
String workDir = dummy.getPath().substring(0, dummy.getPath().lastIndexOf(File.separatorChar));
if ((workDir == null) || (workDir.length() == 0))
{
workDir = ".";
}
dummy.delete();
_workDir = new File(workDir);
}
return _workDir;
} | [
"private",
"File",
"getWorkDir",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"_workDir",
"==",
"null",
")",
"{",
"File",
"dummy",
"=",
"File",
".",
"createTempFile",
"(",
"\"dummy\"",
",",
"\".log\"",
")",
";",
"String",
"workDir",
"=",
"dummy",
".",
"getPath",
"(",
")",
".",
"substring",
"(",
"0",
",",
"dummy",
".",
"getPath",
"(",
")",
".",
"lastIndexOf",
"(",
"File",
".",
"separatorChar",
")",
")",
";",
"if",
"(",
"(",
"workDir",
"==",
"null",
")",
"||",
"(",
"workDir",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"{",
"workDir",
"=",
"\".\"",
";",
"}",
"dummy",
".",
"delete",
"(",
")",
";",
"_workDir",
"=",
"new",
"File",
"(",
"workDir",
")",
";",
"}",
"return",
"_workDir",
";",
"}"
] | Returns the temporary directory used by java.
@return The temporary directory
@throws IOException If an io error occurred | [
"Returns",
"the",
"temporary",
"directory",
"used",
"by",
"java",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java#L657-L672 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java | TorqueDBHandling.deleteDir | private void deleteDir(File dir)
{
if (dir.exists() && dir.isDirectory())
{
File[] files = dir.listFiles();
for (int idx = 0; idx < files.length; idx++)
{
if (!files[idx].exists())
{
continue;
}
if (files[idx].isDirectory())
{
deleteDir(files[idx]);
}
else
{
files[idx].delete();
}
}
dir.delete();
}
} | java | private void deleteDir(File dir)
{
if (dir.exists() && dir.isDirectory())
{
File[] files = dir.listFiles();
for (int idx = 0; idx < files.length; idx++)
{
if (!files[idx].exists())
{
continue;
}
if (files[idx].isDirectory())
{
deleteDir(files[idx]);
}
else
{
files[idx].delete();
}
}
dir.delete();
}
} | [
"private",
"void",
"deleteDir",
"(",
"File",
"dir",
")",
"{",
"if",
"(",
"dir",
".",
"exists",
"(",
")",
"&&",
"dir",
".",
"isDirectory",
"(",
")",
")",
"{",
"File",
"[",
"]",
"files",
"=",
"dir",
".",
"listFiles",
"(",
")",
";",
"for",
"(",
"int",
"idx",
"=",
"0",
";",
"idx",
"<",
"files",
".",
"length",
";",
"idx",
"++",
")",
"{",
"if",
"(",
"!",
"files",
"[",
"idx",
"]",
".",
"exists",
"(",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"files",
"[",
"idx",
"]",
".",
"isDirectory",
"(",
")",
")",
"{",
"deleteDir",
"(",
"files",
"[",
"idx",
"]",
")",
";",
"}",
"else",
"{",
"files",
"[",
"idx",
"]",
".",
"delete",
"(",
")",
";",
"}",
"}",
"dir",
".",
"delete",
"(",
")",
";",
"}",
"}"
] | Little helper function that recursivly deletes a directory.
@param dir The directory | [
"Little",
"helper",
"function",
"that",
"recursivly",
"deletes",
"a",
"directory",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/dbhandling/TorqueDBHandling.java#L679-L702 | train |
Axway/Grapes | server/src/main/java/org/axway/grapes/server/webapp/resources/Sequoia.java | Sequoia.getModuleGraph | @GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/graph/{name}/{version}")
public Response getModuleGraph(@PathParam("name") final String moduleName,
@PathParam("version") final String moduleVersion,
@Context final UriInfo uriInfo){
LOG.info("Dependency Checker got a get module graph export request.");
if(moduleName == null || moduleVersion == null){
return Response.serverError().status(HttpStatus.NOT_ACCEPTABLE_406).build();
}
final FiltersHolder filters = new FiltersHolder();
filters.init(uriInfo.getQueryParameters());
final String moduleId = DbModule.generateID(moduleName, moduleVersion);
final AbstractGraph moduleGraph = getGraphsHandler(filters).getModuleGraph(moduleId);
return Response.ok(moduleGraph).build();
} | java | @GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/graph/{name}/{version}")
public Response getModuleGraph(@PathParam("name") final String moduleName,
@PathParam("version") final String moduleVersion,
@Context final UriInfo uriInfo){
LOG.info("Dependency Checker got a get module graph export request.");
if(moduleName == null || moduleVersion == null){
return Response.serverError().status(HttpStatus.NOT_ACCEPTABLE_406).build();
}
final FiltersHolder filters = new FiltersHolder();
filters.init(uriInfo.getQueryParameters());
final String moduleId = DbModule.generateID(moduleName, moduleVersion);
final AbstractGraph moduleGraph = getGraphsHandler(filters).getModuleGraph(moduleId);
return Response.ok(moduleGraph).build();
} | [
"@",
"GET",
"@",
"Produces",
"(",
"MediaType",
".",
"APPLICATION_JSON",
")",
"@",
"Path",
"(",
"\"/graph/{name}/{version}\"",
")",
"public",
"Response",
"getModuleGraph",
"(",
"@",
"PathParam",
"(",
"\"name\"",
")",
"final",
"String",
"moduleName",
",",
"@",
"PathParam",
"(",
"\"version\"",
")",
"final",
"String",
"moduleVersion",
",",
"@",
"Context",
"final",
"UriInfo",
"uriInfo",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Dependency Checker got a get module graph export request.\"",
")",
";",
"if",
"(",
"moduleName",
"==",
"null",
"||",
"moduleVersion",
"==",
"null",
")",
"{",
"return",
"Response",
".",
"serverError",
"(",
")",
".",
"status",
"(",
"HttpStatus",
".",
"NOT_ACCEPTABLE_406",
")",
".",
"build",
"(",
")",
";",
"}",
"final",
"FiltersHolder",
"filters",
"=",
"new",
"FiltersHolder",
"(",
")",
";",
"filters",
".",
"init",
"(",
"uriInfo",
".",
"getQueryParameters",
"(",
")",
")",
";",
"final",
"String",
"moduleId",
"=",
"DbModule",
".",
"generateID",
"(",
"moduleName",
",",
"moduleVersion",
")",
";",
"final",
"AbstractGraph",
"moduleGraph",
"=",
"getGraphsHandler",
"(",
"filters",
")",
".",
"getModuleGraph",
"(",
"moduleId",
")",
";",
"return",
"Response",
".",
"ok",
"(",
"moduleGraph",
")",
".",
"build",
"(",
")",
";",
"}"
] | Perform a module dependency graph of the target and return the graph as a JSON
@param moduleName
@param moduleVersion
@param uriInfo
@return Response | [
"Perform",
"a",
"module",
"dependency",
"graph",
"of",
"the",
"target",
"and",
"return",
"the",
"graph",
"as",
"a",
"JSON"
] | ce9cc73d85f83eaa5fbc991abb593915a8c8374e | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/webapp/resources/Sequoia.java#L49-L69 | train |
geomajas/geomajas-project-server | plugin/layer-geotools/geotools/src/main/java/org/geomajas/layer/geotools/GeoToolsLayer.java | GeoToolsLayer.update | void update(Object feature) throws LayerException {
SimpleFeatureSource source = getFeatureSource();
if (source instanceof SimpleFeatureStore) {
SimpleFeatureStore store = (SimpleFeatureStore) source;
String featureId = getFeatureModel().getId(feature);
Filter filter = filterService.createFidFilter(new String[] { featureId });
transactionSynchronization.synchTransaction(store);
List<Name> names = new ArrayList<Name>();
Map<String, Attribute> attrMap = getFeatureModel().getAttributes(feature);
List<Object> values = new ArrayList<Object>();
for (Map.Entry<String, Attribute> entry : attrMap.entrySet()) {
String name = entry.getKey();
names.add(store.getSchema().getDescriptor(name).getName());
values.add(entry.getValue().getValue());
}
try {
store.modifyFeatures(names.toArray(new Name[names.size()]), values.toArray(), filter);
store.modifyFeatures(store.getSchema().getGeometryDescriptor().getName(), getFeatureModel()
.getGeometry(feature), filter);
log.debug("Updated feature {} in {}", featureId, getFeatureSourceName());
} catch (IOException ioe) {
featureModelUsable = false;
throw new LayerException(ioe, ExceptionCode.LAYER_MODEL_IO_EXCEPTION);
}
} else {
log.error("Don't know how to create or update " + getFeatureSourceName() + ", class "
+ source.getClass().getName() + " does not implement SimpleFeatureStore");
throw new LayerException(ExceptionCode.CREATE_OR_UPDATE_NOT_IMPLEMENTED, getFeatureSourceName(), source
.getClass().getName());
}
} | java | void update(Object feature) throws LayerException {
SimpleFeatureSource source = getFeatureSource();
if (source instanceof SimpleFeatureStore) {
SimpleFeatureStore store = (SimpleFeatureStore) source;
String featureId = getFeatureModel().getId(feature);
Filter filter = filterService.createFidFilter(new String[] { featureId });
transactionSynchronization.synchTransaction(store);
List<Name> names = new ArrayList<Name>();
Map<String, Attribute> attrMap = getFeatureModel().getAttributes(feature);
List<Object> values = new ArrayList<Object>();
for (Map.Entry<String, Attribute> entry : attrMap.entrySet()) {
String name = entry.getKey();
names.add(store.getSchema().getDescriptor(name).getName());
values.add(entry.getValue().getValue());
}
try {
store.modifyFeatures(names.toArray(new Name[names.size()]), values.toArray(), filter);
store.modifyFeatures(store.getSchema().getGeometryDescriptor().getName(), getFeatureModel()
.getGeometry(feature), filter);
log.debug("Updated feature {} in {}", featureId, getFeatureSourceName());
} catch (IOException ioe) {
featureModelUsable = false;
throw new LayerException(ioe, ExceptionCode.LAYER_MODEL_IO_EXCEPTION);
}
} else {
log.error("Don't know how to create or update " + getFeatureSourceName() + ", class "
+ source.getClass().getName() + " does not implement SimpleFeatureStore");
throw new LayerException(ExceptionCode.CREATE_OR_UPDATE_NOT_IMPLEMENTED, getFeatureSourceName(), source
.getClass().getName());
}
} | [
"void",
"update",
"(",
"Object",
"feature",
")",
"throws",
"LayerException",
"{",
"SimpleFeatureSource",
"source",
"=",
"getFeatureSource",
"(",
")",
";",
"if",
"(",
"source",
"instanceof",
"SimpleFeatureStore",
")",
"{",
"SimpleFeatureStore",
"store",
"=",
"(",
"SimpleFeatureStore",
")",
"source",
";",
"String",
"featureId",
"=",
"getFeatureModel",
"(",
")",
".",
"getId",
"(",
"feature",
")",
";",
"Filter",
"filter",
"=",
"filterService",
".",
"createFidFilter",
"(",
"new",
"String",
"[",
"]",
"{",
"featureId",
"}",
")",
";",
"transactionSynchronization",
".",
"synchTransaction",
"(",
"store",
")",
";",
"List",
"<",
"Name",
">",
"names",
"=",
"new",
"ArrayList",
"<",
"Name",
">",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Attribute",
">",
"attrMap",
"=",
"getFeatureModel",
"(",
")",
".",
"getAttributes",
"(",
"feature",
")",
";",
"List",
"<",
"Object",
">",
"values",
"=",
"new",
"ArrayList",
"<",
"Object",
">",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Attribute",
">",
"entry",
":",
"attrMap",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"name",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"names",
".",
"add",
"(",
"store",
".",
"getSchema",
"(",
")",
".",
"getDescriptor",
"(",
"name",
")",
".",
"getName",
"(",
")",
")",
";",
"values",
".",
"add",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"getValue",
"(",
")",
")",
";",
"}",
"try",
"{",
"store",
".",
"modifyFeatures",
"(",
"names",
".",
"toArray",
"(",
"new",
"Name",
"[",
"names",
".",
"size",
"(",
")",
"]",
")",
",",
"values",
".",
"toArray",
"(",
")",
",",
"filter",
")",
";",
"store",
".",
"modifyFeatures",
"(",
"store",
".",
"getSchema",
"(",
")",
".",
"getGeometryDescriptor",
"(",
")",
".",
"getName",
"(",
")",
",",
"getFeatureModel",
"(",
")",
".",
"getGeometry",
"(",
"feature",
")",
",",
"filter",
")",
";",
"log",
".",
"debug",
"(",
"\"Updated feature {} in {}\"",
",",
"featureId",
",",
"getFeatureSourceName",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"featureModelUsable",
"=",
"false",
";",
"throw",
"new",
"LayerException",
"(",
"ioe",
",",
"ExceptionCode",
".",
"LAYER_MODEL_IO_EXCEPTION",
")",
";",
"}",
"}",
"else",
"{",
"log",
".",
"error",
"(",
"\"Don't know how to create or update \"",
"+",
"getFeatureSourceName",
"(",
")",
"+",
"\", class \"",
"+",
"source",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\" does not implement SimpleFeatureStore\"",
")",
";",
"throw",
"new",
"LayerException",
"(",
"ExceptionCode",
".",
"CREATE_OR_UPDATE_NOT_IMPLEMENTED",
",",
"getFeatureSourceName",
"(",
")",
",",
"source",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"}"
] | Update an existing feature. Made package private for testing purposes.
@param feature feature to update
@throws LayerException oops | [
"Update",
"an",
"existing",
"feature",
".",
"Made",
"package",
"private",
"for",
"testing",
"purposes",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/layer-geotools/geotools/src/main/java/org/geomajas/layer/geotools/GeoToolsLayer.java#L347-L378 | train |
foundation-runtime/logging | logging-log4j/src/main/java/com/cisco/oss/foundation/logging/converters/FoundationLoggingPatternConverter.java | FoundationLoggingPatternConverter.format | @Override
public void format(final StringBuffer sbuf, final LoggingEvent event) {
for (int i = 0; i < patternConverters.length; i++) {
final int startField = sbuf.length();
patternConverters[i].format(event, sbuf);
patternFields[i].format(startField, sbuf);
}
} | java | @Override
public void format(final StringBuffer sbuf, final LoggingEvent event) {
for (int i = 0; i < patternConverters.length; i++) {
final int startField = sbuf.length();
patternConverters[i].format(event, sbuf);
patternFields[i].format(startField, sbuf);
}
} | [
"@",
"Override",
"public",
"void",
"format",
"(",
"final",
"StringBuffer",
"sbuf",
",",
"final",
"LoggingEvent",
"event",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"patternConverters",
".",
"length",
";",
"i",
"++",
")",
"{",
"final",
"int",
"startField",
"=",
"sbuf",
".",
"length",
"(",
")",
";",
"patternConverters",
"[",
"i",
"]",
".",
"format",
"(",
"event",
",",
"sbuf",
")",
";",
"patternFields",
"[",
"i",
"]",
".",
"format",
"(",
"startField",
",",
"sbuf",
")",
";",
"}",
"}"
] | Format event to string buffer.
@param sbuf
string buffer to receive formatted event, may not be null.
@param event
event to format, may not be null. | [
"Format",
"event",
"to",
"string",
"buffer",
"."
] | cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6 | https://github.com/foundation-runtime/logging/blob/cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6/logging-log4j/src/main/java/com/cisco/oss/foundation/logging/converters/FoundationLoggingPatternConverter.java#L140-L147 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/ant/RepositoryDataTask.java | RepositoryDataTask.readSingleSchemaFile | private Database readSingleSchemaFile(DatabaseIO reader, File schemaFile)
{
Database model = null;
if (!schemaFile.isFile())
{
log("Path "+schemaFile.getAbsolutePath()+" does not denote a schema file", Project.MSG_ERR);
}
else if (!schemaFile.canRead())
{
log("Could not read schema file "+schemaFile.getAbsolutePath(), Project.MSG_ERR);
}
else
{
try
{
model = reader.read(schemaFile);
log("Read schema file "+schemaFile.getAbsolutePath(), Project.MSG_INFO);
}
catch (Exception ex)
{
throw new BuildException("Could not read schema file "+schemaFile.getAbsolutePath()+": "+ex.getLocalizedMessage(), ex);
}
}
return model;
} | java | private Database readSingleSchemaFile(DatabaseIO reader, File schemaFile)
{
Database model = null;
if (!schemaFile.isFile())
{
log("Path "+schemaFile.getAbsolutePath()+" does not denote a schema file", Project.MSG_ERR);
}
else if (!schemaFile.canRead())
{
log("Could not read schema file "+schemaFile.getAbsolutePath(), Project.MSG_ERR);
}
else
{
try
{
model = reader.read(schemaFile);
log("Read schema file "+schemaFile.getAbsolutePath(), Project.MSG_INFO);
}
catch (Exception ex)
{
throw new BuildException("Could not read schema file "+schemaFile.getAbsolutePath()+": "+ex.getLocalizedMessage(), ex);
}
}
return model;
} | [
"private",
"Database",
"readSingleSchemaFile",
"(",
"DatabaseIO",
"reader",
",",
"File",
"schemaFile",
")",
"{",
"Database",
"model",
"=",
"null",
";",
"if",
"(",
"!",
"schemaFile",
".",
"isFile",
"(",
")",
")",
"{",
"log",
"(",
"\"Path \"",
"+",
"schemaFile",
".",
"getAbsolutePath",
"(",
")",
"+",
"\" does not denote a schema file\"",
",",
"Project",
".",
"MSG_ERR",
")",
";",
"}",
"else",
"if",
"(",
"!",
"schemaFile",
".",
"canRead",
"(",
")",
")",
"{",
"log",
"(",
"\"Could not read schema file \"",
"+",
"schemaFile",
".",
"getAbsolutePath",
"(",
")",
",",
"Project",
".",
"MSG_ERR",
")",
";",
"}",
"else",
"{",
"try",
"{",
"model",
"=",
"reader",
".",
"read",
"(",
"schemaFile",
")",
";",
"log",
"(",
"\"Read schema file \"",
"+",
"schemaFile",
".",
"getAbsolutePath",
"(",
")",
",",
"Project",
".",
"MSG_INFO",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Could not read schema file \"",
"+",
"schemaFile",
".",
"getAbsolutePath",
"(",
")",
"+",
"\": \"",
"+",
"ex",
".",
"getLocalizedMessage",
"(",
")",
",",
"ex",
")",
";",
"}",
"}",
"return",
"model",
";",
"}"
] | Reads a single schema file.
@param reader The schema reader
@param schemaFile The schema file
@return The model | [
"Reads",
"a",
"single",
"schema",
"file",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/ant/RepositoryDataTask.java#L238-L263 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/ant/RepositoryDataTask.java | RepositoryDataTask.initOJB | private MetadataManager initOJB()
{
try
{
if (_ojbPropertiesFile == null)
{
_ojbPropertiesFile = new File("OJB.properties");
if (!_ojbPropertiesFile.exists())
{
throw new BuildException("Could not find OJB.properties, please specify it via the ojbpropertiesfile attribute");
}
}
else
{
if (!_ojbPropertiesFile.exists())
{
throw new BuildException("Could not load the specified OJB properties file "+_ojbPropertiesFile);
}
log("Using properties file "+_ojbPropertiesFile.getAbsolutePath(), Project.MSG_INFO);
System.setProperty("OJB.properties", _ojbPropertiesFile.getAbsolutePath());
}
MetadataManager metadataManager = MetadataManager.getInstance();
RepositoryPersistor persistor = new RepositoryPersistor();
if (_repositoryFile != null)
{
if (!_repositoryFile.exists())
{
throw new BuildException("Could not load the specified repository file "+_repositoryFile);
}
log("Loading repository file "+_repositoryFile.getAbsolutePath(), Project.MSG_INFO);
// this will load the info from the specified repository file
// and merge it with the existing info (if it has been loaded)
metadataManager.mergeConnectionRepository(persistor.readConnectionRepository(_repositoryFile.getAbsolutePath()));
metadataManager.mergeDescriptorRepository(persistor.readDescriptorRepository(_repositoryFile.getAbsolutePath()));
}
else if (metadataManager.connectionRepository().getAllDescriptor().isEmpty() &&
metadataManager.getGlobalRepository().getDescriptorTable().isEmpty())
{
// Seems nothing was loaded, probably because we're not starting in the directory
// that the properties file is in, and the repository file path is relative
// So lets try to resolve this path and load the repository info manually
Properties props = new Properties();
props.load(new FileInputStream(_ojbPropertiesFile));
String repositoryPath = props.getProperty("repositoryFile", "repository.xml");
File repositoryFile = new File(repositoryPath);
if (!repositoryFile.exists())
{
repositoryFile = new File(_ojbPropertiesFile.getParentFile(), repositoryPath);
}
metadataManager.mergeConnectionRepository(persistor.readConnectionRepository(repositoryFile.getAbsolutePath()));
metadataManager.mergeDescriptorRepository(persistor.readDescriptorRepository(repositoryFile.getAbsolutePath()));
}
// we might have to determine the default pb key ourselves
if (metadataManager.getDefaultPBKey() == null)
{
for (Iterator it = metadataManager.connectionRepository().getAllDescriptor().iterator(); it.hasNext();)
{
JdbcConnectionDescriptor descriptor = (JdbcConnectionDescriptor)it.next();
if (descriptor.isDefaultConnection())
{
metadataManager.setDefaultPBKey(new PBKey(descriptor.getJcdAlias(), descriptor.getUserName(), descriptor.getPassWord()));
break;
}
}
}
return metadataManager;
}
catch (Exception ex)
{
if (ex instanceof BuildException)
{
throw (BuildException)ex;
}
else
{
throw new BuildException(ex);
}
}
} | java | private MetadataManager initOJB()
{
try
{
if (_ojbPropertiesFile == null)
{
_ojbPropertiesFile = new File("OJB.properties");
if (!_ojbPropertiesFile.exists())
{
throw new BuildException("Could not find OJB.properties, please specify it via the ojbpropertiesfile attribute");
}
}
else
{
if (!_ojbPropertiesFile.exists())
{
throw new BuildException("Could not load the specified OJB properties file "+_ojbPropertiesFile);
}
log("Using properties file "+_ojbPropertiesFile.getAbsolutePath(), Project.MSG_INFO);
System.setProperty("OJB.properties", _ojbPropertiesFile.getAbsolutePath());
}
MetadataManager metadataManager = MetadataManager.getInstance();
RepositoryPersistor persistor = new RepositoryPersistor();
if (_repositoryFile != null)
{
if (!_repositoryFile.exists())
{
throw new BuildException("Could not load the specified repository file "+_repositoryFile);
}
log("Loading repository file "+_repositoryFile.getAbsolutePath(), Project.MSG_INFO);
// this will load the info from the specified repository file
// and merge it with the existing info (if it has been loaded)
metadataManager.mergeConnectionRepository(persistor.readConnectionRepository(_repositoryFile.getAbsolutePath()));
metadataManager.mergeDescriptorRepository(persistor.readDescriptorRepository(_repositoryFile.getAbsolutePath()));
}
else if (metadataManager.connectionRepository().getAllDescriptor().isEmpty() &&
metadataManager.getGlobalRepository().getDescriptorTable().isEmpty())
{
// Seems nothing was loaded, probably because we're not starting in the directory
// that the properties file is in, and the repository file path is relative
// So lets try to resolve this path and load the repository info manually
Properties props = new Properties();
props.load(new FileInputStream(_ojbPropertiesFile));
String repositoryPath = props.getProperty("repositoryFile", "repository.xml");
File repositoryFile = new File(repositoryPath);
if (!repositoryFile.exists())
{
repositoryFile = new File(_ojbPropertiesFile.getParentFile(), repositoryPath);
}
metadataManager.mergeConnectionRepository(persistor.readConnectionRepository(repositoryFile.getAbsolutePath()));
metadataManager.mergeDescriptorRepository(persistor.readDescriptorRepository(repositoryFile.getAbsolutePath()));
}
// we might have to determine the default pb key ourselves
if (metadataManager.getDefaultPBKey() == null)
{
for (Iterator it = metadataManager.connectionRepository().getAllDescriptor().iterator(); it.hasNext();)
{
JdbcConnectionDescriptor descriptor = (JdbcConnectionDescriptor)it.next();
if (descriptor.isDefaultConnection())
{
metadataManager.setDefaultPBKey(new PBKey(descriptor.getJcdAlias(), descriptor.getUserName(), descriptor.getPassWord()));
break;
}
}
}
return metadataManager;
}
catch (Exception ex)
{
if (ex instanceof BuildException)
{
throw (BuildException)ex;
}
else
{
throw new BuildException(ex);
}
}
} | [
"private",
"MetadataManager",
"initOJB",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"_ojbPropertiesFile",
"==",
"null",
")",
"{",
"_ojbPropertiesFile",
"=",
"new",
"File",
"(",
"\"OJB.properties\"",
")",
";",
"if",
"(",
"!",
"_ojbPropertiesFile",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Could not find OJB.properties, please specify it via the ojbpropertiesfile attribute\"",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"_ojbPropertiesFile",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Could not load the specified OJB properties file \"",
"+",
"_ojbPropertiesFile",
")",
";",
"}",
"log",
"(",
"\"Using properties file \"",
"+",
"_ojbPropertiesFile",
".",
"getAbsolutePath",
"(",
")",
",",
"Project",
".",
"MSG_INFO",
")",
";",
"System",
".",
"setProperty",
"(",
"\"OJB.properties\"",
",",
"_ojbPropertiesFile",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"MetadataManager",
"metadataManager",
"=",
"MetadataManager",
".",
"getInstance",
"(",
")",
";",
"RepositoryPersistor",
"persistor",
"=",
"new",
"RepositoryPersistor",
"(",
")",
";",
"if",
"(",
"_repositoryFile",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"_repositoryFile",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Could not load the specified repository file \"",
"+",
"_repositoryFile",
")",
";",
"}",
"log",
"(",
"\"Loading repository file \"",
"+",
"_repositoryFile",
".",
"getAbsolutePath",
"(",
")",
",",
"Project",
".",
"MSG_INFO",
")",
";",
"// this will load the info from the specified repository file\r",
"// and merge it with the existing info (if it has been loaded)\r",
"metadataManager",
".",
"mergeConnectionRepository",
"(",
"persistor",
".",
"readConnectionRepository",
"(",
"_repositoryFile",
".",
"getAbsolutePath",
"(",
")",
")",
")",
";",
"metadataManager",
".",
"mergeDescriptorRepository",
"(",
"persistor",
".",
"readDescriptorRepository",
"(",
"_repositoryFile",
".",
"getAbsolutePath",
"(",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"metadataManager",
".",
"connectionRepository",
"(",
")",
".",
"getAllDescriptor",
"(",
")",
".",
"isEmpty",
"(",
")",
"&&",
"metadataManager",
".",
"getGlobalRepository",
"(",
")",
".",
"getDescriptorTable",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"// Seems nothing was loaded, probably because we're not starting in the directory\r",
"// that the properties file is in, and the repository file path is relative\r",
"// So lets try to resolve this path and load the repository info manually\r",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"props",
".",
"load",
"(",
"new",
"FileInputStream",
"(",
"_ojbPropertiesFile",
")",
")",
";",
"String",
"repositoryPath",
"=",
"props",
".",
"getProperty",
"(",
"\"repositoryFile\"",
",",
"\"repository.xml\"",
")",
";",
"File",
"repositoryFile",
"=",
"new",
"File",
"(",
"repositoryPath",
")",
";",
"if",
"(",
"!",
"repositoryFile",
".",
"exists",
"(",
")",
")",
"{",
"repositoryFile",
"=",
"new",
"File",
"(",
"_ojbPropertiesFile",
".",
"getParentFile",
"(",
")",
",",
"repositoryPath",
")",
";",
"}",
"metadataManager",
".",
"mergeConnectionRepository",
"(",
"persistor",
".",
"readConnectionRepository",
"(",
"repositoryFile",
".",
"getAbsolutePath",
"(",
")",
")",
")",
";",
"metadataManager",
".",
"mergeDescriptorRepository",
"(",
"persistor",
".",
"readDescriptorRepository",
"(",
"repositoryFile",
".",
"getAbsolutePath",
"(",
")",
")",
")",
";",
"}",
"// we might have to determine the default pb key ourselves\r",
"if",
"(",
"metadataManager",
".",
"getDefaultPBKey",
"(",
")",
"==",
"null",
")",
"{",
"for",
"(",
"Iterator",
"it",
"=",
"metadataManager",
".",
"connectionRepository",
"(",
")",
".",
"getAllDescriptor",
"(",
")",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"JdbcConnectionDescriptor",
"descriptor",
"=",
"(",
"JdbcConnectionDescriptor",
")",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"descriptor",
".",
"isDefaultConnection",
"(",
")",
")",
"{",
"metadataManager",
".",
"setDefaultPBKey",
"(",
"new",
"PBKey",
"(",
"descriptor",
".",
"getJcdAlias",
"(",
")",
",",
"descriptor",
".",
"getUserName",
"(",
")",
",",
"descriptor",
".",
"getPassWord",
"(",
")",
")",
")",
";",
"break",
";",
"}",
"}",
"}",
"return",
"metadataManager",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"if",
"(",
"ex",
"instanceof",
"BuildException",
")",
"{",
"throw",
"(",
"BuildException",
")",
"ex",
";",
"}",
"else",
"{",
"throw",
"new",
"BuildException",
"(",
"ex",
")",
";",
"}",
"}",
"}"
] | Initializes OJB for the purposes of this task.
@return The metadata manager used by OJB | [
"Initializes",
"OJB",
"for",
"the",
"purposes",
"of",
"this",
"task",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/ant/RepositoryDataTask.java#L270-L355 | train |
geomajas/geomajas-project-server | plugin/print/print/src/main/java/org/geomajas/plugin/printing/service/PrintServiceImpl.java | PrintServiceImpl.putDocument | public String putDocument(Document document) {
String key = UUID.randomUUID().toString();
documentMap.put(key, document);
return key;
} | java | public String putDocument(Document document) {
String key = UUID.randomUUID().toString();
documentMap.put(key, document);
return key;
} | [
"public",
"String",
"putDocument",
"(",
"Document",
"document",
")",
"{",
"String",
"key",
"=",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
";",
"documentMap",
".",
"put",
"(",
"key",
",",
"document",
")",
";",
"return",
"key",
";",
"}"
] | Puts a new document in the service. The generate key is globally unique.
@param document document
@return key unique key to reference the document | [
"Puts",
"a",
"new",
"document",
"in",
"the",
"service",
".",
"The",
"generate",
"key",
"is",
"globally",
"unique",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/print/print/src/main/java/org/geomajas/plugin/printing/service/PrintServiceImpl.java#L156-L160 | train |
geomajas/geomajas-project-server | plugin/print/print/src/main/java/org/geomajas/plugin/printing/service/PrintServiceImpl.java | PrintServiceImpl.removeDocument | public Document removeDocument(String key) throws PrintingException {
if (documentMap.containsKey(key)) {
return documentMap.remove(key);
} else {
throw new PrintingException(PrintingException.DOCUMENT_NOT_FOUND, key);
}
} | java | public Document removeDocument(String key) throws PrintingException {
if (documentMap.containsKey(key)) {
return documentMap.remove(key);
} else {
throw new PrintingException(PrintingException.DOCUMENT_NOT_FOUND, key);
}
} | [
"public",
"Document",
"removeDocument",
"(",
"String",
"key",
")",
"throws",
"PrintingException",
"{",
"if",
"(",
"documentMap",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"return",
"documentMap",
".",
"remove",
"(",
"key",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"PrintingException",
"(",
"PrintingException",
".",
"DOCUMENT_NOT_FOUND",
",",
"key",
")",
";",
"}",
"}"
] | Gets a document from the service.
@param key
unique key to reference the document
@return the document or null if no such document | [
"Gets",
"a",
"document",
"from",
"the",
"service",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/print/print/src/main/java/org/geomajas/plugin/printing/service/PrintServiceImpl.java#L169-L175 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectByPkStatement.java | SqlSelectByPkStatement.buildQuery | private static Query buildQuery(ClassDescriptor cld)
{
FieldDescriptor[] pkFields = cld.getPkFields();
Criteria crit = new Criteria();
for(int i = 0; i < pkFields.length; i++)
{
crit.addEqualTo(pkFields[i].getAttributeName(), null);
}
return new QueryByCriteria(cld.getClassOfObject(), crit);
} | java | private static Query buildQuery(ClassDescriptor cld)
{
FieldDescriptor[] pkFields = cld.getPkFields();
Criteria crit = new Criteria();
for(int i = 0; i < pkFields.length; i++)
{
crit.addEqualTo(pkFields[i].getAttributeName(), null);
}
return new QueryByCriteria(cld.getClassOfObject(), crit);
} | [
"private",
"static",
"Query",
"buildQuery",
"(",
"ClassDescriptor",
"cld",
")",
"{",
"FieldDescriptor",
"[",
"]",
"pkFields",
"=",
"cld",
".",
"getPkFields",
"(",
")",
";",
"Criteria",
"crit",
"=",
"new",
"Criteria",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"pkFields",
".",
"length",
";",
"i",
"++",
")",
"{",
"crit",
".",
"addEqualTo",
"(",
"pkFields",
"[",
"i",
"]",
".",
"getAttributeName",
"(",
")",
",",
"null",
")",
";",
"}",
"return",
"new",
"QueryByCriteria",
"(",
"cld",
".",
"getClassOfObject",
"(",
")",
",",
"crit",
")",
";",
"}"
] | Build a Pk-Query base on the ClassDescriptor.
@param cld
@return a select by PK query | [
"Build",
"a",
"Pk",
"-",
"Query",
"base",
"on",
"the",
"ClassDescriptor",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectByPkStatement.java#L52-L62 | train |
geomajas/geomajas-project-server | api/src/main/java/org/geomajas/global/GeomajasException.java | GeomajasException.getMessage | public String getMessage(Locale locale) {
if (getCause() != null) {
String message = getShortMessage(locale) + ", " + translate("ROOT_CAUSE", locale) + " ";
if (getCause() instanceof GeomajasException) {
return message + ((GeomajasException) getCause()).getMessage(locale);
}
return message + getCause().getMessage();
} else {
return getShortMessage(locale);
}
} | java | public String getMessage(Locale locale) {
if (getCause() != null) {
String message = getShortMessage(locale) + ", " + translate("ROOT_CAUSE", locale) + " ";
if (getCause() instanceof GeomajasException) {
return message + ((GeomajasException) getCause()).getMessage(locale);
}
return message + getCause().getMessage();
} else {
return getShortMessage(locale);
}
} | [
"public",
"String",
"getMessage",
"(",
"Locale",
"locale",
")",
"{",
"if",
"(",
"getCause",
"(",
")",
"!=",
"null",
")",
"{",
"String",
"message",
"=",
"getShortMessage",
"(",
"locale",
")",
"+",
"\", \"",
"+",
"translate",
"(",
"\"ROOT_CAUSE\"",
",",
"locale",
")",
"+",
"\" \"",
";",
"if",
"(",
"getCause",
"(",
")",
"instanceof",
"GeomajasException",
")",
"{",
"return",
"message",
"+",
"(",
"(",
"GeomajasException",
")",
"getCause",
"(",
")",
")",
".",
"getMessage",
"(",
"locale",
")",
";",
"}",
"return",
"message",
"+",
"getCause",
"(",
")",
".",
"getMessage",
"(",
")",
";",
"}",
"else",
"{",
"return",
"getShortMessage",
"(",
"locale",
")",
";",
"}",
"}"
] | Get the exception message using the requested locale.
@param locale locale for message
@return exception message | [
"Get",
"the",
"exception",
"message",
"using",
"the",
"requested",
"locale",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/api/src/main/java/org/geomajas/global/GeomajasException.java#L145-L155 | train |
geomajas/geomajas-project-server | api/src/main/java/org/geomajas/global/GeomajasException.java | GeomajasException.getShortMessage | public String getShortMessage(Locale locale) {
String message;
message = translate(Integer.toString(exceptionCode), locale);
if (message != null && msgParameters != null && msgParameters.length > 0) {
for (int i = 0; i < msgParameters.length; i++) {
boolean isIncluded = false;
String needTranslationParam = "$${" + i + "}";
if (message.contains(needTranslationParam)) {
String translation = translate(msgParameters[i], locale);
if (null == translation && null != msgParameters[i]) {
translation = msgParameters[i].toString();
}
if (null == translation) {
translation = "[null]";
}
message = message.replace(needTranslationParam, translation);
isIncluded = true;
}
String verbatimParam = "${" + i + "}";
String rs = null == msgParameters[i] ? "[null]" : msgParameters[i].toString();
if (message.contains(verbatimParam)) {
message = message.replace(verbatimParam, rs);
isIncluded = true;
}
if (!isIncluded) {
message = message + " (" + rs + ")"; // NOSONAR replace/contains makes StringBuilder use difficult
}
}
}
return message;
} | java | public String getShortMessage(Locale locale) {
String message;
message = translate(Integer.toString(exceptionCode), locale);
if (message != null && msgParameters != null && msgParameters.length > 0) {
for (int i = 0; i < msgParameters.length; i++) {
boolean isIncluded = false;
String needTranslationParam = "$${" + i + "}";
if (message.contains(needTranslationParam)) {
String translation = translate(msgParameters[i], locale);
if (null == translation && null != msgParameters[i]) {
translation = msgParameters[i].toString();
}
if (null == translation) {
translation = "[null]";
}
message = message.replace(needTranslationParam, translation);
isIncluded = true;
}
String verbatimParam = "${" + i + "}";
String rs = null == msgParameters[i] ? "[null]" : msgParameters[i].toString();
if (message.contains(verbatimParam)) {
message = message.replace(verbatimParam, rs);
isIncluded = true;
}
if (!isIncluded) {
message = message + " (" + rs + ")"; // NOSONAR replace/contains makes StringBuilder use difficult
}
}
}
return message;
} | [
"public",
"String",
"getShortMessage",
"(",
"Locale",
"locale",
")",
"{",
"String",
"message",
";",
"message",
"=",
"translate",
"(",
"Integer",
".",
"toString",
"(",
"exceptionCode",
")",
",",
"locale",
")",
";",
"if",
"(",
"message",
"!=",
"null",
"&&",
"msgParameters",
"!=",
"null",
"&&",
"msgParameters",
".",
"length",
">",
"0",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"msgParameters",
".",
"length",
";",
"i",
"++",
")",
"{",
"boolean",
"isIncluded",
"=",
"false",
";",
"String",
"needTranslationParam",
"=",
"\"$${\"",
"+",
"i",
"+",
"\"}\"",
";",
"if",
"(",
"message",
".",
"contains",
"(",
"needTranslationParam",
")",
")",
"{",
"String",
"translation",
"=",
"translate",
"(",
"msgParameters",
"[",
"i",
"]",
",",
"locale",
")",
";",
"if",
"(",
"null",
"==",
"translation",
"&&",
"null",
"!=",
"msgParameters",
"[",
"i",
"]",
")",
"{",
"translation",
"=",
"msgParameters",
"[",
"i",
"]",
".",
"toString",
"(",
")",
";",
"}",
"if",
"(",
"null",
"==",
"translation",
")",
"{",
"translation",
"=",
"\"[null]\"",
";",
"}",
"message",
"=",
"message",
".",
"replace",
"(",
"needTranslationParam",
",",
"translation",
")",
";",
"isIncluded",
"=",
"true",
";",
"}",
"String",
"verbatimParam",
"=",
"\"${\"",
"+",
"i",
"+",
"\"}\"",
";",
"String",
"rs",
"=",
"null",
"==",
"msgParameters",
"[",
"i",
"]",
"?",
"\"[null]\"",
":",
"msgParameters",
"[",
"i",
"]",
".",
"toString",
"(",
")",
";",
"if",
"(",
"message",
".",
"contains",
"(",
"verbatimParam",
")",
")",
"{",
"message",
"=",
"message",
".",
"replace",
"(",
"verbatimParam",
",",
"rs",
")",
";",
"isIncluded",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"isIncluded",
")",
"{",
"message",
"=",
"message",
"+",
"\" (\"",
"+",
"rs",
"+",
"\")\"",
";",
"// NOSONAR replace/contains makes StringBuilder use difficult",
"}",
"}",
"}",
"return",
"message",
";",
"}"
] | Get the short exception message using the requested locale. This does not include the cause exception message.
@param locale locale for message
@return (short) exception message | [
"Get",
"the",
"short",
"exception",
"message",
"using",
"the",
"requested",
"locale",
".",
"This",
"does",
"not",
"include",
"the",
"cause",
"exception",
"message",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/api/src/main/java/org/geomajas/global/GeomajasException.java#L163-L193 | train |
geomajas/geomajas-project-server | plugin/rasterizing/rasterizing/src/main/java/org/geomajas/plugin/rasterizing/layer/RasterDirectLayer.java | RasterDirectLayer.toDirectColorModel | public PlanarImage toDirectColorModel(RenderedImage img) {
BufferedImage dest = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
BufferedImage source = new BufferedImage(img.getColorModel(), (WritableRaster) img.getData(), img
.getColorModel().isAlphaPremultiplied(), null);
ColorConvertOp op = new ColorConvertOp(null);
op.filter(source, dest);
return PlanarImage.wrapRenderedImage(dest);
} | java | public PlanarImage toDirectColorModel(RenderedImage img) {
BufferedImage dest = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
BufferedImage source = new BufferedImage(img.getColorModel(), (WritableRaster) img.getData(), img
.getColorModel().isAlphaPremultiplied(), null);
ColorConvertOp op = new ColorConvertOp(null);
op.filter(source, dest);
return PlanarImage.wrapRenderedImage(dest);
} | [
"public",
"PlanarImage",
"toDirectColorModel",
"(",
"RenderedImage",
"img",
")",
"{",
"BufferedImage",
"dest",
"=",
"new",
"BufferedImage",
"(",
"img",
".",
"getWidth",
"(",
")",
",",
"img",
".",
"getHeight",
"(",
")",
",",
"BufferedImage",
".",
"TYPE_4BYTE_ABGR",
")",
";",
"BufferedImage",
"source",
"=",
"new",
"BufferedImage",
"(",
"img",
".",
"getColorModel",
"(",
")",
",",
"(",
"WritableRaster",
")",
"img",
".",
"getData",
"(",
")",
",",
"img",
".",
"getColorModel",
"(",
")",
".",
"isAlphaPremultiplied",
"(",
")",
",",
"null",
")",
";",
"ColorConvertOp",
"op",
"=",
"new",
"ColorConvertOp",
"(",
"null",
")",
";",
"op",
".",
"filter",
"(",
"source",
",",
"dest",
")",
";",
"return",
"PlanarImage",
".",
"wrapRenderedImage",
"(",
"dest",
")",
";",
"}"
] | Converts an image to a RGBA direct color model using a workaround via buffered image directly calling the
ColorConvert operation fails for unknown reasons ?!
@param img image to convert
@return converted image | [
"Converts",
"an",
"image",
"to",
"a",
"RGBA",
"direct",
"color",
"model",
"using",
"a",
"workaround",
"via",
"buffered",
"image",
"directly",
"calling",
"the",
"ColorConvert",
"operation",
"fails",
"for",
"unknown",
"reasons",
"?!"
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/rasterizing/rasterizing/src/main/java/org/geomajas/plugin/rasterizing/layer/RasterDirectLayer.java#L440-L447 | train |
kuali/ojb-1.0.4 | src/jca/org/apache/ojb/otm/connector/OTMJCAManagedConnectionFactory.java | OTMJCAManagedConnectionFactory.createManagedConnection | public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo info)
{
Util.log("In OTMJCAManagedConnectionFactory.createManagedConnection");
try
{
Kit kit = getKit();
PBKey key = ((OTMConnectionRequestInfo) info).getPbKey();
OTMConnection connection = kit.acquireConnection(key);
return new OTMJCAManagedConnection(this, connection, key);
}
catch (ResourceException e)
{
throw new OTMConnectionRuntimeException(e.getMessage());
}
} | java | public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo info)
{
Util.log("In OTMJCAManagedConnectionFactory.createManagedConnection");
try
{
Kit kit = getKit();
PBKey key = ((OTMConnectionRequestInfo) info).getPbKey();
OTMConnection connection = kit.acquireConnection(key);
return new OTMJCAManagedConnection(this, connection, key);
}
catch (ResourceException e)
{
throw new OTMConnectionRuntimeException(e.getMessage());
}
} | [
"public",
"ManagedConnection",
"createManagedConnection",
"(",
"Subject",
"subject",
",",
"ConnectionRequestInfo",
"info",
")",
"{",
"Util",
".",
"log",
"(",
"\"In OTMJCAManagedConnectionFactory.createManagedConnection\"",
")",
";",
"try",
"{",
"Kit",
"kit",
"=",
"getKit",
"(",
")",
";",
"PBKey",
"key",
"=",
"(",
"(",
"OTMConnectionRequestInfo",
")",
"info",
")",
".",
"getPbKey",
"(",
")",
";",
"OTMConnection",
"connection",
"=",
"kit",
".",
"acquireConnection",
"(",
"key",
")",
";",
"return",
"new",
"OTMJCAManagedConnection",
"(",
"this",
",",
"connection",
",",
"key",
")",
";",
"}",
"catch",
"(",
"ResourceException",
"e",
")",
"{",
"throw",
"new",
"OTMConnectionRuntimeException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | return a new managed connection. This connection is wrapped around the real connection and delegates to it
to get work done.
@param subject
@param info
@return | [
"return",
"a",
"new",
"managed",
"connection",
".",
"This",
"connection",
"is",
"wrapped",
"around",
"the",
"real",
"connection",
"and",
"delegates",
"to",
"it",
"to",
"get",
"work",
"done",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/jca/org/apache/ojb/otm/connector/OTMJCAManagedConnectionFactory.java#L83-L97 | train |
geomajas/geomajas-project-server | plugin/print/print/src/main/java/org/geomajas/plugin/printing/document/SinglePageDocument.java | SinglePageDocument.render | public void render(OutputStream outputStream, Format format, int dpi) throws PrintingException {
try {
if (baos == null) {
prepare();
}
writeDocument(outputStream, format, dpi);
} catch (Exception e) { // NOSONAR
throw new PrintingException(e, PrintingException.DOCUMENT_RENDER_PROBLEM);
}
} | java | public void render(OutputStream outputStream, Format format, int dpi) throws PrintingException {
try {
if (baos == null) {
prepare();
}
writeDocument(outputStream, format, dpi);
} catch (Exception e) { // NOSONAR
throw new PrintingException(e, PrintingException.DOCUMENT_RENDER_PROBLEM);
}
} | [
"public",
"void",
"render",
"(",
"OutputStream",
"outputStream",
",",
"Format",
"format",
",",
"int",
"dpi",
")",
"throws",
"PrintingException",
"{",
"try",
"{",
"if",
"(",
"baos",
"==",
"null",
")",
"{",
"prepare",
"(",
")",
";",
"}",
"writeDocument",
"(",
"outputStream",
",",
"format",
",",
"dpi",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// NOSONAR",
"throw",
"new",
"PrintingException",
"(",
"e",
",",
"PrintingException",
".",
"DOCUMENT_RENDER_PROBLEM",
")",
";",
"}",
"}"
] | Renders the document to the specified output stream. | [
"Renders",
"the",
"document",
"to",
"the",
"specified",
"output",
"stream",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/print/print/src/main/java/org/geomajas/plugin/printing/document/SinglePageDocument.java#L98-L107 | train |
geomajas/geomajas-project-server | plugin/print/print/src/main/java/org/geomajas/plugin/printing/document/SinglePageDocument.java | SinglePageDocument.prepare | private void prepare() throws IOException, DocumentException, PrintingException {
if (baos == null) {
baos = new ByteArrayOutputStream(); // let it grow as much as needed
}
baos.reset();
boolean resize = false;
if (page.getConstraint().getWidth() == 0 || page.getConstraint().getHeight() == 0) {
resize = true;
}
// Create a document in the requested ISO scale.
Document document = new Document(page.getBounds(), 0, 0, 0, 0);
PdfWriter writer;
writer = PdfWriter.getInstance(document, baos);
// Render in correct colors for transparent rasters
writer.setRgbTransparencyBlending(true);
// The mapView is not scaled to the document, we assume the mapView
// has the right ratio.
// Write document title and metadata
document.open();
PdfContext context = new PdfContext(writer);
context.initSize(page.getBounds());
// first pass of all children to calculate size
page.calculateSize(context);
if (resize) {
// we now know the bounds of the document
// round 'm up and restart with a new document
int width = (int) Math.ceil(page.getBounds().getWidth());
int height = (int) Math.ceil(page.getBounds().getHeight());
page.getConstraint().setWidth(width);
page.getConstraint().setHeight(height);
document = new Document(new Rectangle(width, height), 0, 0, 0, 0);
writer = PdfWriter.getInstance(document, baos);
// Render in correct colors for transparent rasters
writer.setRgbTransparencyBlending(true);
document.open();
baos.reset();
context = new PdfContext(writer);
context.initSize(page.getBounds());
}
// int compressionLevel = writer.getCompressionLevel(); // For testing
// writer.setCompressionLevel(0);
// Actual drawing
document.addTitle("Geomajas");
// second pass to layout
page.layout(context);
// finally render (uses baos)
page.render(context);
document.add(context.getImage());
// Now close the document
document.close();
} | java | private void prepare() throws IOException, DocumentException, PrintingException {
if (baos == null) {
baos = new ByteArrayOutputStream(); // let it grow as much as needed
}
baos.reset();
boolean resize = false;
if (page.getConstraint().getWidth() == 0 || page.getConstraint().getHeight() == 0) {
resize = true;
}
// Create a document in the requested ISO scale.
Document document = new Document(page.getBounds(), 0, 0, 0, 0);
PdfWriter writer;
writer = PdfWriter.getInstance(document, baos);
// Render in correct colors for transparent rasters
writer.setRgbTransparencyBlending(true);
// The mapView is not scaled to the document, we assume the mapView
// has the right ratio.
// Write document title and metadata
document.open();
PdfContext context = new PdfContext(writer);
context.initSize(page.getBounds());
// first pass of all children to calculate size
page.calculateSize(context);
if (resize) {
// we now know the bounds of the document
// round 'm up and restart with a new document
int width = (int) Math.ceil(page.getBounds().getWidth());
int height = (int) Math.ceil(page.getBounds().getHeight());
page.getConstraint().setWidth(width);
page.getConstraint().setHeight(height);
document = new Document(new Rectangle(width, height), 0, 0, 0, 0);
writer = PdfWriter.getInstance(document, baos);
// Render in correct colors for transparent rasters
writer.setRgbTransparencyBlending(true);
document.open();
baos.reset();
context = new PdfContext(writer);
context.initSize(page.getBounds());
}
// int compressionLevel = writer.getCompressionLevel(); // For testing
// writer.setCompressionLevel(0);
// Actual drawing
document.addTitle("Geomajas");
// second pass to layout
page.layout(context);
// finally render (uses baos)
page.render(context);
document.add(context.getImage());
// Now close the document
document.close();
} | [
"private",
"void",
"prepare",
"(",
")",
"throws",
"IOException",
",",
"DocumentException",
",",
"PrintingException",
"{",
"if",
"(",
"baos",
"==",
"null",
")",
"{",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"// let it grow as much as needed",
"}",
"baos",
".",
"reset",
"(",
")",
";",
"boolean",
"resize",
"=",
"false",
";",
"if",
"(",
"page",
".",
"getConstraint",
"(",
")",
".",
"getWidth",
"(",
")",
"==",
"0",
"||",
"page",
".",
"getConstraint",
"(",
")",
".",
"getHeight",
"(",
")",
"==",
"0",
")",
"{",
"resize",
"=",
"true",
";",
"}",
"// Create a document in the requested ISO scale.",
"Document",
"document",
"=",
"new",
"Document",
"(",
"page",
".",
"getBounds",
"(",
")",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
";",
"PdfWriter",
"writer",
";",
"writer",
"=",
"PdfWriter",
".",
"getInstance",
"(",
"document",
",",
"baos",
")",
";",
"// Render in correct colors for transparent rasters",
"writer",
".",
"setRgbTransparencyBlending",
"(",
"true",
")",
";",
"// The mapView is not scaled to the document, we assume the mapView",
"// has the right ratio.",
"// Write document title and metadata",
"document",
".",
"open",
"(",
")",
";",
"PdfContext",
"context",
"=",
"new",
"PdfContext",
"(",
"writer",
")",
";",
"context",
".",
"initSize",
"(",
"page",
".",
"getBounds",
"(",
")",
")",
";",
"// first pass of all children to calculate size",
"page",
".",
"calculateSize",
"(",
"context",
")",
";",
"if",
"(",
"resize",
")",
"{",
"// we now know the bounds of the document",
"// round 'm up and restart with a new document",
"int",
"width",
"=",
"(",
"int",
")",
"Math",
".",
"ceil",
"(",
"page",
".",
"getBounds",
"(",
")",
".",
"getWidth",
"(",
")",
")",
";",
"int",
"height",
"=",
"(",
"int",
")",
"Math",
".",
"ceil",
"(",
"page",
".",
"getBounds",
"(",
")",
".",
"getHeight",
"(",
")",
")",
";",
"page",
".",
"getConstraint",
"(",
")",
".",
"setWidth",
"(",
"width",
")",
";",
"page",
".",
"getConstraint",
"(",
")",
".",
"setHeight",
"(",
"height",
")",
";",
"document",
"=",
"new",
"Document",
"(",
"new",
"Rectangle",
"(",
"width",
",",
"height",
")",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
";",
"writer",
"=",
"PdfWriter",
".",
"getInstance",
"(",
"document",
",",
"baos",
")",
";",
"// Render in correct colors for transparent rasters",
"writer",
".",
"setRgbTransparencyBlending",
"(",
"true",
")",
";",
"document",
".",
"open",
"(",
")",
";",
"baos",
".",
"reset",
"(",
")",
";",
"context",
"=",
"new",
"PdfContext",
"(",
"writer",
")",
";",
"context",
".",
"initSize",
"(",
"page",
".",
"getBounds",
"(",
")",
")",
";",
"}",
"// int compressionLevel = writer.getCompressionLevel(); // For testing",
"// writer.setCompressionLevel(0);",
"// Actual drawing",
"document",
".",
"addTitle",
"(",
"\"Geomajas\"",
")",
";",
"// second pass to layout",
"page",
".",
"layout",
"(",
"context",
")",
";",
"// finally render (uses baos)",
"page",
".",
"render",
"(",
"context",
")",
";",
"document",
".",
"add",
"(",
"context",
".",
"getImage",
"(",
")",
")",
";",
"// Now close the document",
"document",
".",
"close",
"(",
")",
";",
"}"
] | Prepare the document before rendering.
@param outputStream output stream to render to, null if only for layout
@param format format
@throws DocumentException oops
@throws IOException oops
@throws PrintingException oops | [
"Prepare",
"the",
"document",
"before",
"rendering",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/print/print/src/main/java/org/geomajas/plugin/printing/document/SinglePageDocument.java#L132-L189 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/logging/Log4jLoggerImpl.java | Log4jLoggerImpl.isLog4JConfigured | private static synchronized boolean isLog4JConfigured()
{
if(!log4jConfigured)
{
Enumeration en = org.apache.log4j.Logger.getRootLogger().getAllAppenders();
if (!(en instanceof org.apache.log4j.helpers.NullEnumeration))
{
log4jConfigured = true;
}
else
{
Enumeration cats = LogManager.getCurrentLoggers();
while (cats.hasMoreElements())
{
org.apache.log4j.Logger c = (org.apache.log4j.Logger) cats.nextElement();
if (!(c.getAllAppenders() instanceof org.apache.log4j.helpers.NullEnumeration))
{
log4jConfigured = true;
}
}
}
if(log4jConfigured)
{
String msg = "Log4J is already configured, will not search for log4j properties file";
LoggerFactory.getBootLogger().info(msg);
}
else
{
LoggerFactory.getBootLogger().info("Log4J is not configured");
}
}
return log4jConfigured;
} | java | private static synchronized boolean isLog4JConfigured()
{
if(!log4jConfigured)
{
Enumeration en = org.apache.log4j.Logger.getRootLogger().getAllAppenders();
if (!(en instanceof org.apache.log4j.helpers.NullEnumeration))
{
log4jConfigured = true;
}
else
{
Enumeration cats = LogManager.getCurrentLoggers();
while (cats.hasMoreElements())
{
org.apache.log4j.Logger c = (org.apache.log4j.Logger) cats.nextElement();
if (!(c.getAllAppenders() instanceof org.apache.log4j.helpers.NullEnumeration))
{
log4jConfigured = true;
}
}
}
if(log4jConfigured)
{
String msg = "Log4J is already configured, will not search for log4j properties file";
LoggerFactory.getBootLogger().info(msg);
}
else
{
LoggerFactory.getBootLogger().info("Log4J is not configured");
}
}
return log4jConfigured;
} | [
"private",
"static",
"synchronized",
"boolean",
"isLog4JConfigured",
"(",
")",
"{",
"if",
"(",
"!",
"log4jConfigured",
")",
"{",
"Enumeration",
"en",
"=",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
".",
"getRootLogger",
"(",
")",
".",
"getAllAppenders",
"(",
")",
";",
"if",
"(",
"!",
"(",
"en",
"instanceof",
"org",
".",
"apache",
".",
"log4j",
".",
"helpers",
".",
"NullEnumeration",
")",
")",
"{",
"log4jConfigured",
"=",
"true",
";",
"}",
"else",
"{",
"Enumeration",
"cats",
"=",
"LogManager",
".",
"getCurrentLoggers",
"(",
")",
";",
"while",
"(",
"cats",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
"c",
"=",
"(",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
")",
"cats",
".",
"nextElement",
"(",
")",
";",
"if",
"(",
"!",
"(",
"c",
".",
"getAllAppenders",
"(",
")",
"instanceof",
"org",
".",
"apache",
".",
"log4j",
".",
"helpers",
".",
"NullEnumeration",
")",
")",
"{",
"log4jConfigured",
"=",
"true",
";",
"}",
"}",
"}",
"if",
"(",
"log4jConfigured",
")",
"{",
"String",
"msg",
"=",
"\"Log4J is already configured, will not search for log4j properties file\"",
";",
"LoggerFactory",
".",
"getBootLogger",
"(",
")",
".",
"info",
"(",
"msg",
")",
";",
"}",
"else",
"{",
"LoggerFactory",
".",
"getBootLogger",
"(",
")",
".",
"info",
"(",
"\"Log4J is not configured\"",
")",
";",
"}",
"}",
"return",
"log4jConfigured",
";",
"}"
] | Helper method to check if log4j is already configured | [
"Helper",
"method",
"to",
"check",
"if",
"log4j",
"is",
"already",
"configured"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/logging/Log4jLoggerImpl.java#L55-L88 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/logging/Log4jLoggerImpl.java | Log4jLoggerImpl.getLogger | private org.apache.log4j.Logger getLogger()
{
/*
Logger interface extends Serializable, thus Log field is
declared 'transient' and we have to null-check
*/
if (logger == null)
{
logger = org.apache.log4j.Logger.getLogger(name);
}
return logger;
} | java | private org.apache.log4j.Logger getLogger()
{
/*
Logger interface extends Serializable, thus Log field is
declared 'transient' and we have to null-check
*/
if (logger == null)
{
logger = org.apache.log4j.Logger.getLogger(name);
}
return logger;
} | [
"private",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
"getLogger",
"(",
")",
"{",
"/*\r\n Logger interface extends Serializable, thus Log field is\r\n declared 'transient' and we have to null-check\r\n\t\t*/",
"if",
"(",
"logger",
"==",
"null",
")",
"{",
"logger",
"=",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
".",
"getLogger",
"(",
"name",
")",
";",
"}",
"return",
"logger",
";",
"}"
] | Gets the logger.
@return Returns a Category | [
"Gets",
"the",
"logger",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/logging/Log4jLoggerImpl.java#L144-L155 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/logging/Log4jLoggerImpl.java | Log4jLoggerImpl.debug | public final void debug(Object pObject)
{
getLogger().log(FQCN, Level.DEBUG, pObject, null);
} | java | public final void debug(Object pObject)
{
getLogger().log(FQCN, Level.DEBUG, pObject, null);
} | [
"public",
"final",
"void",
"debug",
"(",
"Object",
"pObject",
")",
"{",
"getLogger",
"(",
")",
".",
"log",
"(",
"FQCN",
",",
"Level",
".",
"DEBUG",
",",
"pObject",
",",
"null",
")",
";",
"}"
] | generate a message for loglevel DEBUG
@param pObject the message Object | [
"generate",
"a",
"message",
"for",
"loglevel",
"DEBUG"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/logging/Log4jLoggerImpl.java#L172-L175 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/logging/Log4jLoggerImpl.java | Log4jLoggerImpl.info | public final void info(Object pObject)
{
getLogger().log(FQCN, Level.INFO, pObject, null);
} | java | public final void info(Object pObject)
{
getLogger().log(FQCN, Level.INFO, pObject, null);
} | [
"public",
"final",
"void",
"info",
"(",
"Object",
"pObject",
")",
"{",
"getLogger",
"(",
")",
".",
"log",
"(",
"FQCN",
",",
"Level",
".",
"INFO",
",",
"pObject",
",",
"null",
")",
";",
"}"
] | generate a message for loglevel INFO
@param pObject the message Object | [
"generate",
"a",
"message",
"for",
"loglevel",
"INFO"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/logging/Log4jLoggerImpl.java#L182-L185 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/logging/Log4jLoggerImpl.java | Log4jLoggerImpl.warn | public final void warn(Object pObject)
{
getLogger().log(FQCN, Level.WARN, pObject, null);
} | java | public final void warn(Object pObject)
{
getLogger().log(FQCN, Level.WARN, pObject, null);
} | [
"public",
"final",
"void",
"warn",
"(",
"Object",
"pObject",
")",
"{",
"getLogger",
"(",
")",
".",
"log",
"(",
"FQCN",
",",
"Level",
".",
"WARN",
",",
"pObject",
",",
"null",
")",
";",
"}"
] | generate a message for loglevel WARN
@param pObject the message Object | [
"generate",
"a",
"message",
"for",
"loglevel",
"WARN"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/logging/Log4jLoggerImpl.java#L192-L195 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/logging/Log4jLoggerImpl.java | Log4jLoggerImpl.error | public final void error(Object pObject)
{
getLogger().log(FQCN, Level.ERROR, pObject, null);
} | java | public final void error(Object pObject)
{
getLogger().log(FQCN, Level.ERROR, pObject, null);
} | [
"public",
"final",
"void",
"error",
"(",
"Object",
"pObject",
")",
"{",
"getLogger",
"(",
")",
".",
"log",
"(",
"FQCN",
",",
"Level",
".",
"ERROR",
",",
"pObject",
",",
"null",
")",
";",
"}"
] | generate a message for loglevel ERROR
@param pObject the message Object | [
"generate",
"a",
"message",
"for",
"loglevel",
"ERROR"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/logging/Log4jLoggerImpl.java#L202-L205 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/logging/Log4jLoggerImpl.java | Log4jLoggerImpl.fatal | public final void fatal(Object pObject)
{
getLogger().log(FQCN, Level.FATAL, pObject, null);
} | java | public final void fatal(Object pObject)
{
getLogger().log(FQCN, Level.FATAL, pObject, null);
} | [
"public",
"final",
"void",
"fatal",
"(",
"Object",
"pObject",
")",
"{",
"getLogger",
"(",
")",
".",
"log",
"(",
"FQCN",
",",
"Level",
".",
"FATAL",
",",
"pObject",
",",
"null",
")",
";",
"}"
] | generate a message for loglevel FATAL
@param pObject the message Object | [
"generate",
"a",
"message",
"for",
"loglevel",
"FATAL"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/logging/Log4jLoggerImpl.java#L212-L215 | train |
geomajas/geomajas-project-server | plugin/layer-hibernate/hibernate/src/main/java/org/geomajas/layer/hibernate/HibernateLayerUtil.java | HibernateLayerUtil.getPropertyClass | protected Class<?> getPropertyClass(ClassMetadata meta, String propertyName) throws HibernateLayerException {
// try to assure the correct separator is used
propertyName = propertyName.replace(XPATH_SEPARATOR, SEPARATOR);
if (propertyName.contains(SEPARATOR)) {
String directProperty = propertyName.substring(0, propertyName.indexOf(SEPARATOR));
try {
Type prop = meta.getPropertyType(directProperty);
if (prop.isCollectionType()) {
CollectionType coll = (CollectionType) prop;
prop = coll.getElementType((SessionFactoryImplementor) sessionFactory);
}
ClassMetadata propMeta = sessionFactory.getClassMetadata(prop.getReturnedClass());
return getPropertyClass(propMeta, propertyName.substring(propertyName.indexOf(SEPARATOR) + 1));
} catch (HibernateException e) {
throw new HibernateLayerException(e, ExceptionCode.HIBERNATE_COULD_NOT_RESOLVE, propertyName,
meta.getEntityName());
}
} else {
try {
return meta.getPropertyType(propertyName).getReturnedClass();
} catch (HibernateException e) {
throw new HibernateLayerException(e, ExceptionCode.HIBERNATE_COULD_NOT_RESOLVE, propertyName,
meta.getEntityName());
}
}
} | java | protected Class<?> getPropertyClass(ClassMetadata meta, String propertyName) throws HibernateLayerException {
// try to assure the correct separator is used
propertyName = propertyName.replace(XPATH_SEPARATOR, SEPARATOR);
if (propertyName.contains(SEPARATOR)) {
String directProperty = propertyName.substring(0, propertyName.indexOf(SEPARATOR));
try {
Type prop = meta.getPropertyType(directProperty);
if (prop.isCollectionType()) {
CollectionType coll = (CollectionType) prop;
prop = coll.getElementType((SessionFactoryImplementor) sessionFactory);
}
ClassMetadata propMeta = sessionFactory.getClassMetadata(prop.getReturnedClass());
return getPropertyClass(propMeta, propertyName.substring(propertyName.indexOf(SEPARATOR) + 1));
} catch (HibernateException e) {
throw new HibernateLayerException(e, ExceptionCode.HIBERNATE_COULD_NOT_RESOLVE, propertyName,
meta.getEntityName());
}
} else {
try {
return meta.getPropertyType(propertyName).getReturnedClass();
} catch (HibernateException e) {
throw new HibernateLayerException(e, ExceptionCode.HIBERNATE_COULD_NOT_RESOLVE, propertyName,
meta.getEntityName());
}
}
} | [
"protected",
"Class",
"<",
"?",
">",
"getPropertyClass",
"(",
"ClassMetadata",
"meta",
",",
"String",
"propertyName",
")",
"throws",
"HibernateLayerException",
"{",
"// try to assure the correct separator is used",
"propertyName",
"=",
"propertyName",
".",
"replace",
"(",
"XPATH_SEPARATOR",
",",
"SEPARATOR",
")",
";",
"if",
"(",
"propertyName",
".",
"contains",
"(",
"SEPARATOR",
")",
")",
"{",
"String",
"directProperty",
"=",
"propertyName",
".",
"substring",
"(",
"0",
",",
"propertyName",
".",
"indexOf",
"(",
"SEPARATOR",
")",
")",
";",
"try",
"{",
"Type",
"prop",
"=",
"meta",
".",
"getPropertyType",
"(",
"directProperty",
")",
";",
"if",
"(",
"prop",
".",
"isCollectionType",
"(",
")",
")",
"{",
"CollectionType",
"coll",
"=",
"(",
"CollectionType",
")",
"prop",
";",
"prop",
"=",
"coll",
".",
"getElementType",
"(",
"(",
"SessionFactoryImplementor",
")",
"sessionFactory",
")",
";",
"}",
"ClassMetadata",
"propMeta",
"=",
"sessionFactory",
".",
"getClassMetadata",
"(",
"prop",
".",
"getReturnedClass",
"(",
")",
")",
";",
"return",
"getPropertyClass",
"(",
"propMeta",
",",
"propertyName",
".",
"substring",
"(",
"propertyName",
".",
"indexOf",
"(",
"SEPARATOR",
")",
"+",
"1",
")",
")",
";",
"}",
"catch",
"(",
"HibernateException",
"e",
")",
"{",
"throw",
"new",
"HibernateLayerException",
"(",
"e",
",",
"ExceptionCode",
".",
"HIBERNATE_COULD_NOT_RESOLVE",
",",
"propertyName",
",",
"meta",
".",
"getEntityName",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"try",
"{",
"return",
"meta",
".",
"getPropertyType",
"(",
"propertyName",
")",
".",
"getReturnedClass",
"(",
")",
";",
"}",
"catch",
"(",
"HibernateException",
"e",
")",
"{",
"throw",
"new",
"HibernateLayerException",
"(",
"e",
",",
"ExceptionCode",
".",
"HIBERNATE_COULD_NOT_RESOLVE",
",",
"propertyName",
",",
"meta",
".",
"getEntityName",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Return the class of one of the properties of another class from which the Hibernate metadata is given.
@param meta
The parent class to search a property in.
@param propertyName
The name of the property in the parent class (provided by meta)
@return Returns the class of the property in question.
@throws HibernateLayerException
Throws an exception if the property name could not be retrieved. | [
"Return",
"the",
"class",
"of",
"one",
"of",
"the",
"properties",
"of",
"another",
"class",
"from",
"which",
"the",
"Hibernate",
"metadata",
"is",
"given",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/layer-hibernate/hibernate/src/main/java/org/geomajas/layer/hibernate/HibernateLayerUtil.java#L102-L128 | train |
geomajas/geomajas-project-server | plugin/layer-hibernate/hibernate/src/main/java/org/geomajas/layer/hibernate/HibernateLayerUtil.java | HibernateLayerUtil.setSessionFactory | public void setSessionFactory(SessionFactory sessionFactory) throws HibernateLayerException {
try {
this.sessionFactory = sessionFactory;
if (null != layerInfo) {
entityMetadata = sessionFactory.getClassMetadata(layerInfo.getFeatureInfo().getDataSourceName());
}
} catch (Exception e) { // NOSONAR
throw new HibernateLayerException(e, ExceptionCode.HIBERNATE_NO_SESSION_FACTORY);
}
} | java | public void setSessionFactory(SessionFactory sessionFactory) throws HibernateLayerException {
try {
this.sessionFactory = sessionFactory;
if (null != layerInfo) {
entityMetadata = sessionFactory.getClassMetadata(layerInfo.getFeatureInfo().getDataSourceName());
}
} catch (Exception e) { // NOSONAR
throw new HibernateLayerException(e, ExceptionCode.HIBERNATE_NO_SESSION_FACTORY);
}
} | [
"public",
"void",
"setSessionFactory",
"(",
"SessionFactory",
"sessionFactory",
")",
"throws",
"HibernateLayerException",
"{",
"try",
"{",
"this",
".",
"sessionFactory",
"=",
"sessionFactory",
";",
"if",
"(",
"null",
"!=",
"layerInfo",
")",
"{",
"entityMetadata",
"=",
"sessionFactory",
".",
"getClassMetadata",
"(",
"layerInfo",
".",
"getFeatureInfo",
"(",
")",
".",
"getDataSourceName",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// NOSONAR",
"throw",
"new",
"HibernateLayerException",
"(",
"e",
",",
"ExceptionCode",
".",
"HIBERNATE_NO_SESSION_FACTORY",
")",
";",
"}",
"}"
] | Set session factory.
@param sessionFactory session factory
@throws HibernateLayerException could not get class metadata for data source | [
"Set",
"session",
"factory",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/layer-hibernate/hibernate/src/main/java/org/geomajas/layer/hibernate/HibernateLayerUtil.java#L145-L154 | train |
kuali/ojb-1.0.4 | src/jdori/org/apache/ojb/jdori/sql/Helper.java | Helper.getJDOClass | static JDOClass getJDOClass(Class c)
{
JDOClass rc = null;
try
{
JavaModelFactory javaModelFactory = RuntimeJavaModelFactory.getInstance();
JavaModel javaModel = javaModelFactory.getJavaModel(c.getClassLoader());
JDOModel m = JDOModelFactoryImpl.getInstance().getJDOModel(javaModel);
rc = m.getJDOClass(c.getName());
}
catch (RuntimeException ex)
{
throw new JDOFatalInternalException("Not a JDO class: " + c.getName());
}
return rc;
} | java | static JDOClass getJDOClass(Class c)
{
JDOClass rc = null;
try
{
JavaModelFactory javaModelFactory = RuntimeJavaModelFactory.getInstance();
JavaModel javaModel = javaModelFactory.getJavaModel(c.getClassLoader());
JDOModel m = JDOModelFactoryImpl.getInstance().getJDOModel(javaModel);
rc = m.getJDOClass(c.getName());
}
catch (RuntimeException ex)
{
throw new JDOFatalInternalException("Not a JDO class: " + c.getName());
}
return rc;
} | [
"static",
"JDOClass",
"getJDOClass",
"(",
"Class",
"c",
")",
"{",
"JDOClass",
"rc",
"=",
"null",
";",
"try",
"{",
"JavaModelFactory",
"javaModelFactory",
"=",
"RuntimeJavaModelFactory",
".",
"getInstance",
"(",
")",
";",
"JavaModel",
"javaModel",
"=",
"javaModelFactory",
".",
"getJavaModel",
"(",
"c",
".",
"getClassLoader",
"(",
")",
")",
";",
"JDOModel",
"m",
"=",
"JDOModelFactoryImpl",
".",
"getInstance",
"(",
")",
".",
"getJDOModel",
"(",
"javaModel",
")",
";",
"rc",
"=",
"m",
".",
"getJDOClass",
"(",
"c",
".",
"getName",
"(",
")",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"ex",
")",
"{",
"throw",
"new",
"JDOFatalInternalException",
"(",
"\"Not a JDO class: \"",
"+",
"c",
".",
"getName",
"(",
")",
")",
";",
"}",
"return",
"rc",
";",
"}"
] | this method looks up the appropriate JDOClass for a given persistent Class.
It uses the JDOModel to perfom this lookup.
@param c the persistent Class
@return the JDOCLass object | [
"this",
"method",
"looks",
"up",
"the",
"appropriate",
"JDOClass",
"for",
"a",
"given",
"persistent",
"Class",
".",
"It",
"uses",
"the",
"JDOModel",
"to",
"perfom",
"this",
"lookup",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/jdori/org/apache/ojb/jdori/sql/Helper.java#L43-L58 | train |
kuali/ojb-1.0.4 | src/jdori/org/apache/ojb/jdori/sql/Helper.java | Helper.getLCState | static Object getLCState(StateManagerInternal sm)
{
// unfortunately the LifeCycleState classes are package private.
// so we have to do some dirty reflection hack to access them
try
{
Field myLC = sm.getClass().getDeclaredField("myLC");
myLC.setAccessible(true);
return myLC.get(sm);
}
catch (NoSuchFieldException e)
{
return e;
}
catch (IllegalAccessException e)
{
return e;
}
} | java | static Object getLCState(StateManagerInternal sm)
{
// unfortunately the LifeCycleState classes are package private.
// so we have to do some dirty reflection hack to access them
try
{
Field myLC = sm.getClass().getDeclaredField("myLC");
myLC.setAccessible(true);
return myLC.get(sm);
}
catch (NoSuchFieldException e)
{
return e;
}
catch (IllegalAccessException e)
{
return e;
}
} | [
"static",
"Object",
"getLCState",
"(",
"StateManagerInternal",
"sm",
")",
"{",
"// unfortunately the LifeCycleState classes are package private.\r",
"// so we have to do some dirty reflection hack to access them\r",
"try",
"{",
"Field",
"myLC",
"=",
"sm",
".",
"getClass",
"(",
")",
".",
"getDeclaredField",
"(",
"\"myLC\"",
")",
";",
"myLC",
".",
"setAccessible",
"(",
"true",
")",
";",
"return",
"myLC",
".",
"get",
"(",
"sm",
")",
";",
"}",
"catch",
"(",
"NoSuchFieldException",
"e",
")",
"{",
"return",
"e",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"return",
"e",
";",
"}",
"}"
] | obtains the internal JDO lifecycle state of the input StatemanagerInternal.
This Method is helpful to display persistent objects internal state.
@param sm the StateManager to be inspected
@return the LifeCycleState of a StateManager instance | [
"obtains",
"the",
"internal",
"JDO",
"lifecycle",
"state",
"of",
"the",
"input",
"StatemanagerInternal",
".",
"This",
"Method",
"is",
"helpful",
"to",
"display",
"persistent",
"objects",
"internal",
"state",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/jdori/org/apache/ojb/jdori/sql/Helper.java#L66-L84 | train |
geomajas/geomajas-project-server | plugin/layer-tms/tms/src/main/java/org/geomajas/layer/tms/TmsLayer.java | TmsLayer.postConstruct | @PostConstruct
protected void postConstruct() throws GeomajasException {
if (null == baseTmsUrl) {
throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "baseTmsUrl");
}
// Make sure we have a base URL we can work with:
if ((baseTmsUrl.startsWith("http://") || baseTmsUrl.startsWith("https://")) && !baseTmsUrl.endsWith("/")) {
baseTmsUrl += "/";
}
// Make sure there is a correct RasterLayerInfo object:
if (layerInfo == null || layerInfo == UNUSABLE_LAYER_INFO) {
try {
tileMap = configurationService.getCapabilities(this);
version = tileMap.getVersion();
extension = tileMap.getTileFormat().getExtension();
layerInfo = configurationService.asLayerInfo(tileMap);
usable = true;
} catch (TmsLayerException e) {
// a layer needs an info object to keep the DtoConfigurationPostProcessor happy !
layerInfo = UNUSABLE_LAYER_INFO;
usable = false;
log.warn("The layer could not be correctly initialized: " + getId(), e);
}
} else if (extension == null) {
throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "extension");
}
if (layerInfo != null) {
// Finally prepare some often needed values:
state = new TileServiceState(geoService, layerInfo);
// when proxying the real url will be resolved later on, just use a simple one for now
boolean proxying = useCache || useProxy || null != authentication;
if (tileMap != null && !proxying) {
urlBuilder = new TileMapUrlBuilder(tileMap);
} else {
urlBuilder = new SimpleTmsUrlBuilder(extension);
}
}
} | java | @PostConstruct
protected void postConstruct() throws GeomajasException {
if (null == baseTmsUrl) {
throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "baseTmsUrl");
}
// Make sure we have a base URL we can work with:
if ((baseTmsUrl.startsWith("http://") || baseTmsUrl.startsWith("https://")) && !baseTmsUrl.endsWith("/")) {
baseTmsUrl += "/";
}
// Make sure there is a correct RasterLayerInfo object:
if (layerInfo == null || layerInfo == UNUSABLE_LAYER_INFO) {
try {
tileMap = configurationService.getCapabilities(this);
version = tileMap.getVersion();
extension = tileMap.getTileFormat().getExtension();
layerInfo = configurationService.asLayerInfo(tileMap);
usable = true;
} catch (TmsLayerException e) {
// a layer needs an info object to keep the DtoConfigurationPostProcessor happy !
layerInfo = UNUSABLE_LAYER_INFO;
usable = false;
log.warn("The layer could not be correctly initialized: " + getId(), e);
}
} else if (extension == null) {
throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "extension");
}
if (layerInfo != null) {
// Finally prepare some often needed values:
state = new TileServiceState(geoService, layerInfo);
// when proxying the real url will be resolved later on, just use a simple one for now
boolean proxying = useCache || useProxy || null != authentication;
if (tileMap != null && !proxying) {
urlBuilder = new TileMapUrlBuilder(tileMap);
} else {
urlBuilder = new SimpleTmsUrlBuilder(extension);
}
}
} | [
"@",
"PostConstruct",
"protected",
"void",
"postConstruct",
"(",
")",
"throws",
"GeomajasException",
"{",
"if",
"(",
"null",
"==",
"baseTmsUrl",
")",
"{",
"throw",
"new",
"GeomajasException",
"(",
"ExceptionCode",
".",
"PARAMETER_MISSING",
",",
"\"baseTmsUrl\"",
")",
";",
"}",
"// Make sure we have a base URL we can work with:",
"if",
"(",
"(",
"baseTmsUrl",
".",
"startsWith",
"(",
"\"http://\"",
")",
"||",
"baseTmsUrl",
".",
"startsWith",
"(",
"\"https://\"",
")",
")",
"&&",
"!",
"baseTmsUrl",
".",
"endsWith",
"(",
"\"/\"",
")",
")",
"{",
"baseTmsUrl",
"+=",
"\"/\"",
";",
"}",
"// Make sure there is a correct RasterLayerInfo object:",
"if",
"(",
"layerInfo",
"==",
"null",
"||",
"layerInfo",
"==",
"UNUSABLE_LAYER_INFO",
")",
"{",
"try",
"{",
"tileMap",
"=",
"configurationService",
".",
"getCapabilities",
"(",
"this",
")",
";",
"version",
"=",
"tileMap",
".",
"getVersion",
"(",
")",
";",
"extension",
"=",
"tileMap",
".",
"getTileFormat",
"(",
")",
".",
"getExtension",
"(",
")",
";",
"layerInfo",
"=",
"configurationService",
".",
"asLayerInfo",
"(",
"tileMap",
")",
";",
"usable",
"=",
"true",
";",
"}",
"catch",
"(",
"TmsLayerException",
"e",
")",
"{",
"// a layer needs an info object to keep the DtoConfigurationPostProcessor happy !",
"layerInfo",
"=",
"UNUSABLE_LAYER_INFO",
";",
"usable",
"=",
"false",
";",
"log",
".",
"warn",
"(",
"\"The layer could not be correctly initialized: \"",
"+",
"getId",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"else",
"if",
"(",
"extension",
"==",
"null",
")",
"{",
"throw",
"new",
"GeomajasException",
"(",
"ExceptionCode",
".",
"PARAMETER_MISSING",
",",
"\"extension\"",
")",
";",
"}",
"if",
"(",
"layerInfo",
"!=",
"null",
")",
"{",
"// Finally prepare some often needed values:",
"state",
"=",
"new",
"TileServiceState",
"(",
"geoService",
",",
"layerInfo",
")",
";",
"// when proxying the real url will be resolved later on, just use a simple one for now",
"boolean",
"proxying",
"=",
"useCache",
"||",
"useProxy",
"||",
"null",
"!=",
"authentication",
";",
"if",
"(",
"tileMap",
"!=",
"null",
"&&",
"!",
"proxying",
")",
"{",
"urlBuilder",
"=",
"new",
"TileMapUrlBuilder",
"(",
"tileMap",
")",
";",
"}",
"else",
"{",
"urlBuilder",
"=",
"new",
"SimpleTmsUrlBuilder",
"(",
"extension",
")",
";",
"}",
"}",
"}"
] | Finish initializing the service. | [
"Finish",
"initializing",
"the",
"service",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/layer-tms/tms/src/main/java/org/geomajas/layer/tms/TmsLayer.java#L127-L167 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/odmg/locking/InMemoryLockMapImpl.java | InMemoryLockMapImpl.getReaders | public Collection getReaders(Object obj)
{
checkTimedOutLocks();
Identity oid = new Identity(obj,getBroker());
return getReaders(oid);
} | java | public Collection getReaders(Object obj)
{
checkTimedOutLocks();
Identity oid = new Identity(obj,getBroker());
return getReaders(oid);
} | [
"public",
"Collection",
"getReaders",
"(",
"Object",
"obj",
")",
"{",
"checkTimedOutLocks",
"(",
")",
";",
"Identity",
"oid",
"=",
"new",
"Identity",
"(",
"obj",
",",
"getBroker",
"(",
")",
")",
";",
"return",
"getReaders",
"(",
"oid",
")",
";",
"}"
] | returns a collection of Reader LockEntries for object obj.
If no LockEntries could be found an empty Vector is returned. | [
"returns",
"a",
"collection",
"of",
"Reader",
"LockEntries",
"for",
"object",
"obj",
".",
"If",
"no",
"LockEntries",
"could",
"be",
"found",
"an",
"empty",
"Vector",
"is",
"returned",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/locking/InMemoryLockMapImpl.java#L104-L109 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/odmg/locking/InMemoryLockMapImpl.java | InMemoryLockMapImpl.removeTimedOutLocks | private void removeTimedOutLocks(long timeout)
{
int count = 0;
long maxAge = System.currentTimeMillis() - timeout;
boolean breakFromLoop = false;
ObjectLocks temp = null;
synchronized (locktable)
{
Iterator it = locktable.values().iterator();
/**
* run this loop while:
* - we have more in the iterator
* - the breakFromLoop flag hasn't been set
* - we haven't removed more than the limit for this cleaning iteration.
*/
while (it.hasNext() && !breakFromLoop && (count <= MAX_LOCKS_TO_CLEAN))
{
temp = (ObjectLocks) it.next();
if (temp.getWriter() != null)
{
if (temp.getWriter().getTimestamp() < maxAge)
{
// writer has timed out, set it to null
temp.setWriter(null);
}
}
if (temp.getYoungestReader() < maxAge)
{
// all readers are older than timeout.
temp.getReaders().clear();
if (temp.getWriter() == null)
{
// all readers and writer are older than timeout,
// remove the objectLock from the iterator (which
// is backed by the map, so it will be removed.
it.remove();
}
}
else
{
// we need to walk each reader.
Iterator readerIt = temp.getReaders().values().iterator();
LockEntry readerLock = null;
while (readerIt.hasNext())
{
readerLock = (LockEntry) readerIt.next();
if (readerLock.getTimestamp() < maxAge)
{
// this read lock is old, remove it.
readerIt.remove();
}
}
}
count++;
}
}
} | java | private void removeTimedOutLocks(long timeout)
{
int count = 0;
long maxAge = System.currentTimeMillis() - timeout;
boolean breakFromLoop = false;
ObjectLocks temp = null;
synchronized (locktable)
{
Iterator it = locktable.values().iterator();
/**
* run this loop while:
* - we have more in the iterator
* - the breakFromLoop flag hasn't been set
* - we haven't removed more than the limit for this cleaning iteration.
*/
while (it.hasNext() && !breakFromLoop && (count <= MAX_LOCKS_TO_CLEAN))
{
temp = (ObjectLocks) it.next();
if (temp.getWriter() != null)
{
if (temp.getWriter().getTimestamp() < maxAge)
{
// writer has timed out, set it to null
temp.setWriter(null);
}
}
if (temp.getYoungestReader() < maxAge)
{
// all readers are older than timeout.
temp.getReaders().clear();
if (temp.getWriter() == null)
{
// all readers and writer are older than timeout,
// remove the objectLock from the iterator (which
// is backed by the map, so it will be removed.
it.remove();
}
}
else
{
// we need to walk each reader.
Iterator readerIt = temp.getReaders().values().iterator();
LockEntry readerLock = null;
while (readerIt.hasNext())
{
readerLock = (LockEntry) readerIt.next();
if (readerLock.getTimestamp() < maxAge)
{
// this read lock is old, remove it.
readerIt.remove();
}
}
}
count++;
}
}
} | [
"private",
"void",
"removeTimedOutLocks",
"(",
"long",
"timeout",
")",
"{",
"int",
"count",
"=",
"0",
";",
"long",
"maxAge",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"timeout",
";",
"boolean",
"breakFromLoop",
"=",
"false",
";",
"ObjectLocks",
"temp",
"=",
"null",
";",
"synchronized",
"(",
"locktable",
")",
"{",
"Iterator",
"it",
"=",
"locktable",
".",
"values",
"(",
")",
".",
"iterator",
"(",
")",
";",
"/**\r\n\t * run this loop while:\r\n\t * - we have more in the iterator\r\n\t * - the breakFromLoop flag hasn't been set\r\n\t * - we haven't removed more than the limit for this cleaning iteration.\r\n\t */",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
"&&",
"!",
"breakFromLoop",
"&&",
"(",
"count",
"<=",
"MAX_LOCKS_TO_CLEAN",
")",
")",
"{",
"temp",
"=",
"(",
"ObjectLocks",
")",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"temp",
".",
"getWriter",
"(",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"temp",
".",
"getWriter",
"(",
")",
".",
"getTimestamp",
"(",
")",
"<",
"maxAge",
")",
"{",
"// writer has timed out, set it to null\r",
"temp",
".",
"setWriter",
"(",
"null",
")",
";",
"}",
"}",
"if",
"(",
"temp",
".",
"getYoungestReader",
"(",
")",
"<",
"maxAge",
")",
"{",
"// all readers are older than timeout.\r",
"temp",
".",
"getReaders",
"(",
")",
".",
"clear",
"(",
")",
";",
"if",
"(",
"temp",
".",
"getWriter",
"(",
")",
"==",
"null",
")",
"{",
"// all readers and writer are older than timeout,\r",
"// remove the objectLock from the iterator (which\r",
"// is backed by the map, so it will be removed.\r",
"it",
".",
"remove",
"(",
")",
";",
"}",
"}",
"else",
"{",
"// we need to walk each reader.\r",
"Iterator",
"readerIt",
"=",
"temp",
".",
"getReaders",
"(",
")",
".",
"values",
"(",
")",
".",
"iterator",
"(",
")",
";",
"LockEntry",
"readerLock",
"=",
"null",
";",
"while",
"(",
"readerIt",
".",
"hasNext",
"(",
")",
")",
"{",
"readerLock",
"=",
"(",
"LockEntry",
")",
"readerIt",
".",
"next",
"(",
")",
";",
"if",
"(",
"readerLock",
".",
"getTimestamp",
"(",
")",
"<",
"maxAge",
")",
"{",
"// this read lock is old, remove it.\r",
"readerIt",
".",
"remove",
"(",
")",
";",
"}",
"}",
"}",
"count",
"++",
";",
"}",
"}",
"}"
] | removes all timed out lock entries from the persistent storage.
The timeout value can be set in the OJB properties file. | [
"removes",
"all",
"timed",
"out",
"lock",
"entries",
"from",
"the",
"persistent",
"storage",
".",
"The",
"timeout",
"value",
"can",
"be",
"set",
"in",
"the",
"OJB",
"properties",
"file",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/locking/InMemoryLockMapImpl.java#L395-L451 | train |
gsi-upm/BeastTool | beast-tool/src/main/java/es/upm/dit/gsi/beast/platform/jadex/JadexConnector.java | JadexConnector.createAgent | public void createAgent(String agent_name, String path) {
IComponentIdentifier agent = cmsService.createComponent(agent_name,
path, null, null).get(new ThreadSuspendable());
createdAgents.put(agent_name, agent);
} | java | public void createAgent(String agent_name, String path) {
IComponentIdentifier agent = cmsService.createComponent(agent_name,
path, null, null).get(new ThreadSuspendable());
createdAgents.put(agent_name, agent);
} | [
"public",
"void",
"createAgent",
"(",
"String",
"agent_name",
",",
"String",
"path",
")",
"{",
"IComponentIdentifier",
"agent",
"=",
"cmsService",
".",
"createComponent",
"(",
"agent_name",
",",
"path",
",",
"null",
",",
"null",
")",
".",
"get",
"(",
"new",
"ThreadSuspendable",
"(",
")",
")",
";",
"createdAgents",
".",
"put",
"(",
"agent_name",
",",
"agent",
")",
";",
"}"
] | Creates a real agent in the platform
@param agent_name
The name that the agent is gonna have in the platform
@param path
The path of the description (xml) of the agent | [
"Creates",
"a",
"real",
"agent",
"in",
"the",
"platform"
] | cc7fdc75cb818c5d60802aaf32c27829e0ca144c | https://github.com/gsi-upm/BeastTool/blob/cc7fdc75cb818c5d60802aaf32c27829e0ca144c/beast-tool/src/main/java/es/upm/dit/gsi/beast/platform/jadex/JadexConnector.java#L112-L116 | train |
gsi-upm/BeastTool | beast-tool/src/main/java/es/upm/dit/gsi/beast/platform/jadex/JadexConnector.java | JadexConnector.getAgentsExternalAccess | public IExternalAccess getAgentsExternalAccess(String agent_name) {
return cmsService.getExternalAccess(getAgentID(agent_name)).get(
new ThreadSuspendable());
} | java | public IExternalAccess getAgentsExternalAccess(String agent_name) {
return cmsService.getExternalAccess(getAgentID(agent_name)).get(
new ThreadSuspendable());
} | [
"public",
"IExternalAccess",
"getAgentsExternalAccess",
"(",
"String",
"agent_name",
")",
"{",
"return",
"cmsService",
".",
"getExternalAccess",
"(",
"getAgentID",
"(",
"agent_name",
")",
")",
".",
"get",
"(",
"new",
"ThreadSuspendable",
"(",
")",
")",
";",
"}"
] | This method searches in the Component Management Service, so given an
agent name returns its IExternalAccess
@param agent_name
The name of the agent in the platform
@return The IComponentIdentifier of the agent in the platform | [
"This",
"method",
"searches",
"in",
"the",
"Component",
"Management",
"Service",
"so",
"given",
"an",
"agent",
"name",
"returns",
"its",
"IExternalAccess"
] | cc7fdc75cb818c5d60802aaf32c27829e0ca144c | https://github.com/gsi-upm/BeastTool/blob/cc7fdc75cb818c5d60802aaf32c27829e0ca144c/beast-tool/src/main/java/es/upm/dit/gsi/beast/platform/jadex/JadexConnector.java#L139-L143 | train |
Axway/Grapes | server/src/main/java/org/axway/grapes/server/core/ProductHandler.java | ProductHandler.create | public void create(final DbProduct dbProduct) {
if(repositoryHandler.getProduct(dbProduct.getName()) != null){
throw new WebApplicationException(Response.status(Response.Status.CONFLICT).entity("Product already exist!").build());
}
repositoryHandler.store(dbProduct);
} | java | public void create(final DbProduct dbProduct) {
if(repositoryHandler.getProduct(dbProduct.getName()) != null){
throw new WebApplicationException(Response.status(Response.Status.CONFLICT).entity("Product already exist!").build());
}
repositoryHandler.store(dbProduct);
} | [
"public",
"void",
"create",
"(",
"final",
"DbProduct",
"dbProduct",
")",
"{",
"if",
"(",
"repositoryHandler",
".",
"getProduct",
"(",
"dbProduct",
".",
"getName",
"(",
")",
")",
"!=",
"null",
")",
"{",
"throw",
"new",
"WebApplicationException",
"(",
"Response",
".",
"status",
"(",
"Response",
".",
"Status",
".",
"CONFLICT",
")",
".",
"entity",
"(",
"\"Product already exist!\"",
")",
".",
"build",
"(",
")",
")",
";",
"}",
"repositoryHandler",
".",
"store",
"(",
"dbProduct",
")",
";",
"}"
] | Creates a new Product in Grapes database
@param dbProduct DbProduct | [
"Creates",
"a",
"new",
"Product",
"in",
"Grapes",
"database"
] | ce9cc73d85f83eaa5fbc991abb593915a8c8374e | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/core/ProductHandler.java#L31-L37 | train |
Axway/Grapes | server/src/main/java/org/axway/grapes/server/core/ProductHandler.java | ProductHandler.getProduct | public DbProduct getProduct(final String name) {
final DbProduct dbProduct = repositoryHandler.getProduct(name);
if(dbProduct == null){
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND)
.entity("Product " + name + " does not exist.").build());
}
return dbProduct;
} | java | public DbProduct getProduct(final String name) {
final DbProduct dbProduct = repositoryHandler.getProduct(name);
if(dbProduct == null){
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND)
.entity("Product " + name + " does not exist.").build());
}
return dbProduct;
} | [
"public",
"DbProduct",
"getProduct",
"(",
"final",
"String",
"name",
")",
"{",
"final",
"DbProduct",
"dbProduct",
"=",
"repositoryHandler",
".",
"getProduct",
"(",
"name",
")",
";",
"if",
"(",
"dbProduct",
"==",
"null",
")",
"{",
"throw",
"new",
"WebApplicationException",
"(",
"Response",
".",
"status",
"(",
"Response",
".",
"Status",
".",
"NOT_FOUND",
")",
".",
"entity",
"(",
"\"Product \"",
"+",
"name",
"+",
"\" does not exist.\"",
")",
".",
"build",
"(",
")",
")",
";",
"}",
"return",
"dbProduct",
";",
"}"
] | Returns a product regarding its name
@param name String
@return DbProduct | [
"Returns",
"a",
"product",
"regarding",
"its",
"name"
] | ce9cc73d85f83eaa5fbc991abb593915a8c8374e | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/core/ProductHandler.java#L63-L72 | train |
Axway/Grapes | server/src/main/java/org/axway/grapes/server/core/ProductHandler.java | ProductHandler.deleteProduct | public void deleteProduct(final String name) {
final DbProduct dbProduct = getProduct(name);
repositoryHandler.deleteProduct(dbProduct.getName());
} | java | public void deleteProduct(final String name) {
final DbProduct dbProduct = getProduct(name);
repositoryHandler.deleteProduct(dbProduct.getName());
} | [
"public",
"void",
"deleteProduct",
"(",
"final",
"String",
"name",
")",
"{",
"final",
"DbProduct",
"dbProduct",
"=",
"getProduct",
"(",
"name",
")",
";",
"repositoryHandler",
".",
"deleteProduct",
"(",
"dbProduct",
".",
"getName",
"(",
")",
")",
";",
"}"
] | Deletes a product from the database
@param name String | [
"Deletes",
"a",
"product",
"from",
"the",
"database"
] | ce9cc73d85f83eaa5fbc991abb593915a8c8374e | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/core/ProductHandler.java#L79-L82 | train |
Axway/Grapes | server/src/main/java/org/axway/grapes/server/core/ProductHandler.java | ProductHandler.setProductModules | public void setProductModules(final String name, final List<String> moduleNames) {
final DbProduct dbProduct = getProduct(name);
dbProduct.setModules(moduleNames);
repositoryHandler.store(dbProduct);
} | java | public void setProductModules(final String name, final List<String> moduleNames) {
final DbProduct dbProduct = getProduct(name);
dbProduct.setModules(moduleNames);
repositoryHandler.store(dbProduct);
} | [
"public",
"void",
"setProductModules",
"(",
"final",
"String",
"name",
",",
"final",
"List",
"<",
"String",
">",
"moduleNames",
")",
"{",
"final",
"DbProduct",
"dbProduct",
"=",
"getProduct",
"(",
"name",
")",
";",
"dbProduct",
".",
"setModules",
"(",
"moduleNames",
")",
";",
"repositoryHandler",
".",
"store",
"(",
"dbProduct",
")",
";",
"}"
] | Patches the product module names
@param name String
@param moduleNames List<String> | [
"Patches",
"the",
"product",
"module",
"names"
] | ce9cc73d85f83eaa5fbc991abb593915a8c8374e | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/core/ProductHandler.java#L90-L94 | train |
gsi-upm/BeastTool | beast-tool/src/main/java/es/upm/dit/gsi/beast/platform/jade/JadeAgentIntrospector.java | JadeAgentIntrospector.getAgentPlans | @Override
public Object[] getAgentPlans(String agent_name, Connector connector) {
// Not supported in JADE
connector.getLogger().warning("Non suported method for Jade Platform. There is no plans in Jade platform.");
throw new java.lang.UnsupportedOperationException("Non suported method for Jade Platform. There is no extra properties.");
} | java | @Override
public Object[] getAgentPlans(String agent_name, Connector connector) {
// Not supported in JADE
connector.getLogger().warning("Non suported method for Jade Platform. There is no plans in Jade platform.");
throw new java.lang.UnsupportedOperationException("Non suported method for Jade Platform. There is no extra properties.");
} | [
"@",
"Override",
"public",
"Object",
"[",
"]",
"getAgentPlans",
"(",
"String",
"agent_name",
",",
"Connector",
"connector",
")",
"{",
"// Not supported in JADE",
"connector",
".",
"getLogger",
"(",
")",
".",
"warning",
"(",
"\"Non suported method for Jade Platform. There is no plans in Jade platform.\"",
")",
";",
"throw",
"new",
"java",
".",
"lang",
".",
"UnsupportedOperationException",
"(",
"\"Non suported method for Jade Platform. There is no extra properties.\"",
")",
";",
"}"
] | Non-supported in JadeAgentIntrospector | [
"Non",
"-",
"supported",
"in",
"JadeAgentIntrospector"
] | cc7fdc75cb818c5d60802aaf32c27829e0ca144c | https://github.com/gsi-upm/BeastTool/blob/cc7fdc75cb818c5d60802aaf32c27829e0ca144c/beast-tool/src/main/java/es/upm/dit/gsi/beast/platform/jade/JadeAgentIntrospector.java#L115-L120 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java | CollectionProxyDefaultImpl.loadSize | protected synchronized int loadSize() throws PersistenceBrokerException
{
PersistenceBroker broker = getBroker();
try
{
return broker.getCount(getQuery());
}
catch (Exception ex)
{
throw new PersistenceBrokerException(ex);
}
finally
{
releaseBroker(broker);
}
} | java | protected synchronized int loadSize() throws PersistenceBrokerException
{
PersistenceBroker broker = getBroker();
try
{
return broker.getCount(getQuery());
}
catch (Exception ex)
{
throw new PersistenceBrokerException(ex);
}
finally
{
releaseBroker(broker);
}
} | [
"protected",
"synchronized",
"int",
"loadSize",
"(",
")",
"throws",
"PersistenceBrokerException",
"{",
"PersistenceBroker",
"broker",
"=",
"getBroker",
"(",
")",
";",
"try",
"{",
"return",
"broker",
".",
"getCount",
"(",
"getQuery",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"PersistenceBrokerException",
"(",
"ex",
")",
";",
"}",
"finally",
"{",
"releaseBroker",
"(",
"broker",
")",
";",
"}",
"}"
] | Determines the number of elements that the query would return. Override this
method if the size shall be determined in a specific way.
@return The number of elements | [
"Determines",
"the",
"number",
"of",
"elements",
"that",
"the",
"query",
"would",
"return",
".",
"Override",
"this",
"method",
"if",
"the",
"size",
"shall",
"be",
"determined",
"in",
"a",
"specific",
"way",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java#L145-L160 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java | CollectionProxyDefaultImpl.loadData | protected Collection loadData() throws PersistenceBrokerException
{
PersistenceBroker broker = getBroker();
try
{
Collection result;
if (_data != null) // could be set by listener
{
result = _data;
}
else if (_size != 0)
{
// TODO: returned ManageableCollection should extend Collection to avoid
// this cast
result = (Collection) broker.getCollectionByQuery(getCollectionClass(), getQuery());
}
else
{
result = (Collection)getCollectionClass().newInstance();
}
return result;
}
catch (Exception ex)
{
throw new PersistenceBrokerException(ex);
}
finally
{
releaseBroker(broker);
}
} | java | protected Collection loadData() throws PersistenceBrokerException
{
PersistenceBroker broker = getBroker();
try
{
Collection result;
if (_data != null) // could be set by listener
{
result = _data;
}
else if (_size != 0)
{
// TODO: returned ManageableCollection should extend Collection to avoid
// this cast
result = (Collection) broker.getCollectionByQuery(getCollectionClass(), getQuery());
}
else
{
result = (Collection)getCollectionClass().newInstance();
}
return result;
}
catch (Exception ex)
{
throw new PersistenceBrokerException(ex);
}
finally
{
releaseBroker(broker);
}
} | [
"protected",
"Collection",
"loadData",
"(",
")",
"throws",
"PersistenceBrokerException",
"{",
"PersistenceBroker",
"broker",
"=",
"getBroker",
"(",
")",
";",
"try",
"{",
"Collection",
"result",
";",
"if",
"(",
"_data",
"!=",
"null",
")",
"// could be set by listener\r",
"{",
"result",
"=",
"_data",
";",
"}",
"else",
"if",
"(",
"_size",
"!=",
"0",
")",
"{",
"// TODO: returned ManageableCollection should extend Collection to avoid\r",
"// this cast\r",
"result",
"=",
"(",
"Collection",
")",
"broker",
".",
"getCollectionByQuery",
"(",
"getCollectionClass",
"(",
")",
",",
"getQuery",
"(",
")",
")",
";",
"}",
"else",
"{",
"result",
"=",
"(",
"Collection",
")",
"getCollectionClass",
"(",
")",
".",
"newInstance",
"(",
")",
";",
"}",
"return",
"result",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"PersistenceBrokerException",
"(",
"ex",
")",
";",
"}",
"finally",
"{",
"releaseBroker",
"(",
"broker",
")",
";",
"}",
"}"
] | Loads the data from the database. Override this method if the objects
shall be loaded in a specific way.
@return The loaded data | [
"Loads",
"the",
"data",
"from",
"the",
"database",
".",
"Override",
"this",
"method",
"if",
"the",
"objects",
"shall",
"be",
"loaded",
"in",
"a",
"specific",
"way",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java#L178-L209 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java | CollectionProxyDefaultImpl.beforeLoading | protected void beforeLoading()
{
if (_listeners != null)
{
CollectionProxyListener listener;
if (_perThreadDescriptorsEnabled) {
loadProfileIfNeeded();
}
for (int idx = _listeners.size() - 1; idx >= 0; idx--)
{
listener = (CollectionProxyListener)_listeners.get(idx);
listener.beforeLoading(this);
}
}
} | java | protected void beforeLoading()
{
if (_listeners != null)
{
CollectionProxyListener listener;
if (_perThreadDescriptorsEnabled) {
loadProfileIfNeeded();
}
for (int idx = _listeners.size() - 1; idx >= 0; idx--)
{
listener = (CollectionProxyListener)_listeners.get(idx);
listener.beforeLoading(this);
}
}
} | [
"protected",
"void",
"beforeLoading",
"(",
")",
"{",
"if",
"(",
"_listeners",
"!=",
"null",
")",
"{",
"CollectionProxyListener",
"listener",
";",
"if",
"(",
"_perThreadDescriptorsEnabled",
")",
"{",
"loadProfileIfNeeded",
"(",
")",
";",
"}",
"for",
"(",
"int",
"idx",
"=",
"_listeners",
".",
"size",
"(",
")",
"-",
"1",
";",
"idx",
">=",
"0",
";",
"idx",
"--",
")",
"{",
"listener",
"=",
"(",
"CollectionProxyListener",
")",
"_listeners",
".",
"get",
"(",
"idx",
")",
";",
"listener",
".",
"beforeLoading",
"(",
"this",
")",
";",
"}",
"}",
"}"
] | Notifies all listeners that the data is about to be loaded. | [
"Notifies",
"all",
"listeners",
"that",
"the",
"data",
"is",
"about",
"to",
"be",
"loaded",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java#L214-L229 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java | CollectionProxyDefaultImpl.clear | public void clear()
{
Class collClass = getCollectionClass();
// ECER: assure we notify all objects being removed,
// necessary for RemovalAwareCollections...
if (IRemovalAwareCollection.class.isAssignableFrom(collClass))
{
getData().clear();
}
else
{
Collection coll;
// BRJ: use an empty collection so isLoaded will return true
// for non RemovalAwareCollections only !!
try
{
coll = (Collection) collClass.newInstance();
}
catch (Exception e)
{
coll = new ArrayList();
}
setData(coll);
}
_size = 0;
} | java | public void clear()
{
Class collClass = getCollectionClass();
// ECER: assure we notify all objects being removed,
// necessary for RemovalAwareCollections...
if (IRemovalAwareCollection.class.isAssignableFrom(collClass))
{
getData().clear();
}
else
{
Collection coll;
// BRJ: use an empty collection so isLoaded will return true
// for non RemovalAwareCollections only !!
try
{
coll = (Collection) collClass.newInstance();
}
catch (Exception e)
{
coll = new ArrayList();
}
setData(coll);
}
_size = 0;
} | [
"public",
"void",
"clear",
"(",
")",
"{",
"Class",
"collClass",
"=",
"getCollectionClass",
"(",
")",
";",
"// ECER: assure we notify all objects being removed, \r",
"// necessary for RemovalAwareCollections...\r",
"if",
"(",
"IRemovalAwareCollection",
".",
"class",
".",
"isAssignableFrom",
"(",
"collClass",
")",
")",
"{",
"getData",
"(",
")",
".",
"clear",
"(",
")",
";",
"}",
"else",
"{",
"Collection",
"coll",
";",
"// BRJ: use an empty collection so isLoaded will return true\r",
"// for non RemovalAwareCollections only !! \r",
"try",
"{",
"coll",
"=",
"(",
"Collection",
")",
"collClass",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"coll",
"=",
"new",
"ArrayList",
"(",
")",
";",
"}",
"setData",
"(",
"coll",
")",
";",
"}",
"_size",
"=",
"0",
";",
"}"
] | Clears the proxy. A cleared proxy is defined as loaded
@see Collection#clear() | [
"Clears",
"the",
"proxy",
".",
"A",
"cleared",
"proxy",
"is",
"defined",
"as",
"loaded"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java#L363-L390 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java | CollectionProxyDefaultImpl.releaseBroker | protected synchronized void releaseBroker(PersistenceBroker broker)
{
/*
arminw:
only close the broker instance if we get
it from the PBF, do nothing if we obtain it from
PBThreadMapping
*/
if (broker != null && _needsClose)
{
_needsClose = false;
broker.close();
}
} | java | protected synchronized void releaseBroker(PersistenceBroker broker)
{
/*
arminw:
only close the broker instance if we get
it from the PBF, do nothing if we obtain it from
PBThreadMapping
*/
if (broker != null && _needsClose)
{
_needsClose = false;
broker.close();
}
} | [
"protected",
"synchronized",
"void",
"releaseBroker",
"(",
"PersistenceBroker",
"broker",
")",
"{",
"/*\r\n arminw:\r\n only close the broker instance if we get\r\n it from the PBF, do nothing if we obtain it from\r\n PBThreadMapping\r\n */",
"if",
"(",
"broker",
"!=",
"null",
"&&",
"_needsClose",
")",
"{",
"_needsClose",
"=",
"false",
";",
"broker",
".",
"close",
"(",
")",
";",
"}",
"}"
] | Release the broker instance. | [
"Release",
"the",
"broker",
"instance",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java#L415-L428 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java | CollectionProxyDefaultImpl.getBroker | protected synchronized PersistenceBroker getBroker() throws PBFactoryException
{
/*
mkalen:
NB! The loadProfileIfNeeded must be called _before_ acquiring a broker below,
since some methods in PersistenceBrokerImpl will keep a local reference to
the descriptor repository that was active during broker construction/refresh
(not checking the repository beeing used on method invocation).
PersistenceBrokerImpl#getClassDescriptor(Class clazz) is such a method,
that will throw ClassNotPersistenceCapableException on the following scenario:
(All happens in one thread only):
t0: activate per-thread metadata changes
t1: load, register and activate profile A
t2: load object O1 witch collection proxy C to objects {O2} (C stores profile key K(A))
t3: close broker from t2
t4: load, register and activate profile B
t5: reference O1.getO2Collection, causing C loadData() to be invoked
t6: C calls getBroker
broker B is created and descriptorRepository is set to descriptors from profile B
t7: C calls loadProfileIfNeeded, re-activating profile A
t8: C calls B.getCollectionByQuery
t9: B gets callback (via QueryReferenceBroker) to getClassDescriptor
the local descriptorRepository from t6 is used!
=> We will now try to query for {O2} with profile B
(even though we re-activated profile A in t7)
=> ClassNotPersistenceCapableException
Keeping loadProfileIfNeeded() at the start of this method changes everything from t6:
t6: C calls loadProfileIfNeeded, re-activating profile A
t7: C calls getBroker,
broker B is created and descriptorRepository is set to descriptors from profile A
t8: C calls B.getCollectionByQuery
t9: B gets callback to getClassDescriptor,
the local descriptorRepository from t6 is used
=> We query for {O2} with profile A
=> All good :-)
*/
if (_perThreadDescriptorsEnabled)
{
loadProfileIfNeeded();
}
PersistenceBroker broker;
if (getBrokerKey() == null)
{
/*
arminw:
if no PBKey is set we throw an exception, because we don't
know which PB (connection) should be used.
*/
throw new OJBRuntimeException("Can't find associated PBKey. Need PBKey to obtain a valid" +
"PersistenceBroker instance from intern resources.");
}
// first try to use the current threaded broker to avoid blocking
broker = PersistenceBrokerThreadMapping.currentPersistenceBroker(getBrokerKey());
// current broker not found or was closed, create a intern new one
if (broker == null || broker.isClosed())
{
broker = PersistenceBrokerFactory.createPersistenceBroker(getBrokerKey());
// signal that we use a new internal obtained PB instance to read the
// data and that this instance have to be closed after use
_needsClose = true;
}
return broker;
} | java | protected synchronized PersistenceBroker getBroker() throws PBFactoryException
{
/*
mkalen:
NB! The loadProfileIfNeeded must be called _before_ acquiring a broker below,
since some methods in PersistenceBrokerImpl will keep a local reference to
the descriptor repository that was active during broker construction/refresh
(not checking the repository beeing used on method invocation).
PersistenceBrokerImpl#getClassDescriptor(Class clazz) is such a method,
that will throw ClassNotPersistenceCapableException on the following scenario:
(All happens in one thread only):
t0: activate per-thread metadata changes
t1: load, register and activate profile A
t2: load object O1 witch collection proxy C to objects {O2} (C stores profile key K(A))
t3: close broker from t2
t4: load, register and activate profile B
t5: reference O1.getO2Collection, causing C loadData() to be invoked
t6: C calls getBroker
broker B is created and descriptorRepository is set to descriptors from profile B
t7: C calls loadProfileIfNeeded, re-activating profile A
t8: C calls B.getCollectionByQuery
t9: B gets callback (via QueryReferenceBroker) to getClassDescriptor
the local descriptorRepository from t6 is used!
=> We will now try to query for {O2} with profile B
(even though we re-activated profile A in t7)
=> ClassNotPersistenceCapableException
Keeping loadProfileIfNeeded() at the start of this method changes everything from t6:
t6: C calls loadProfileIfNeeded, re-activating profile A
t7: C calls getBroker,
broker B is created and descriptorRepository is set to descriptors from profile A
t8: C calls B.getCollectionByQuery
t9: B gets callback to getClassDescriptor,
the local descriptorRepository from t6 is used
=> We query for {O2} with profile A
=> All good :-)
*/
if (_perThreadDescriptorsEnabled)
{
loadProfileIfNeeded();
}
PersistenceBroker broker;
if (getBrokerKey() == null)
{
/*
arminw:
if no PBKey is set we throw an exception, because we don't
know which PB (connection) should be used.
*/
throw new OJBRuntimeException("Can't find associated PBKey. Need PBKey to obtain a valid" +
"PersistenceBroker instance from intern resources.");
}
// first try to use the current threaded broker to avoid blocking
broker = PersistenceBrokerThreadMapping.currentPersistenceBroker(getBrokerKey());
// current broker not found or was closed, create a intern new one
if (broker == null || broker.isClosed())
{
broker = PersistenceBrokerFactory.createPersistenceBroker(getBrokerKey());
// signal that we use a new internal obtained PB instance to read the
// data and that this instance have to be closed after use
_needsClose = true;
}
return broker;
} | [
"protected",
"synchronized",
"PersistenceBroker",
"getBroker",
"(",
")",
"throws",
"PBFactoryException",
"{",
"/*\r\n mkalen:\r\n NB! The loadProfileIfNeeded must be called _before_ acquiring a broker below,\r\n since some methods in PersistenceBrokerImpl will keep a local reference to\r\n the descriptor repository that was active during broker construction/refresh\r\n (not checking the repository beeing used on method invocation).\r\n\r\n PersistenceBrokerImpl#getClassDescriptor(Class clazz) is such a method,\r\n that will throw ClassNotPersistenceCapableException on the following scenario:\r\n\r\n (All happens in one thread only):\r\n t0: activate per-thread metadata changes\r\n t1: load, register and activate profile A\r\n t2: load object O1 witch collection proxy C to objects {O2} (C stores profile key K(A))\r\n t3: close broker from t2\r\n t4: load, register and activate profile B\r\n t5: reference O1.getO2Collection, causing C loadData() to be invoked\r\n t6: C calls getBroker\r\n broker B is created and descriptorRepository is set to descriptors from profile B\r\n t7: C calls loadProfileIfNeeded, re-activating profile A\r\n t8: C calls B.getCollectionByQuery\r\n t9: B gets callback (via QueryReferenceBroker) to getClassDescriptor\r\n the local descriptorRepository from t6 is used!\r\n => We will now try to query for {O2} with profile B\r\n (even though we re-activated profile A in t7)\r\n => ClassNotPersistenceCapableException\r\n\r\n Keeping loadProfileIfNeeded() at the start of this method changes everything from t6:\r\n t6: C calls loadProfileIfNeeded, re-activating profile A\r\n t7: C calls getBroker,\r\n broker B is created and descriptorRepository is set to descriptors from profile A\r\n t8: C calls B.getCollectionByQuery\r\n t9: B gets callback to getClassDescriptor,\r\n the local descriptorRepository from t6 is used\r\n => We query for {O2} with profile A\r\n => All good :-)\r\n */",
"if",
"(",
"_perThreadDescriptorsEnabled",
")",
"{",
"loadProfileIfNeeded",
"(",
")",
";",
"}",
"PersistenceBroker",
"broker",
";",
"if",
"(",
"getBrokerKey",
"(",
")",
"==",
"null",
")",
"{",
"/*\r\n arminw:\r\n if no PBKey is set we throw an exception, because we don't\r\n know which PB (connection) should be used.\r\n */",
"throw",
"new",
"OJBRuntimeException",
"(",
"\"Can't find associated PBKey. Need PBKey to obtain a valid\"",
"+",
"\"PersistenceBroker instance from intern resources.\"",
")",
";",
"}",
"// first try to use the current threaded broker to avoid blocking\r",
"broker",
"=",
"PersistenceBrokerThreadMapping",
".",
"currentPersistenceBroker",
"(",
"getBrokerKey",
"(",
")",
")",
";",
"// current broker not found or was closed, create a intern new one\r",
"if",
"(",
"broker",
"==",
"null",
"||",
"broker",
".",
"isClosed",
"(",
")",
")",
"{",
"broker",
"=",
"PersistenceBrokerFactory",
".",
"createPersistenceBroker",
"(",
"getBrokerKey",
"(",
")",
")",
";",
"// signal that we use a new internal obtained PB instance to read the\r",
"// data and that this instance have to be closed after use\r",
"_needsClose",
"=",
"true",
";",
"}",
"return",
"broker",
";",
"}"
] | Acquires a broker instance. If no PBKey is available a runtime exception will be thrown.
@return A broker instance | [
"Acquires",
"a",
"broker",
"instance",
".",
"If",
"no",
"PBKey",
"is",
"available",
"a",
"runtime",
"exception",
"will",
"be",
"thrown",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java#L435-L501 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java | CollectionProxyDefaultImpl.addListener | public synchronized void addListener(CollectionProxyListener listener)
{
if (_listeners == null)
{
_listeners = new ArrayList();
}
// to avoid multi-add of same listener, do check
if(!_listeners.contains(listener))
{
_listeners.add(listener);
}
} | java | public synchronized void addListener(CollectionProxyListener listener)
{
if (_listeners == null)
{
_listeners = new ArrayList();
}
// to avoid multi-add of same listener, do check
if(!_listeners.contains(listener))
{
_listeners.add(listener);
}
} | [
"public",
"synchronized",
"void",
"addListener",
"(",
"CollectionProxyListener",
"listener",
")",
"{",
"if",
"(",
"_listeners",
"==",
"null",
")",
"{",
"_listeners",
"=",
"new",
"ArrayList",
"(",
")",
";",
"}",
"// to avoid multi-add of same listener, do check\r",
"if",
"(",
"!",
"_listeners",
".",
"contains",
"(",
"listener",
")",
")",
"{",
"_listeners",
".",
"add",
"(",
"listener",
")",
";",
"}",
"}"
] | Adds a listener to this collection.
@param listener The listener to add | [
"Adds",
"a",
"listener",
"to",
"this",
"collection",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java#L633-L644 | train |
jembi/openhim-mediator-engine-java | src/main/java/org/openhim/mediator/engine/RegistrationConfig.java | RegistrationConfig.getURN | public String getURN() throws InvalidRegistrationContentException {
if (parsedConfig==null || parsedConfig.urn==null || parsedConfig.urn.trim().isEmpty()) {
throw new InvalidRegistrationContentException("Invalid registration config - failed to read mediator URN");
}
return parsedConfig.urn;
} | java | public String getURN() throws InvalidRegistrationContentException {
if (parsedConfig==null || parsedConfig.urn==null || parsedConfig.urn.trim().isEmpty()) {
throw new InvalidRegistrationContentException("Invalid registration config - failed to read mediator URN");
}
return parsedConfig.urn;
} | [
"public",
"String",
"getURN",
"(",
")",
"throws",
"InvalidRegistrationContentException",
"{",
"if",
"(",
"parsedConfig",
"==",
"null",
"||",
"parsedConfig",
".",
"urn",
"==",
"null",
"||",
"parsedConfig",
".",
"urn",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidRegistrationContentException",
"(",
"\"Invalid registration config - failed to read mediator URN\"",
")",
";",
"}",
"return",
"parsedConfig",
".",
"urn",
";",
"}"
] | Reads and returns the mediator URN from the JSON content.
@see #RegistrationConfig(String) | [
"Reads",
"and",
"returns",
"the",
"mediator",
"URN",
"from",
"the",
"JSON",
"content",
"."
] | 02adc0da4302cbde26cc9a5c1ce91ec6277e4f68 | https://github.com/jembi/openhim-mediator-engine-java/blob/02adc0da4302cbde26cc9a5c1ce91ec6277e4f68/src/main/java/org/openhim/mediator/engine/RegistrationConfig.java#L95-L100 | train |
foundation-runtime/logging | logging-log4j/src/main/java/org/apache/log4j/helpers/FileHelper.java | FileHelper.deleteExisting | public boolean deleteExisting(final File file) {
if (!file.exists()) {
return true;
}
boolean deleted = false;
if (file.canWrite()) {
deleted = file.delete();
} else {
LogLog.debug(file + " is not writeable for delete (retrying)");
}
if (!deleted) {
if (!file.exists()) {
deleted = true;
} else {
file.delete();
deleted = (!file.exists());
}
}
return deleted;
} | java | public boolean deleteExisting(final File file) {
if (!file.exists()) {
return true;
}
boolean deleted = false;
if (file.canWrite()) {
deleted = file.delete();
} else {
LogLog.debug(file + " is not writeable for delete (retrying)");
}
if (!deleted) {
if (!file.exists()) {
deleted = true;
} else {
file.delete();
deleted = (!file.exists());
}
}
return deleted;
} | [
"public",
"boolean",
"deleteExisting",
"(",
"final",
"File",
"file",
")",
"{",
"if",
"(",
"!",
"file",
".",
"exists",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"boolean",
"deleted",
"=",
"false",
";",
"if",
"(",
"file",
".",
"canWrite",
"(",
")",
")",
"{",
"deleted",
"=",
"file",
".",
"delete",
"(",
")",
";",
"}",
"else",
"{",
"LogLog",
".",
"debug",
"(",
"file",
"+",
"\" is not writeable for delete (retrying)\"",
")",
";",
"}",
"if",
"(",
"!",
"deleted",
")",
"{",
"if",
"(",
"!",
"file",
".",
"exists",
"(",
")",
")",
"{",
"deleted",
"=",
"true",
";",
"}",
"else",
"{",
"file",
".",
"delete",
"(",
")",
";",
"deleted",
"=",
"(",
"!",
"file",
".",
"exists",
"(",
")",
")",
";",
"}",
"}",
"return",
"deleted",
";",
"}"
] | Delete with retry.
@param file
@return <tt>true</tt> if the file was successfully deleted. | [
"Delete",
"with",
"retry",
"."
] | cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6 | https://github.com/foundation-runtime/logging/blob/cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6/logging-log4j/src/main/java/org/apache/log4j/helpers/FileHelper.java#L72-L91 | train |
foundation-runtime/logging | logging-log4j/src/main/java/org/apache/log4j/helpers/FileHelper.java | FileHelper.rename | public boolean rename(final File from, final File to) {
boolean renamed = false;
if (this.isWriteable(from)) {
renamed = from.renameTo(to);
} else {
LogLog.debug(from + " is not writeable for rename (retrying)");
}
if (!renamed) {
from.renameTo(to);
renamed = (!from.exists());
}
return renamed;
} | java | public boolean rename(final File from, final File to) {
boolean renamed = false;
if (this.isWriteable(from)) {
renamed = from.renameTo(to);
} else {
LogLog.debug(from + " is not writeable for rename (retrying)");
}
if (!renamed) {
from.renameTo(to);
renamed = (!from.exists());
}
return renamed;
} | [
"public",
"boolean",
"rename",
"(",
"final",
"File",
"from",
",",
"final",
"File",
"to",
")",
"{",
"boolean",
"renamed",
"=",
"false",
";",
"if",
"(",
"this",
".",
"isWriteable",
"(",
"from",
")",
")",
"{",
"renamed",
"=",
"from",
".",
"renameTo",
"(",
"to",
")",
";",
"}",
"else",
"{",
"LogLog",
".",
"debug",
"(",
"from",
"+",
"\" is not writeable for rename (retrying)\"",
")",
";",
"}",
"if",
"(",
"!",
"renamed",
")",
"{",
"from",
".",
"renameTo",
"(",
"to",
")",
";",
"renamed",
"=",
"(",
"!",
"from",
".",
"exists",
"(",
")",
")",
";",
"}",
"return",
"renamed",
";",
"}"
] | Rename with retry.
@param from
@param to
@return <tt>true</tt> if the file was successfully renamed. | [
"Rename",
"with",
"retry",
"."
] | cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6 | https://github.com/foundation-runtime/logging/blob/cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6/logging-log4j/src/main/java/org/apache/log4j/helpers/FileHelper.java#L100-L112 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/odmg/ImplementationImpl.java | ImplementationImpl.registerOpenDatabase | protected synchronized void registerOpenDatabase(DatabaseImpl newDB)
{
DatabaseImpl old_db = getCurrentDatabase();
if (old_db != null)
{
try
{
if (old_db.isOpen())
{
log.warn("## There is still an opened database, close old one ##");
old_db.close();
}
}
catch (Throwable t)
{
//ignore
}
}
if (log.isDebugEnabled()) log.debug("Set current database " + newDB + " PBKey was " + newDB.getPBKey());
setCurrentDatabase(newDB);
// usedDatabases.add(newDB.getPBKey());
} | java | protected synchronized void registerOpenDatabase(DatabaseImpl newDB)
{
DatabaseImpl old_db = getCurrentDatabase();
if (old_db != null)
{
try
{
if (old_db.isOpen())
{
log.warn("## There is still an opened database, close old one ##");
old_db.close();
}
}
catch (Throwable t)
{
//ignore
}
}
if (log.isDebugEnabled()) log.debug("Set current database " + newDB + " PBKey was " + newDB.getPBKey());
setCurrentDatabase(newDB);
// usedDatabases.add(newDB.getPBKey());
} | [
"protected",
"synchronized",
"void",
"registerOpenDatabase",
"(",
"DatabaseImpl",
"newDB",
")",
"{",
"DatabaseImpl",
"old_db",
"=",
"getCurrentDatabase",
"(",
")",
";",
"if",
"(",
"old_db",
"!=",
"null",
")",
"{",
"try",
"{",
"if",
"(",
"old_db",
".",
"isOpen",
"(",
")",
")",
"{",
"log",
".",
"warn",
"(",
"\"## There is still an opened database, close old one ##\"",
")",
";",
"old_db",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"//ignore\r",
"}",
"}",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"log",
".",
"debug",
"(",
"\"Set current database \"",
"+",
"newDB",
"+",
"\" PBKey was \"",
"+",
"newDB",
".",
"getPBKey",
"(",
")",
")",
";",
"setCurrentDatabase",
"(",
"newDB",
")",
";",
"// usedDatabases.add(newDB.getPBKey());\r",
"}"
] | Register opened database via the PBKey. | [
"Register",
"opened",
"database",
"via",
"the",
"PBKey",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/ImplementationImpl.java#L329-L350 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/metadata/DescriptorBase.java | DescriptorBase.getAttributeNames | public String[] getAttributeNames()
{
Set keys = (attributeMap == null ? new HashSet() : attributeMap.keySet());
String[] result = new String[keys.size()];
keys.toArray(result);
return result;
} | java | public String[] getAttributeNames()
{
Set keys = (attributeMap == null ? new HashSet() : attributeMap.keySet());
String[] result = new String[keys.size()];
keys.toArray(result);
return result;
} | [
"public",
"String",
"[",
"]",
"getAttributeNames",
"(",
")",
"{",
"Set",
"keys",
"=",
"(",
"attributeMap",
"==",
"null",
"?",
"new",
"HashSet",
"(",
")",
":",
"attributeMap",
".",
"keySet",
"(",
")",
")",
";",
"String",
"[",
"]",
"result",
"=",
"new",
"String",
"[",
"keys",
".",
"size",
"(",
")",
"]",
";",
"keys",
".",
"toArray",
"(",
"result",
")",
";",
"return",
"result",
";",
"}"
] | Returns an array of the names of all atributes of this descriptor.
@return The list of attribute names (will not be <code>null</code>) | [
"Returns",
"an",
"array",
"of",
"the",
"names",
"of",
"all",
"atributes",
"of",
"this",
"descriptor",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/DescriptorBase.java#L99-L106 | train |
kuali/ojb-1.0.4 | src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java | ModelConstraints.check | public void check(ModelDef modelDef, String checkLevel) throws ConstraintException
{
ensureReferencedKeys(modelDef, checkLevel);
checkReferenceForeignkeys(modelDef, checkLevel);
checkCollectionForeignkeys(modelDef, checkLevel);
checkKeyModifications(modelDef, checkLevel);
} | java | public void check(ModelDef modelDef, String checkLevel) throws ConstraintException
{
ensureReferencedKeys(modelDef, checkLevel);
checkReferenceForeignkeys(modelDef, checkLevel);
checkCollectionForeignkeys(modelDef, checkLevel);
checkKeyModifications(modelDef, checkLevel);
} | [
"public",
"void",
"check",
"(",
"ModelDef",
"modelDef",
",",
"String",
"checkLevel",
")",
"throws",
"ConstraintException",
"{",
"ensureReferencedKeys",
"(",
"modelDef",
",",
"checkLevel",
")",
";",
"checkReferenceForeignkeys",
"(",
"modelDef",
",",
"checkLevel",
")",
";",
"checkCollectionForeignkeys",
"(",
"modelDef",
",",
"checkLevel",
")",
";",
"checkKeyModifications",
"(",
"modelDef",
",",
"checkLevel",
")",
";",
"}"
] | Checks the given model.
@param modelDef The model
@param checkLevel The amount of checks to perform
@exception ConstraintException If a constraint has been violated | [
"Checks",
"the",
"given",
"model",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java#L49-L55 | train |
kuali/ojb-1.0.4 | src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java | ModelConstraints.ensureReferencedPKs | private void ensureReferencedPKs(ModelDef modelDef, ReferenceDescriptorDef refDef) throws ConstraintException
{
String targetClassName = refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF);
ClassDescriptorDef targetClassDef = modelDef.getClass(targetClassName);
ensurePKsFromHierarchy(targetClassDef);
} | java | private void ensureReferencedPKs(ModelDef modelDef, ReferenceDescriptorDef refDef) throws ConstraintException
{
String targetClassName = refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF);
ClassDescriptorDef targetClassDef = modelDef.getClass(targetClassName);
ensurePKsFromHierarchy(targetClassDef);
} | [
"private",
"void",
"ensureReferencedPKs",
"(",
"ModelDef",
"modelDef",
",",
"ReferenceDescriptorDef",
"refDef",
")",
"throws",
"ConstraintException",
"{",
"String",
"targetClassName",
"=",
"refDef",
".",
"getProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_CLASS_REF",
")",
";",
"ClassDescriptorDef",
"targetClassDef",
"=",
"modelDef",
".",
"getClass",
"(",
"targetClassName",
")",
";",
"ensurePKsFromHierarchy",
"(",
"targetClassDef",
")",
";",
"}"
] | Ensures that the primary keys required by the given reference are present in the referenced class.
@param modelDef The model
@param refDef The reference
@throws ConstraintException If there is a conflict between the primary keys | [
"Ensures",
"that",
"the",
"primary",
"keys",
"required",
"by",
"the",
"given",
"reference",
"are",
"present",
"in",
"the",
"referenced",
"class",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java#L109-L115 | train |
kuali/ojb-1.0.4 | src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java | ModelConstraints.ensureReferencedPKs | private void ensureReferencedPKs(ModelDef modelDef, CollectionDescriptorDef collDef) throws ConstraintException
{
String elementClassName = collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
ClassDescriptorDef elementClassDef = modelDef.getClass(elementClassName);
String indirTable = collDef.getProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE);
String localKey = collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
String remoteKey = collDef.getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY);
boolean hasRemoteKey = remoteKey != null;
ArrayList fittingCollections = new ArrayList();
// we're checking for the fitting remote collection(s) and also
// use their foreignkey as remote-foreignkey in the original collection definition
for (Iterator it = elementClassDef.getAllExtentClasses(); it.hasNext();)
{
ClassDescriptorDef subTypeDef = (ClassDescriptorDef)it.next();
// find the collection in the element class that has the same indirection table
for (Iterator collIt = subTypeDef.getCollections(); collIt.hasNext();)
{
CollectionDescriptorDef curCollDef = (CollectionDescriptorDef)collIt.next();
if (indirTable.equals(curCollDef.getProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE)) &&
(collDef != curCollDef) &&
(!hasRemoteKey || CommaListIterator.sameLists(remoteKey, curCollDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY))) &&
(!curCollDef.hasProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY) ||
CommaListIterator.sameLists(localKey, curCollDef.getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY))))
{
fittingCollections.add(curCollDef);
}
}
}
if (!fittingCollections.isEmpty())
{
// if there is more than one, check that they match, i.e. that they all have the same foreignkeys
if (!hasRemoteKey && (fittingCollections.size() > 1))
{
CollectionDescriptorDef firstCollDef = (CollectionDescriptorDef)fittingCollections.get(0);
String foreignKey = firstCollDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
for (int idx = 1; idx < fittingCollections.size(); idx++)
{
CollectionDescriptorDef curCollDef = (CollectionDescriptorDef)fittingCollections.get(idx);
if (!CommaListIterator.sameLists(foreignKey, curCollDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY)))
{
throw new ConstraintException("Cannot determine the element-side collection that corresponds to the collection "+
collDef.getName()+" in type "+collDef.getOwner().getName()+
" because there are at least two different collections that would fit."+
" Specifying remote-foreignkey in the original collection "+collDef.getName()+
" will perhaps help");
}
}
// store the found keys at the collections
collDef.setProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY, foreignKey);
for (int idx = 0; idx < fittingCollections.size(); idx++)
{
CollectionDescriptorDef curCollDef = (CollectionDescriptorDef)fittingCollections.get(idx);
curCollDef.setProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY, localKey);
}
}
}
// copy subclass pk fields into target class (if not already present)
ensurePKsFromHierarchy(elementClassDef);
} | java | private void ensureReferencedPKs(ModelDef modelDef, CollectionDescriptorDef collDef) throws ConstraintException
{
String elementClassName = collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
ClassDescriptorDef elementClassDef = modelDef.getClass(elementClassName);
String indirTable = collDef.getProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE);
String localKey = collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
String remoteKey = collDef.getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY);
boolean hasRemoteKey = remoteKey != null;
ArrayList fittingCollections = new ArrayList();
// we're checking for the fitting remote collection(s) and also
// use their foreignkey as remote-foreignkey in the original collection definition
for (Iterator it = elementClassDef.getAllExtentClasses(); it.hasNext();)
{
ClassDescriptorDef subTypeDef = (ClassDescriptorDef)it.next();
// find the collection in the element class that has the same indirection table
for (Iterator collIt = subTypeDef.getCollections(); collIt.hasNext();)
{
CollectionDescriptorDef curCollDef = (CollectionDescriptorDef)collIt.next();
if (indirTable.equals(curCollDef.getProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE)) &&
(collDef != curCollDef) &&
(!hasRemoteKey || CommaListIterator.sameLists(remoteKey, curCollDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY))) &&
(!curCollDef.hasProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY) ||
CommaListIterator.sameLists(localKey, curCollDef.getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY))))
{
fittingCollections.add(curCollDef);
}
}
}
if (!fittingCollections.isEmpty())
{
// if there is more than one, check that they match, i.e. that they all have the same foreignkeys
if (!hasRemoteKey && (fittingCollections.size() > 1))
{
CollectionDescriptorDef firstCollDef = (CollectionDescriptorDef)fittingCollections.get(0);
String foreignKey = firstCollDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
for (int idx = 1; idx < fittingCollections.size(); idx++)
{
CollectionDescriptorDef curCollDef = (CollectionDescriptorDef)fittingCollections.get(idx);
if (!CommaListIterator.sameLists(foreignKey, curCollDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY)))
{
throw new ConstraintException("Cannot determine the element-side collection that corresponds to the collection "+
collDef.getName()+" in type "+collDef.getOwner().getName()+
" because there are at least two different collections that would fit."+
" Specifying remote-foreignkey in the original collection "+collDef.getName()+
" will perhaps help");
}
}
// store the found keys at the collections
collDef.setProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY, foreignKey);
for (int idx = 0; idx < fittingCollections.size(); idx++)
{
CollectionDescriptorDef curCollDef = (CollectionDescriptorDef)fittingCollections.get(idx);
curCollDef.setProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY, localKey);
}
}
}
// copy subclass pk fields into target class (if not already present)
ensurePKsFromHierarchy(elementClassDef);
} | [
"private",
"void",
"ensureReferencedPKs",
"(",
"ModelDef",
"modelDef",
",",
"CollectionDescriptorDef",
"collDef",
")",
"throws",
"ConstraintException",
"{",
"String",
"elementClassName",
"=",
"collDef",
".",
"getProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_ELEMENT_CLASS_REF",
")",
";",
"ClassDescriptorDef",
"elementClassDef",
"=",
"modelDef",
".",
"getClass",
"(",
"elementClassName",
")",
";",
"String",
"indirTable",
"=",
"collDef",
".",
"getProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_INDIRECTION_TABLE",
")",
";",
"String",
"localKey",
"=",
"collDef",
".",
"getProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_FOREIGNKEY",
")",
";",
"String",
"remoteKey",
"=",
"collDef",
".",
"getProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_REMOTE_FOREIGNKEY",
")",
";",
"boolean",
"hasRemoteKey",
"=",
"remoteKey",
"!=",
"null",
";",
"ArrayList",
"fittingCollections",
"=",
"new",
"ArrayList",
"(",
")",
";",
"// we're checking for the fitting remote collection(s) and also\r",
"// use their foreignkey as remote-foreignkey in the original collection definition\r",
"for",
"(",
"Iterator",
"it",
"=",
"elementClassDef",
".",
"getAllExtentClasses",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"ClassDescriptorDef",
"subTypeDef",
"=",
"(",
"ClassDescriptorDef",
")",
"it",
".",
"next",
"(",
")",
";",
"// find the collection in the element class that has the same indirection table\r",
"for",
"(",
"Iterator",
"collIt",
"=",
"subTypeDef",
".",
"getCollections",
"(",
")",
";",
"collIt",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"CollectionDescriptorDef",
"curCollDef",
"=",
"(",
"CollectionDescriptorDef",
")",
"collIt",
".",
"next",
"(",
")",
";",
"if",
"(",
"indirTable",
".",
"equals",
"(",
"curCollDef",
".",
"getProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_INDIRECTION_TABLE",
")",
")",
"&&",
"(",
"collDef",
"!=",
"curCollDef",
")",
"&&",
"(",
"!",
"hasRemoteKey",
"||",
"CommaListIterator",
".",
"sameLists",
"(",
"remoteKey",
",",
"curCollDef",
".",
"getProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_FOREIGNKEY",
")",
")",
")",
"&&",
"(",
"!",
"curCollDef",
".",
"hasProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_REMOTE_FOREIGNKEY",
")",
"||",
"CommaListIterator",
".",
"sameLists",
"(",
"localKey",
",",
"curCollDef",
".",
"getProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_REMOTE_FOREIGNKEY",
")",
")",
")",
")",
"{",
"fittingCollections",
".",
"add",
"(",
"curCollDef",
")",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"fittingCollections",
".",
"isEmpty",
"(",
")",
")",
"{",
"// if there is more than one, check that they match, i.e. that they all have the same foreignkeys\r",
"if",
"(",
"!",
"hasRemoteKey",
"&&",
"(",
"fittingCollections",
".",
"size",
"(",
")",
">",
"1",
")",
")",
"{",
"CollectionDescriptorDef",
"firstCollDef",
"=",
"(",
"CollectionDescriptorDef",
")",
"fittingCollections",
".",
"get",
"(",
"0",
")",
";",
"String",
"foreignKey",
"=",
"firstCollDef",
".",
"getProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_FOREIGNKEY",
")",
";",
"for",
"(",
"int",
"idx",
"=",
"1",
";",
"idx",
"<",
"fittingCollections",
".",
"size",
"(",
")",
";",
"idx",
"++",
")",
"{",
"CollectionDescriptorDef",
"curCollDef",
"=",
"(",
"CollectionDescriptorDef",
")",
"fittingCollections",
".",
"get",
"(",
"idx",
")",
";",
"if",
"(",
"!",
"CommaListIterator",
".",
"sameLists",
"(",
"foreignKey",
",",
"curCollDef",
".",
"getProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_FOREIGNKEY",
")",
")",
")",
"{",
"throw",
"new",
"ConstraintException",
"(",
"\"Cannot determine the element-side collection that corresponds to the collection \"",
"+",
"collDef",
".",
"getName",
"(",
")",
"+",
"\" in type \"",
"+",
"collDef",
".",
"getOwner",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\" because there are at least two different collections that would fit.\"",
"+",
"\" Specifying remote-foreignkey in the original collection \"",
"+",
"collDef",
".",
"getName",
"(",
")",
"+",
"\" will perhaps help\"",
")",
";",
"}",
"}",
"// store the found keys at the collections\r",
"collDef",
".",
"setProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_REMOTE_FOREIGNKEY",
",",
"foreignKey",
")",
";",
"for",
"(",
"int",
"idx",
"=",
"0",
";",
"idx",
"<",
"fittingCollections",
".",
"size",
"(",
")",
";",
"idx",
"++",
")",
"{",
"CollectionDescriptorDef",
"curCollDef",
"=",
"(",
"CollectionDescriptorDef",
")",
"fittingCollections",
".",
"get",
"(",
"idx",
")",
";",
"curCollDef",
".",
"setProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_REMOTE_FOREIGNKEY",
",",
"localKey",
")",
";",
"}",
"}",
"}",
"// copy subclass pk fields into target class (if not already present)\r",
"ensurePKsFromHierarchy",
"(",
"elementClassDef",
")",
";",
"}"
] | Ensures that the primary keys required by the given collection with indirection table are present in
the element class.
@param modelDef The model
@param collDef The collection
@throws ConstraintException If there is a problem with the fitting collection (if any) or the primary keys | [
"Ensures",
"that",
"the",
"primary",
"keys",
"required",
"by",
"the",
"given",
"collection",
"with",
"indirection",
"table",
"are",
"present",
"in",
"the",
"element",
"class",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java#L125-L190 | train |
kuali/ojb-1.0.4 | src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java | ModelConstraints.ensureReferencedFKs | private void ensureReferencedFKs(ModelDef modelDef, CollectionDescriptorDef collDef) throws ConstraintException
{
String elementClassName = collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
ClassDescriptorDef elementClassDef = modelDef.getClass(elementClassName);
String fkFieldNames = collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
ArrayList missingFields = new ArrayList();
SequencedHashMap fkFields = new SequencedHashMap();
// first we gather all field names
for (CommaListIterator it = new CommaListIterator(fkFieldNames); it.hasNext();)
{
String fieldName = (String)it.next();
FieldDescriptorDef fieldDef = elementClassDef.getField(fieldName);
if (fieldDef == null)
{
missingFields.add(fieldName);
}
fkFields.put(fieldName, fieldDef);
}
// next we traverse all sub types and gather fields as we go
for (Iterator it = elementClassDef.getAllExtentClasses(); it.hasNext() && !missingFields.isEmpty();)
{
ClassDescriptorDef subTypeDef = (ClassDescriptorDef)it.next();
for (int idx = 0; idx < missingFields.size();)
{
FieldDescriptorDef fieldDef = subTypeDef.getField((String)missingFields.get(idx));
if (fieldDef != null)
{
fkFields.put(fieldDef.getName(), fieldDef);
missingFields.remove(idx);
}
else
{
idx++;
}
}
}
if (!missingFields.isEmpty())
{
throw new ConstraintException("Cannot find field "+missingFields.get(0).toString()+" in the hierarchy with root type "+
elementClassDef.getName()+" which is used as foreignkey in collection "+
collDef.getName()+" in "+collDef.getOwner().getName());
}
// copy the found fields into the element class
ensureFields(elementClassDef, fkFields.values());
} | java | private void ensureReferencedFKs(ModelDef modelDef, CollectionDescriptorDef collDef) throws ConstraintException
{
String elementClassName = collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
ClassDescriptorDef elementClassDef = modelDef.getClass(elementClassName);
String fkFieldNames = collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
ArrayList missingFields = new ArrayList();
SequencedHashMap fkFields = new SequencedHashMap();
// first we gather all field names
for (CommaListIterator it = new CommaListIterator(fkFieldNames); it.hasNext();)
{
String fieldName = (String)it.next();
FieldDescriptorDef fieldDef = elementClassDef.getField(fieldName);
if (fieldDef == null)
{
missingFields.add(fieldName);
}
fkFields.put(fieldName, fieldDef);
}
// next we traverse all sub types and gather fields as we go
for (Iterator it = elementClassDef.getAllExtentClasses(); it.hasNext() && !missingFields.isEmpty();)
{
ClassDescriptorDef subTypeDef = (ClassDescriptorDef)it.next();
for (int idx = 0; idx < missingFields.size();)
{
FieldDescriptorDef fieldDef = subTypeDef.getField((String)missingFields.get(idx));
if (fieldDef != null)
{
fkFields.put(fieldDef.getName(), fieldDef);
missingFields.remove(idx);
}
else
{
idx++;
}
}
}
if (!missingFields.isEmpty())
{
throw new ConstraintException("Cannot find field "+missingFields.get(0).toString()+" in the hierarchy with root type "+
elementClassDef.getName()+" which is used as foreignkey in collection "+
collDef.getName()+" in "+collDef.getOwner().getName());
}
// copy the found fields into the element class
ensureFields(elementClassDef, fkFields.values());
} | [
"private",
"void",
"ensureReferencedFKs",
"(",
"ModelDef",
"modelDef",
",",
"CollectionDescriptorDef",
"collDef",
")",
"throws",
"ConstraintException",
"{",
"String",
"elementClassName",
"=",
"collDef",
".",
"getProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_ELEMENT_CLASS_REF",
")",
";",
"ClassDescriptorDef",
"elementClassDef",
"=",
"modelDef",
".",
"getClass",
"(",
"elementClassName",
")",
";",
"String",
"fkFieldNames",
"=",
"collDef",
".",
"getProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_FOREIGNKEY",
")",
";",
"ArrayList",
"missingFields",
"=",
"new",
"ArrayList",
"(",
")",
";",
"SequencedHashMap",
"fkFields",
"=",
"new",
"SequencedHashMap",
"(",
")",
";",
"// first we gather all field names\r",
"for",
"(",
"CommaListIterator",
"it",
"=",
"new",
"CommaListIterator",
"(",
"fkFieldNames",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"String",
"fieldName",
"=",
"(",
"String",
")",
"it",
".",
"next",
"(",
")",
";",
"FieldDescriptorDef",
"fieldDef",
"=",
"elementClassDef",
".",
"getField",
"(",
"fieldName",
")",
";",
"if",
"(",
"fieldDef",
"==",
"null",
")",
"{",
"missingFields",
".",
"add",
"(",
"fieldName",
")",
";",
"}",
"fkFields",
".",
"put",
"(",
"fieldName",
",",
"fieldDef",
")",
";",
"}",
"// next we traverse all sub types and gather fields as we go\r",
"for",
"(",
"Iterator",
"it",
"=",
"elementClassDef",
".",
"getAllExtentClasses",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
"&&",
"!",
"missingFields",
".",
"isEmpty",
"(",
")",
";",
")",
"{",
"ClassDescriptorDef",
"subTypeDef",
"=",
"(",
"ClassDescriptorDef",
")",
"it",
".",
"next",
"(",
")",
";",
"for",
"(",
"int",
"idx",
"=",
"0",
";",
"idx",
"<",
"missingFields",
".",
"size",
"(",
")",
";",
")",
"{",
"FieldDescriptorDef",
"fieldDef",
"=",
"subTypeDef",
".",
"getField",
"(",
"(",
"String",
")",
"missingFields",
".",
"get",
"(",
"idx",
")",
")",
";",
"if",
"(",
"fieldDef",
"!=",
"null",
")",
"{",
"fkFields",
".",
"put",
"(",
"fieldDef",
".",
"getName",
"(",
")",
",",
"fieldDef",
")",
";",
"missingFields",
".",
"remove",
"(",
"idx",
")",
";",
"}",
"else",
"{",
"idx",
"++",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"missingFields",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"ConstraintException",
"(",
"\"Cannot find field \"",
"+",
"missingFields",
".",
"get",
"(",
"0",
")",
".",
"toString",
"(",
")",
"+",
"\" in the hierarchy with root type \"",
"+",
"elementClassDef",
".",
"getName",
"(",
")",
"+",
"\" which is used as foreignkey in collection \"",
"+",
"collDef",
".",
"getName",
"(",
")",
"+",
"\" in \"",
"+",
"collDef",
".",
"getOwner",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"// copy the found fields into the element class\r",
"ensureFields",
"(",
"elementClassDef",
",",
"fkFields",
".",
"values",
"(",
")",
")",
";",
"}"
] | Ensures that the foreign keys required by the given collection are present in the element class.
@param modelDef The model
@param collDef The collection
@throws ConstraintException If there is a problem with the foreign keys | [
"Ensures",
"that",
"the",
"foreign",
"keys",
"required",
"by",
"the",
"given",
"collection",
"are",
"present",
"in",
"the",
"element",
"class",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java#L199-L249 | train |
kuali/ojb-1.0.4 | src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java | ModelConstraints.ensurePKsFromHierarchy | private void ensurePKsFromHierarchy(ClassDescriptorDef classDef) throws ConstraintException
{
SequencedHashMap pks = new SequencedHashMap();
for (Iterator it = classDef.getAllExtentClasses(); it.hasNext();)
{
ClassDescriptorDef subTypeDef = (ClassDescriptorDef)it.next();
ArrayList subPKs = subTypeDef.getPrimaryKeys();
// check against already present PKs
for (Iterator pkIt = subPKs.iterator(); pkIt.hasNext();)
{
FieldDescriptorDef fieldDef = (FieldDescriptorDef)pkIt.next();
FieldDescriptorDef foundPKDef = (FieldDescriptorDef)pks.get(fieldDef.getName());
if (foundPKDef != null)
{
if (!isEqual(fieldDef, foundPKDef))
{
throw new ConstraintException("Cannot pull up the declaration of the required primary key "+fieldDef.getName()+
" because its definitions in "+fieldDef.getOwner().getName()+" and "+
foundPKDef.getOwner().getName()+" differ");
}
}
else
{
pks.put(fieldDef.getName(), fieldDef);
}
}
}
ensureFields(classDef, pks.values());
} | java | private void ensurePKsFromHierarchy(ClassDescriptorDef classDef) throws ConstraintException
{
SequencedHashMap pks = new SequencedHashMap();
for (Iterator it = classDef.getAllExtentClasses(); it.hasNext();)
{
ClassDescriptorDef subTypeDef = (ClassDescriptorDef)it.next();
ArrayList subPKs = subTypeDef.getPrimaryKeys();
// check against already present PKs
for (Iterator pkIt = subPKs.iterator(); pkIt.hasNext();)
{
FieldDescriptorDef fieldDef = (FieldDescriptorDef)pkIt.next();
FieldDescriptorDef foundPKDef = (FieldDescriptorDef)pks.get(fieldDef.getName());
if (foundPKDef != null)
{
if (!isEqual(fieldDef, foundPKDef))
{
throw new ConstraintException("Cannot pull up the declaration of the required primary key "+fieldDef.getName()+
" because its definitions in "+fieldDef.getOwner().getName()+" and "+
foundPKDef.getOwner().getName()+" differ");
}
}
else
{
pks.put(fieldDef.getName(), fieldDef);
}
}
}
ensureFields(classDef, pks.values());
} | [
"private",
"void",
"ensurePKsFromHierarchy",
"(",
"ClassDescriptorDef",
"classDef",
")",
"throws",
"ConstraintException",
"{",
"SequencedHashMap",
"pks",
"=",
"new",
"SequencedHashMap",
"(",
")",
";",
"for",
"(",
"Iterator",
"it",
"=",
"classDef",
".",
"getAllExtentClasses",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"ClassDescriptorDef",
"subTypeDef",
"=",
"(",
"ClassDescriptorDef",
")",
"it",
".",
"next",
"(",
")",
";",
"ArrayList",
"subPKs",
"=",
"subTypeDef",
".",
"getPrimaryKeys",
"(",
")",
";",
"// check against already present PKs\r",
"for",
"(",
"Iterator",
"pkIt",
"=",
"subPKs",
".",
"iterator",
"(",
")",
";",
"pkIt",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"FieldDescriptorDef",
"fieldDef",
"=",
"(",
"FieldDescriptorDef",
")",
"pkIt",
".",
"next",
"(",
")",
";",
"FieldDescriptorDef",
"foundPKDef",
"=",
"(",
"FieldDescriptorDef",
")",
"pks",
".",
"get",
"(",
"fieldDef",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"foundPKDef",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"isEqual",
"(",
"fieldDef",
",",
"foundPKDef",
")",
")",
"{",
"throw",
"new",
"ConstraintException",
"(",
"\"Cannot pull up the declaration of the required primary key \"",
"+",
"fieldDef",
".",
"getName",
"(",
")",
"+",
"\" because its definitions in \"",
"+",
"fieldDef",
".",
"getOwner",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\" and \"",
"+",
"foundPKDef",
".",
"getOwner",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\" differ\"",
")",
";",
"}",
"}",
"else",
"{",
"pks",
".",
"put",
"(",
"fieldDef",
".",
"getName",
"(",
")",
",",
"fieldDef",
")",
";",
"}",
"}",
"}",
"ensureFields",
"(",
"classDef",
",",
"pks",
".",
"values",
"(",
")",
")",
";",
"}"
] | Gathers the pk fields from the hierarchy of the given class, and copies them into the class.
@param classDef The root of the hierarchy
@throws ConstraintException If there is a conflict between the pk fields | [
"Gathers",
"the",
"pk",
"fields",
"from",
"the",
"hierarchy",
"of",
"the",
"given",
"class",
"and",
"copies",
"them",
"into",
"the",
"class",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java#L257-L290 | train |
kuali/ojb-1.0.4 | src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java | ModelConstraints.ensureFields | private void ensureFields(ClassDescriptorDef classDef, Collection fields) throws ConstraintException
{
boolean forceVirtual = !classDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_REPOSITORY_INFO, true);
for (Iterator it = fields.iterator(); it.hasNext();)
{
FieldDescriptorDef fieldDef = (FieldDescriptorDef)it.next();
// First we check whether this field is already present in the class
FieldDescriptorDef foundFieldDef = classDef.getField(fieldDef.getName());
if (foundFieldDef != null)
{
if (isEqual(fieldDef, foundFieldDef))
{
if (forceVirtual)
{
foundFieldDef.setProperty(PropertyHelper.OJB_PROPERTY_VIRTUAL_FIELD, "true");
}
continue;
}
else
{
throw new ConstraintException("Cannot pull up the declaration of the required field "+fieldDef.getName()+
" from type "+fieldDef.getOwner().getName()+" to basetype "+classDef.getName()+
" because there is already a different field of the same name");
}
}
// perhaps a reference or collection ?
if (classDef.getCollection(fieldDef.getName()) != null)
{
throw new ConstraintException("Cannot pull up the declaration of the required field "+fieldDef.getName()+
" from type "+fieldDef.getOwner().getName()+" to basetype "+classDef.getName()+
" because there is already a collection of the same name");
}
if (classDef.getReference(fieldDef.getName()) != null)
{
throw new ConstraintException("Cannot pull up the declaration of the required field "+fieldDef.getName()+
" from type "+fieldDef.getOwner().getName()+" to basetype "+classDef.getName()+
" because there is already a reference of the same name");
}
classDef.addFieldClone(fieldDef);
classDef.getField(fieldDef.getName()).setProperty(PropertyHelper.OJB_PROPERTY_VIRTUAL_FIELD, "true");
}
} | java | private void ensureFields(ClassDescriptorDef classDef, Collection fields) throws ConstraintException
{
boolean forceVirtual = !classDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_REPOSITORY_INFO, true);
for (Iterator it = fields.iterator(); it.hasNext();)
{
FieldDescriptorDef fieldDef = (FieldDescriptorDef)it.next();
// First we check whether this field is already present in the class
FieldDescriptorDef foundFieldDef = classDef.getField(fieldDef.getName());
if (foundFieldDef != null)
{
if (isEqual(fieldDef, foundFieldDef))
{
if (forceVirtual)
{
foundFieldDef.setProperty(PropertyHelper.OJB_PROPERTY_VIRTUAL_FIELD, "true");
}
continue;
}
else
{
throw new ConstraintException("Cannot pull up the declaration of the required field "+fieldDef.getName()+
" from type "+fieldDef.getOwner().getName()+" to basetype "+classDef.getName()+
" because there is already a different field of the same name");
}
}
// perhaps a reference or collection ?
if (classDef.getCollection(fieldDef.getName()) != null)
{
throw new ConstraintException("Cannot pull up the declaration of the required field "+fieldDef.getName()+
" from type "+fieldDef.getOwner().getName()+" to basetype "+classDef.getName()+
" because there is already a collection of the same name");
}
if (classDef.getReference(fieldDef.getName()) != null)
{
throw new ConstraintException("Cannot pull up the declaration of the required field "+fieldDef.getName()+
" from type "+fieldDef.getOwner().getName()+" to basetype "+classDef.getName()+
" because there is already a reference of the same name");
}
classDef.addFieldClone(fieldDef);
classDef.getField(fieldDef.getName()).setProperty(PropertyHelper.OJB_PROPERTY_VIRTUAL_FIELD, "true");
}
} | [
"private",
"void",
"ensureFields",
"(",
"ClassDescriptorDef",
"classDef",
",",
"Collection",
"fields",
")",
"throws",
"ConstraintException",
"{",
"boolean",
"forceVirtual",
"=",
"!",
"classDef",
".",
"getBooleanProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_GENERATE_REPOSITORY_INFO",
",",
"true",
")",
";",
"for",
"(",
"Iterator",
"it",
"=",
"fields",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"FieldDescriptorDef",
"fieldDef",
"=",
"(",
"FieldDescriptorDef",
")",
"it",
".",
"next",
"(",
")",
";",
"// First we check whether this field is already present in the class\r",
"FieldDescriptorDef",
"foundFieldDef",
"=",
"classDef",
".",
"getField",
"(",
"fieldDef",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"foundFieldDef",
"!=",
"null",
")",
"{",
"if",
"(",
"isEqual",
"(",
"fieldDef",
",",
"foundFieldDef",
")",
")",
"{",
"if",
"(",
"forceVirtual",
")",
"{",
"foundFieldDef",
".",
"setProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_VIRTUAL_FIELD",
",",
"\"true\"",
")",
";",
"}",
"continue",
";",
"}",
"else",
"{",
"throw",
"new",
"ConstraintException",
"(",
"\"Cannot pull up the declaration of the required field \"",
"+",
"fieldDef",
".",
"getName",
"(",
")",
"+",
"\" from type \"",
"+",
"fieldDef",
".",
"getOwner",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\" to basetype \"",
"+",
"classDef",
".",
"getName",
"(",
")",
"+",
"\" because there is already a different field of the same name\"",
")",
";",
"}",
"}",
"// perhaps a reference or collection ?\r",
"if",
"(",
"classDef",
".",
"getCollection",
"(",
"fieldDef",
".",
"getName",
"(",
")",
")",
"!=",
"null",
")",
"{",
"throw",
"new",
"ConstraintException",
"(",
"\"Cannot pull up the declaration of the required field \"",
"+",
"fieldDef",
".",
"getName",
"(",
")",
"+",
"\" from type \"",
"+",
"fieldDef",
".",
"getOwner",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\" to basetype \"",
"+",
"classDef",
".",
"getName",
"(",
")",
"+",
"\" because there is already a collection of the same name\"",
")",
";",
"}",
"if",
"(",
"classDef",
".",
"getReference",
"(",
"fieldDef",
".",
"getName",
"(",
")",
")",
"!=",
"null",
")",
"{",
"throw",
"new",
"ConstraintException",
"(",
"\"Cannot pull up the declaration of the required field \"",
"+",
"fieldDef",
".",
"getName",
"(",
")",
"+",
"\" from type \"",
"+",
"fieldDef",
".",
"getOwner",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\" to basetype \"",
"+",
"classDef",
".",
"getName",
"(",
")",
"+",
"\" because there is already a reference of the same name\"",
")",
";",
"}",
"classDef",
".",
"addFieldClone",
"(",
"fieldDef",
")",
";",
"classDef",
".",
"getField",
"(",
"fieldDef",
".",
"getName",
"(",
")",
")",
".",
"setProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_VIRTUAL_FIELD",
",",
"\"true\"",
")",
";",
"}",
"}"
] | Ensures that the specified fields are present in the given class.
@param classDef The class to copy the fields into
@param fields The fields to copy
@throws ConstraintException If there is a conflict between the new fields and fields in the class | [
"Ensures",
"that",
"the",
"specified",
"fields",
"are",
"present",
"in",
"the",
"given",
"class",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java#L299-L344 | train |
kuali/ojb-1.0.4 | src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java | ModelConstraints.isEqual | private boolean isEqual(FieldDescriptorDef first, FieldDescriptorDef second)
{
return first.getName().equals(second.getName()) &&
first.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN).equals(second.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN)) &&
first.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE).equals(second.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE));
} | java | private boolean isEqual(FieldDescriptorDef first, FieldDescriptorDef second)
{
return first.getName().equals(second.getName()) &&
first.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN).equals(second.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN)) &&
first.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE).equals(second.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE));
} | [
"private",
"boolean",
"isEqual",
"(",
"FieldDescriptorDef",
"first",
",",
"FieldDescriptorDef",
"second",
")",
"{",
"return",
"first",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"second",
".",
"getName",
"(",
")",
")",
"&&",
"first",
".",
"getProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_COLUMN",
")",
".",
"equals",
"(",
"second",
".",
"getProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_COLUMN",
")",
")",
"&&",
"first",
".",
"getProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_JDBC_TYPE",
")",
".",
"equals",
"(",
"second",
".",
"getProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_JDBC_TYPE",
")",
")",
";",
"}"
] | Tests whether the two field descriptors are equal, i.e. have same name, same column
and same jdbc-type.
@param first The first field
@param second The second field
@return <code>true</code> if they are equal | [
"Tests",
"whether",
"the",
"two",
"field",
"descriptors",
"are",
"equal",
"i",
".",
"e",
".",
"have",
"same",
"name",
"same",
"column",
"and",
"same",
"jdbc",
"-",
"type",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java#L354-L359 | train |
kuali/ojb-1.0.4 | src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java | ModelConstraints.checkCollectionForeignkeys | private void checkCollectionForeignkeys(ModelDef modelDef, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
ClassDescriptorDef classDef;
CollectionDescriptorDef collDef;
for (Iterator it = modelDef.getClasses(); it.hasNext();)
{
classDef = (ClassDescriptorDef)it.next();
for (Iterator collIt = classDef.getCollections(); collIt.hasNext();)
{
collDef = (CollectionDescriptorDef)collIt.next();
if (!collDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false))
{
if (collDef.hasProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE))
{
checkIndirectionTable(modelDef, collDef);
}
else
{
checkCollectionForeignkeys(modelDef, collDef);
}
}
}
}
} | java | private void checkCollectionForeignkeys(ModelDef modelDef, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
ClassDescriptorDef classDef;
CollectionDescriptorDef collDef;
for (Iterator it = modelDef.getClasses(); it.hasNext();)
{
classDef = (ClassDescriptorDef)it.next();
for (Iterator collIt = classDef.getCollections(); collIt.hasNext();)
{
collDef = (CollectionDescriptorDef)collIt.next();
if (!collDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false))
{
if (collDef.hasProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE))
{
checkIndirectionTable(modelDef, collDef);
}
else
{
checkCollectionForeignkeys(modelDef, collDef);
}
}
}
}
} | [
"private",
"void",
"checkCollectionForeignkeys",
"(",
"ModelDef",
"modelDef",
",",
"String",
"checkLevel",
")",
"throws",
"ConstraintException",
"{",
"if",
"(",
"CHECKLEVEL_NONE",
".",
"equals",
"(",
"checkLevel",
")",
")",
"{",
"return",
";",
"}",
"ClassDescriptorDef",
"classDef",
";",
"CollectionDescriptorDef",
"collDef",
";",
"for",
"(",
"Iterator",
"it",
"=",
"modelDef",
".",
"getClasses",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"classDef",
"=",
"(",
"ClassDescriptorDef",
")",
"it",
".",
"next",
"(",
")",
";",
"for",
"(",
"Iterator",
"collIt",
"=",
"classDef",
".",
"getCollections",
"(",
")",
";",
"collIt",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"collDef",
"=",
"(",
"CollectionDescriptorDef",
")",
"collIt",
".",
"next",
"(",
")",
";",
"if",
"(",
"!",
"collDef",
".",
"getBooleanProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_IGNORE",
",",
"false",
")",
")",
"{",
"if",
"(",
"collDef",
".",
"hasProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_INDIRECTION_TABLE",
")",
")",
"{",
"checkIndirectionTable",
"(",
"modelDef",
",",
"collDef",
")",
";",
"}",
"else",
"{",
"checkCollectionForeignkeys",
"(",
"modelDef",
",",
"collDef",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | Checks the foreignkeys of all collections in the model.
@param modelDef The model
@param checkLevel The current check level (this constraint is checked in basic and strict)
@exception ConstraintException If the value for foreignkey is invalid | [
"Checks",
"the",
"foreignkeys",
"of",
"all",
"collections",
"in",
"the",
"model",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java#L368-L397 | train |
kuali/ojb-1.0.4 | src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java | ModelConstraints.checkReferenceForeignkeys | private void checkReferenceForeignkeys(ModelDef modelDef, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
ClassDescriptorDef classDef;
ReferenceDescriptorDef refDef;
for (Iterator it = modelDef.getClasses(); it.hasNext();)
{
classDef = (ClassDescriptorDef)it.next();
for (Iterator refIt = classDef.getReferences(); refIt.hasNext();)
{
refDef = (ReferenceDescriptorDef)refIt.next();
if (!refDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false))
{
checkReferenceForeignkeys(modelDef, refDef);
}
}
}
} | java | private void checkReferenceForeignkeys(ModelDef modelDef, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
ClassDescriptorDef classDef;
ReferenceDescriptorDef refDef;
for (Iterator it = modelDef.getClasses(); it.hasNext();)
{
classDef = (ClassDescriptorDef)it.next();
for (Iterator refIt = classDef.getReferences(); refIt.hasNext();)
{
refDef = (ReferenceDescriptorDef)refIt.next();
if (!refDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false))
{
checkReferenceForeignkeys(modelDef, refDef);
}
}
}
} | [
"private",
"void",
"checkReferenceForeignkeys",
"(",
"ModelDef",
"modelDef",
",",
"String",
"checkLevel",
")",
"throws",
"ConstraintException",
"{",
"if",
"(",
"CHECKLEVEL_NONE",
".",
"equals",
"(",
"checkLevel",
")",
")",
"{",
"return",
";",
"}",
"ClassDescriptorDef",
"classDef",
";",
"ReferenceDescriptorDef",
"refDef",
";",
"for",
"(",
"Iterator",
"it",
"=",
"modelDef",
".",
"getClasses",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"classDef",
"=",
"(",
"ClassDescriptorDef",
")",
"it",
".",
"next",
"(",
")",
";",
"for",
"(",
"Iterator",
"refIt",
"=",
"classDef",
".",
"getReferences",
"(",
")",
";",
"refIt",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"refDef",
"=",
"(",
"ReferenceDescriptorDef",
")",
"refIt",
".",
"next",
"(",
")",
";",
"if",
"(",
"!",
"refDef",
".",
"getBooleanProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_IGNORE",
",",
"false",
")",
")",
"{",
"checkReferenceForeignkeys",
"(",
"modelDef",
",",
"refDef",
")",
";",
"}",
"}",
"}",
"}"
] | Checks the foreignkeys of all references in the model.
@param modelDef The model
@param checkLevel The current check level (this constraint is checked in basic and strict)
@exception ConstraintException If the value for foreignkey is invalid | [
"Checks",
"the",
"foreignkeys",
"of",
"all",
"references",
"in",
"the",
"model",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java#L600-L622 | train |
kuali/ojb-1.0.4 | src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java | ModelConstraints.usedByReference | private ReferenceDescriptorDef usedByReference(ModelDef modelDef, FieldDescriptorDef fieldDef)
{
String ownerClassName = ((ClassDescriptorDef)fieldDef.getOwner()).getQualifiedName();
ClassDescriptorDef classDef;
ReferenceDescriptorDef refDef;
String targetClassName;
// only relevant for primarykey fields
if (PropertyHelper.toBoolean(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_PRIMARYKEY), false))
{
for (Iterator classIt = modelDef.getClasses(); classIt.hasNext();)
{
classDef = (ClassDescriptorDef)classIt.next();
for (Iterator refIt = classDef.getReferences(); refIt.hasNext();)
{
refDef = (ReferenceDescriptorDef)refIt.next();
targetClassName = refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF).replace('$', '.');
if (ownerClassName.equals(targetClassName))
{
// the field is a primary key of the class referenced by this reference descriptor
return refDef;
}
}
}
}
return null;
} | java | private ReferenceDescriptorDef usedByReference(ModelDef modelDef, FieldDescriptorDef fieldDef)
{
String ownerClassName = ((ClassDescriptorDef)fieldDef.getOwner()).getQualifiedName();
ClassDescriptorDef classDef;
ReferenceDescriptorDef refDef;
String targetClassName;
// only relevant for primarykey fields
if (PropertyHelper.toBoolean(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_PRIMARYKEY), false))
{
for (Iterator classIt = modelDef.getClasses(); classIt.hasNext();)
{
classDef = (ClassDescriptorDef)classIt.next();
for (Iterator refIt = classDef.getReferences(); refIt.hasNext();)
{
refDef = (ReferenceDescriptorDef)refIt.next();
targetClassName = refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF).replace('$', '.');
if (ownerClassName.equals(targetClassName))
{
// the field is a primary key of the class referenced by this reference descriptor
return refDef;
}
}
}
}
return null;
} | [
"private",
"ReferenceDescriptorDef",
"usedByReference",
"(",
"ModelDef",
"modelDef",
",",
"FieldDescriptorDef",
"fieldDef",
")",
"{",
"String",
"ownerClassName",
"=",
"(",
"(",
"ClassDescriptorDef",
")",
"fieldDef",
".",
"getOwner",
"(",
")",
")",
".",
"getQualifiedName",
"(",
")",
";",
"ClassDescriptorDef",
"classDef",
";",
"ReferenceDescriptorDef",
"refDef",
";",
"String",
"targetClassName",
";",
"// only relevant for primarykey fields\r",
"if",
"(",
"PropertyHelper",
".",
"toBoolean",
"(",
"fieldDef",
".",
"getProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_PRIMARYKEY",
")",
",",
"false",
")",
")",
"{",
"for",
"(",
"Iterator",
"classIt",
"=",
"modelDef",
".",
"getClasses",
"(",
")",
";",
"classIt",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"classDef",
"=",
"(",
"ClassDescriptorDef",
")",
"classIt",
".",
"next",
"(",
")",
";",
"for",
"(",
"Iterator",
"refIt",
"=",
"classDef",
".",
"getReferences",
"(",
")",
";",
"refIt",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"refDef",
"=",
"(",
"ReferenceDescriptorDef",
")",
"refIt",
".",
"next",
"(",
")",
";",
"targetClassName",
"=",
"refDef",
".",
"getProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_CLASS_REF",
")",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"if",
"(",
"ownerClassName",
".",
"equals",
"(",
"targetClassName",
")",
")",
"{",
"// the field is a primary key of the class referenced by this reference descriptor\r",
"return",
"refDef",
";",
"}",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | Checks whether the given field definition is used as the primary key of a class referenced by
a reference.
@param modelDef The model
@param fieldDef The current field descriptor def
@return The reference that uses the field or <code>null</code> if the field is not used in this way | [
"Checks",
"whether",
"the",
"given",
"field",
"definition",
"is",
"used",
"as",
"the",
"primary",
"key",
"of",
"a",
"class",
"referenced",
"by",
"a",
"reference",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java#L877-L903 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/metadata/ObjectReferenceDescriptor.java | ObjectReferenceDescriptor.getForeignKeyValues | public Object[] getForeignKeyValues(Object obj, ClassDescriptor mif)
throws PersistenceBrokerException
{
FieldDescriptor[] fks = getForeignKeyFieldDescriptors(mif);
// materialize object only if FK fields are declared
if(fks.length > 0) obj = ProxyHelper.getRealObject(obj);
Object[] result = new Object[fks.length];
for (int i = 0; i < result.length; i++)
{
FieldDescriptor fmd = fks[i];
PersistentField f = fmd.getPersistentField();
// BRJ: do NOT convert.
// conversion is done when binding the sql-statement
//
// FieldConversion fc = fmd.getFieldConversion();
// Object val = fc.javaToSql(f.get(obj));
result[i] = f.get(obj);
}
return result;
} | java | public Object[] getForeignKeyValues(Object obj, ClassDescriptor mif)
throws PersistenceBrokerException
{
FieldDescriptor[] fks = getForeignKeyFieldDescriptors(mif);
// materialize object only if FK fields are declared
if(fks.length > 0) obj = ProxyHelper.getRealObject(obj);
Object[] result = new Object[fks.length];
for (int i = 0; i < result.length; i++)
{
FieldDescriptor fmd = fks[i];
PersistentField f = fmd.getPersistentField();
// BRJ: do NOT convert.
// conversion is done when binding the sql-statement
//
// FieldConversion fc = fmd.getFieldConversion();
// Object val = fc.javaToSql(f.get(obj));
result[i] = f.get(obj);
}
return result;
} | [
"public",
"Object",
"[",
"]",
"getForeignKeyValues",
"(",
"Object",
"obj",
",",
"ClassDescriptor",
"mif",
")",
"throws",
"PersistenceBrokerException",
"{",
"FieldDescriptor",
"[",
"]",
"fks",
"=",
"getForeignKeyFieldDescriptors",
"(",
"mif",
")",
";",
"// materialize object only if FK fields are declared\r",
"if",
"(",
"fks",
".",
"length",
">",
"0",
")",
"obj",
"=",
"ProxyHelper",
".",
"getRealObject",
"(",
"obj",
")",
";",
"Object",
"[",
"]",
"result",
"=",
"new",
"Object",
"[",
"fks",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"result",
".",
"length",
";",
"i",
"++",
")",
"{",
"FieldDescriptor",
"fmd",
"=",
"fks",
"[",
"i",
"]",
";",
"PersistentField",
"f",
"=",
"fmd",
".",
"getPersistentField",
"(",
")",
";",
"// BRJ: do NOT convert.\r",
"// conversion is done when binding the sql-statement\r",
"//\r",
"// FieldConversion fc = fmd.getFieldConversion();\r",
"// Object val = fc.javaToSql(f.get(obj));\r",
"result",
"[",
"i",
"]",
"=",
"f",
".",
"get",
"(",
"obj",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Returns an Object array of all FK field values of the specified object.
If the specified object is an unmaterialized Proxy, it will be materialized
to read the FK values.
@throws MetadataException if an error occours while accessing ForeingKey values on obj | [
"Returns",
"an",
"Object",
"array",
"of",
"all",
"FK",
"field",
"values",
"of",
"the",
"specified",
"object",
".",
"If",
"the",
"specified",
"object",
"is",
"an",
"unmaterialized",
"Proxy",
"it",
"will",
"be",
"materialized",
"to",
"read",
"the",
"FK",
"values",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/ObjectReferenceDescriptor.java#L170-L191 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/metadata/ObjectReferenceDescriptor.java | ObjectReferenceDescriptor.addForeignKeyField | public void addForeignKeyField(int newId)
{
if (m_ForeignKeyFields == null)
{
m_ForeignKeyFields = new Vector();
}
m_ForeignKeyFields.add(new Integer(newId));
} | java | public void addForeignKeyField(int newId)
{
if (m_ForeignKeyFields == null)
{
m_ForeignKeyFields = new Vector();
}
m_ForeignKeyFields.add(new Integer(newId));
} | [
"public",
"void",
"addForeignKeyField",
"(",
"int",
"newId",
")",
"{",
"if",
"(",
"m_ForeignKeyFields",
"==",
"null",
")",
"{",
"m_ForeignKeyFields",
"=",
"new",
"Vector",
"(",
")",
";",
"}",
"m_ForeignKeyFields",
".",
"add",
"(",
"new",
"Integer",
"(",
"newId",
")",
")",
";",
"}"
] | add a foreign key field ID | [
"add",
"a",
"foreign",
"key",
"field",
"ID"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/ObjectReferenceDescriptor.java#L237-L244 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/metadata/ObjectReferenceDescriptor.java | ObjectReferenceDescriptor.addForeignKeyField | public void addForeignKeyField(String newField)
{
if (m_ForeignKeyFields == null)
{
m_ForeignKeyFields = new Vector();
}
m_ForeignKeyFields.add(newField);
} | java | public void addForeignKeyField(String newField)
{
if (m_ForeignKeyFields == null)
{
m_ForeignKeyFields = new Vector();
}
m_ForeignKeyFields.add(newField);
} | [
"public",
"void",
"addForeignKeyField",
"(",
"String",
"newField",
")",
"{",
"if",
"(",
"m_ForeignKeyFields",
"==",
"null",
")",
"{",
"m_ForeignKeyFields",
"=",
"new",
"Vector",
"(",
")",
";",
"}",
"m_ForeignKeyFields",
".",
"add",
"(",
"newField",
")",
";",
"}"
] | add a foreign key field | [
"add",
"a",
"foreign",
"key",
"field"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/ObjectReferenceDescriptor.java#L249-L256 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/locking/CommonsOJBLockManager.java | CommonsOJBLockManager.atomicGetOrCreateLock | public OJBLock atomicGetOrCreateLock(Object resourceId, Object isolationId)
{
synchronized(globalLocks)
{
MultiLevelLock lock = getLock(resourceId);
if(lock == null)
{
lock = createLock(resourceId, isolationId);
}
return (OJBLock) lock;
}
} | java | public OJBLock atomicGetOrCreateLock(Object resourceId, Object isolationId)
{
synchronized(globalLocks)
{
MultiLevelLock lock = getLock(resourceId);
if(lock == null)
{
lock = createLock(resourceId, isolationId);
}
return (OJBLock) lock;
}
} | [
"public",
"OJBLock",
"atomicGetOrCreateLock",
"(",
"Object",
"resourceId",
",",
"Object",
"isolationId",
")",
"{",
"synchronized",
"(",
"globalLocks",
")",
"{",
"MultiLevelLock",
"lock",
"=",
"getLock",
"(",
"resourceId",
")",
";",
"if",
"(",
"lock",
"==",
"null",
")",
"{",
"lock",
"=",
"createLock",
"(",
"resourceId",
",",
"isolationId",
")",
";",
"}",
"return",
"(",
"OJBLock",
")",
"lock",
";",
"}",
"}"
] | Either gets an existing lock on the specified resource or creates one if none exists.
This methods guarantees to do this atomically.
@param resourceId the resource to get or create the lock on
@param isolationId the isolation level identity key. See {@link CommonsOJBLockManager}.
@return the lock for the specified resource | [
"Either",
"gets",
"an",
"existing",
"lock",
"on",
"the",
"specified",
"resource",
"or",
"creates",
"one",
"if",
"none",
"exists",
".",
"This",
"methods",
"guarantees",
"to",
"do",
"this",
"atomically",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/locking/CommonsOJBLockManager.java#L148-L159 | train |
geomajas/geomajas-project-server | plugin/print/print/src/main/java/org/geomajas/plugin/printing/component/PdfContext.java | PdfContext.initSize | public void initSize(Rectangle rectangle) {
template = writer.getDirectContent().createTemplate(rectangle.getWidth(), rectangle.getHeight());
} | java | public void initSize(Rectangle rectangle) {
template = writer.getDirectContent().createTemplate(rectangle.getWidth(), rectangle.getHeight());
} | [
"public",
"void",
"initSize",
"(",
"Rectangle",
"rectangle",
")",
"{",
"template",
"=",
"writer",
".",
"getDirectContent",
"(",
")",
".",
"createTemplate",
"(",
"rectangle",
".",
"getWidth",
"(",
")",
",",
"rectangle",
".",
"getHeight",
"(",
")",
")",
";",
"}"
] | Initializes context size.
@param rectangle rectangle | [
"Initializes",
"context",
"size",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/print/print/src/main/java/org/geomajas/plugin/printing/component/PdfContext.java#L115-L117 | train |
geomajas/geomajas-project-server | plugin/print/print/src/main/java/org/geomajas/plugin/printing/component/PdfContext.java | PdfContext.getTextSize | public Rectangle getTextSize(String text, Font font) {
template.saveState();
// get the font
DefaultFontMapper mapper = new DefaultFontMapper();
BaseFont bf = mapper.awtToPdf(font);
template.setFontAndSize(bf, font.getSize());
// calculate text width and height
float textWidth = template.getEffectiveStringWidth(text, false);
float ascent = bf.getAscentPoint(text, font.getSize());
float descent = bf.getDescentPoint(text, font.getSize());
float textHeight = ascent - descent;
template.restoreState();
return new Rectangle(0, 0, textWidth, textHeight);
} | java | public Rectangle getTextSize(String text, Font font) {
template.saveState();
// get the font
DefaultFontMapper mapper = new DefaultFontMapper();
BaseFont bf = mapper.awtToPdf(font);
template.setFontAndSize(bf, font.getSize());
// calculate text width and height
float textWidth = template.getEffectiveStringWidth(text, false);
float ascent = bf.getAscentPoint(text, font.getSize());
float descent = bf.getDescentPoint(text, font.getSize());
float textHeight = ascent - descent;
template.restoreState();
return new Rectangle(0, 0, textWidth, textHeight);
} | [
"public",
"Rectangle",
"getTextSize",
"(",
"String",
"text",
",",
"Font",
"font",
")",
"{",
"template",
".",
"saveState",
"(",
")",
";",
"// get the font",
"DefaultFontMapper",
"mapper",
"=",
"new",
"DefaultFontMapper",
"(",
")",
";",
"BaseFont",
"bf",
"=",
"mapper",
".",
"awtToPdf",
"(",
"font",
")",
";",
"template",
".",
"setFontAndSize",
"(",
"bf",
",",
"font",
".",
"getSize",
"(",
")",
")",
";",
"// calculate text width and height",
"float",
"textWidth",
"=",
"template",
".",
"getEffectiveStringWidth",
"(",
"text",
",",
"false",
")",
";",
"float",
"ascent",
"=",
"bf",
".",
"getAscentPoint",
"(",
"text",
",",
"font",
".",
"getSize",
"(",
")",
")",
";",
"float",
"descent",
"=",
"bf",
".",
"getDescentPoint",
"(",
"text",
",",
"font",
".",
"getSize",
"(",
")",
")",
";",
"float",
"textHeight",
"=",
"ascent",
"-",
"descent",
";",
"template",
".",
"restoreState",
"(",
")",
";",
"return",
"new",
"Rectangle",
"(",
"0",
",",
"0",
",",
"textWidth",
",",
"textHeight",
")",
";",
"}"
] | Return the text box for the specified text and font.
@param text text
@param font font
@return text box | [
"Return",
"the",
"text",
"box",
"for",
"the",
"specified",
"text",
"and",
"font",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/print/print/src/main/java/org/geomajas/plugin/printing/component/PdfContext.java#L137-L150 | train |
geomajas/geomajas-project-server | plugin/print/print/src/main/java/org/geomajas/plugin/printing/component/PdfContext.java | PdfContext.drawText | public void drawText(String text, Font font, Rectangle box, Color fontColor) {
template.saveState();
// get the font
DefaultFontMapper mapper = new DefaultFontMapper();
BaseFont bf = mapper.awtToPdf(font);
template.setFontAndSize(bf, font.getSize());
// calculate descent
float descent = 0;
if (text != null) {
descent = bf.getDescentPoint(text, font.getSize());
}
// calculate the fitting size
Rectangle fit = getTextSize(text, font);
// draw text if necessary
template.setColorFill(fontColor);
template.beginText();
template.showTextAligned(PdfContentByte.ALIGN_LEFT, text, origX + box.getLeft() + 0.5f
* (box.getWidth() - fit.getWidth()), origY + box.getBottom() + 0.5f
* (box.getHeight() - fit.getHeight()) - descent, 0);
template.endText();
template.restoreState();
} | java | public void drawText(String text, Font font, Rectangle box, Color fontColor) {
template.saveState();
// get the font
DefaultFontMapper mapper = new DefaultFontMapper();
BaseFont bf = mapper.awtToPdf(font);
template.setFontAndSize(bf, font.getSize());
// calculate descent
float descent = 0;
if (text != null) {
descent = bf.getDescentPoint(text, font.getSize());
}
// calculate the fitting size
Rectangle fit = getTextSize(text, font);
// draw text if necessary
template.setColorFill(fontColor);
template.beginText();
template.showTextAligned(PdfContentByte.ALIGN_LEFT, text, origX + box.getLeft() + 0.5f
* (box.getWidth() - fit.getWidth()), origY + box.getBottom() + 0.5f
* (box.getHeight() - fit.getHeight()) - descent, 0);
template.endText();
template.restoreState();
} | [
"public",
"void",
"drawText",
"(",
"String",
"text",
",",
"Font",
"font",
",",
"Rectangle",
"box",
",",
"Color",
"fontColor",
")",
"{",
"template",
".",
"saveState",
"(",
")",
";",
"// get the font",
"DefaultFontMapper",
"mapper",
"=",
"new",
"DefaultFontMapper",
"(",
")",
";",
"BaseFont",
"bf",
"=",
"mapper",
".",
"awtToPdf",
"(",
"font",
")",
";",
"template",
".",
"setFontAndSize",
"(",
"bf",
",",
"font",
".",
"getSize",
"(",
")",
")",
";",
"// calculate descent",
"float",
"descent",
"=",
"0",
";",
"if",
"(",
"text",
"!=",
"null",
")",
"{",
"descent",
"=",
"bf",
".",
"getDescentPoint",
"(",
"text",
",",
"font",
".",
"getSize",
"(",
")",
")",
";",
"}",
"// calculate the fitting size",
"Rectangle",
"fit",
"=",
"getTextSize",
"(",
"text",
",",
"font",
")",
";",
"// draw text if necessary",
"template",
".",
"setColorFill",
"(",
"fontColor",
")",
";",
"template",
".",
"beginText",
"(",
")",
";",
"template",
".",
"showTextAligned",
"(",
"PdfContentByte",
".",
"ALIGN_LEFT",
",",
"text",
",",
"origX",
"+",
"box",
".",
"getLeft",
"(",
")",
"+",
"0.5f",
"*",
"(",
"box",
".",
"getWidth",
"(",
")",
"-",
"fit",
".",
"getWidth",
"(",
")",
")",
",",
"origY",
"+",
"box",
".",
"getBottom",
"(",
")",
"+",
"0.5f",
"*",
"(",
"box",
".",
"getHeight",
"(",
")",
"-",
"fit",
".",
"getHeight",
"(",
")",
")",
"-",
"descent",
",",
"0",
")",
";",
"template",
".",
"endText",
"(",
")",
";",
"template",
".",
"restoreState",
"(",
")",
";",
"}"
] | Draw text in the center of the specified box.
@param text text
@param font font
@param box box to put text int
@param fontColor colour | [
"Draw",
"text",
"in",
"the",
"center",
"of",
"the",
"specified",
"box",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/print/print/src/main/java/org/geomajas/plugin/printing/component/PdfContext.java#L160-L184 | train |
geomajas/geomajas-project-server | plugin/print/print/src/main/java/org/geomajas/plugin/printing/component/PdfContext.java | PdfContext.strokeRectangle | public void strokeRectangle(Rectangle rect, Color color, float linewidth) {
strokeRectangle(rect, color, linewidth, null);
} | java | public void strokeRectangle(Rectangle rect, Color color, float linewidth) {
strokeRectangle(rect, color, linewidth, null);
} | [
"public",
"void",
"strokeRectangle",
"(",
"Rectangle",
"rect",
",",
"Color",
"color",
",",
"float",
"linewidth",
")",
"{",
"strokeRectangle",
"(",
"rect",
",",
"color",
",",
"linewidth",
",",
"null",
")",
";",
"}"
] | Draw a rectangular boundary with this color and linewidth.
@param rect
rectangle
@param color
color
@param linewidth
line width | [
"Draw",
"a",
"rectangular",
"boundary",
"with",
"this",
"color",
"and",
"linewidth",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/print/print/src/main/java/org/geomajas/plugin/printing/component/PdfContext.java#L205-L207 | train |
geomajas/geomajas-project-server | plugin/print/print/src/main/java/org/geomajas/plugin/printing/component/PdfContext.java | PdfContext.strokeRoundRectangle | public void strokeRoundRectangle(Rectangle rect, Color color, float linewidth, float r) {
template.saveState();
setStroke(color, linewidth, null);
template.roundRectangle(origX + rect.getLeft(), origY + rect.getBottom(), rect.getWidth(), rect.getHeight(), r);
template.stroke();
template.restoreState();
} | java | public void strokeRoundRectangle(Rectangle rect, Color color, float linewidth, float r) {
template.saveState();
setStroke(color, linewidth, null);
template.roundRectangle(origX + rect.getLeft(), origY + rect.getBottom(), rect.getWidth(), rect.getHeight(), r);
template.stroke();
template.restoreState();
} | [
"public",
"void",
"strokeRoundRectangle",
"(",
"Rectangle",
"rect",
",",
"Color",
"color",
",",
"float",
"linewidth",
",",
"float",
"r",
")",
"{",
"template",
".",
"saveState",
"(",
")",
";",
"setStroke",
"(",
"color",
",",
"linewidth",
",",
"null",
")",
";",
"template",
".",
"roundRectangle",
"(",
"origX",
"+",
"rect",
".",
"getLeft",
"(",
")",
",",
"origY",
"+",
"rect",
".",
"getBottom",
"(",
")",
",",
"rect",
".",
"getWidth",
"(",
")",
",",
"rect",
".",
"getHeight",
"(",
")",
",",
"r",
")",
";",
"template",
".",
"stroke",
"(",
")",
";",
"template",
".",
"restoreState",
"(",
")",
";",
"}"
] | Draw a rounded rectangular boundary.
@param rect rectangle
@param color colour
@param linewidth line width
@param r radius for rounded corners | [
"Draw",
"a",
"rounded",
"rectangular",
"boundary",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/print/print/src/main/java/org/geomajas/plugin/printing/component/PdfContext.java#L225-L231 | train |
geomajas/geomajas-project-server | plugin/print/print/src/main/java/org/geomajas/plugin/printing/component/PdfContext.java | PdfContext.fillRectangle | public void fillRectangle(Rectangle rect, Color color) {
template.saveState();
setFill(color);
template.rectangle(origX + rect.getLeft(), origY + rect.getBottom(), rect.getWidth(), rect.getHeight());
template.fill();
template.restoreState();
} | java | public void fillRectangle(Rectangle rect, Color color) {
template.saveState();
setFill(color);
template.rectangle(origX + rect.getLeft(), origY + rect.getBottom(), rect.getWidth(), rect.getHeight());
template.fill();
template.restoreState();
} | [
"public",
"void",
"fillRectangle",
"(",
"Rectangle",
"rect",
",",
"Color",
"color",
")",
"{",
"template",
".",
"saveState",
"(",
")",
";",
"setFill",
"(",
"color",
")",
";",
"template",
".",
"rectangle",
"(",
"origX",
"+",
"rect",
".",
"getLeft",
"(",
")",
",",
"origY",
"+",
"rect",
".",
"getBottom",
"(",
")",
",",
"rect",
".",
"getWidth",
"(",
")",
",",
"rect",
".",
"getHeight",
"(",
")",
")",
";",
"template",
".",
"fill",
"(",
")",
";",
"template",
".",
"restoreState",
"(",
")",
";",
"}"
] | Draw a rectangle's interior with this color.
@param rect rectangle
@param color colour | [
"Draw",
"a",
"rectangle",
"s",
"interior",
"with",
"this",
"color",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/print/print/src/main/java/org/geomajas/plugin/printing/component/PdfContext.java#L248-L254 | train |
geomajas/geomajas-project-server | plugin/print/print/src/main/java/org/geomajas/plugin/printing/component/PdfContext.java | PdfContext.strokeEllipse | public void strokeEllipse(Rectangle rect, Color color, float linewidth) {
template.saveState();
setStroke(color, linewidth, null);
template.ellipse(origX + rect.getLeft(), origY + rect.getBottom(), origX + rect.getRight(),
origY + rect.getTop());
template.stroke();
template.restoreState();
} | java | public void strokeEllipse(Rectangle rect, Color color, float linewidth) {
template.saveState();
setStroke(color, linewidth, null);
template.ellipse(origX + rect.getLeft(), origY + rect.getBottom(), origX + rect.getRight(),
origY + rect.getTop());
template.stroke();
template.restoreState();
} | [
"public",
"void",
"strokeEllipse",
"(",
"Rectangle",
"rect",
",",
"Color",
"color",
",",
"float",
"linewidth",
")",
"{",
"template",
".",
"saveState",
"(",
")",
";",
"setStroke",
"(",
"color",
",",
"linewidth",
",",
"null",
")",
";",
"template",
".",
"ellipse",
"(",
"origX",
"+",
"rect",
".",
"getLeft",
"(",
")",
",",
"origY",
"+",
"rect",
".",
"getBottom",
"(",
")",
",",
"origX",
"+",
"rect",
".",
"getRight",
"(",
")",
",",
"origY",
"+",
"rect",
".",
"getTop",
"(",
")",
")",
";",
"template",
".",
"stroke",
"(",
")",
";",
"template",
".",
"restoreState",
"(",
")",
";",
"}"
] | Draw an elliptical exterior with this color.
@param rect rectangle in which ellipse should fit
@param color colour to use for stroking
@param linewidth line width | [
"Draw",
"an",
"elliptical",
"exterior",
"with",
"this",
"color",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/print/print/src/main/java/org/geomajas/plugin/printing/component/PdfContext.java#L271-L278 | train |
geomajas/geomajas-project-server | plugin/print/print/src/main/java/org/geomajas/plugin/printing/component/PdfContext.java | PdfContext.fillEllipse | public void fillEllipse(Rectangle rect, Color color) {
template.saveState();
setFill(color);
template.ellipse(origX + rect.getLeft(), origY + rect.getBottom(), origX + rect.getRight(),
origY + rect.getTop());
template.fill();
template.restoreState();
} | java | public void fillEllipse(Rectangle rect, Color color) {
template.saveState();
setFill(color);
template.ellipse(origX + rect.getLeft(), origY + rect.getBottom(), origX + rect.getRight(),
origY + rect.getTop());
template.fill();
template.restoreState();
} | [
"public",
"void",
"fillEllipse",
"(",
"Rectangle",
"rect",
",",
"Color",
"color",
")",
"{",
"template",
".",
"saveState",
"(",
")",
";",
"setFill",
"(",
"color",
")",
";",
"template",
".",
"ellipse",
"(",
"origX",
"+",
"rect",
".",
"getLeft",
"(",
")",
",",
"origY",
"+",
"rect",
".",
"getBottom",
"(",
")",
",",
"origX",
"+",
"rect",
".",
"getRight",
"(",
")",
",",
"origY",
"+",
"rect",
".",
"getTop",
"(",
")",
")",
";",
"template",
".",
"fill",
"(",
")",
";",
"template",
".",
"restoreState",
"(",
")",
";",
"}"
] | Draw an elliptical interior with this color.
@param rect rectangle in which ellipse should fit
@param color colour to use for filling | [
"Draw",
"an",
"elliptical",
"interior",
"with",
"this",
"color",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/print/print/src/main/java/org/geomajas/plugin/printing/component/PdfContext.java#L286-L293 | train |
geomajas/geomajas-project-server | plugin/print/print/src/main/java/org/geomajas/plugin/printing/component/PdfContext.java | PdfContext.moveRectangleTo | public void moveRectangleTo(Rectangle rect, float x, float y) {
float width = rect.getWidth();
float height = rect.getHeight();
rect.setLeft(x);
rect.setBottom(y);
rect.setRight(rect.getLeft() + width);
rect.setTop(rect.getBottom() + height);
} | java | public void moveRectangleTo(Rectangle rect, float x, float y) {
float width = rect.getWidth();
float height = rect.getHeight();
rect.setLeft(x);
rect.setBottom(y);
rect.setRight(rect.getLeft() + width);
rect.setTop(rect.getBottom() + height);
} | [
"public",
"void",
"moveRectangleTo",
"(",
"Rectangle",
"rect",
",",
"float",
"x",
",",
"float",
"y",
")",
"{",
"float",
"width",
"=",
"rect",
".",
"getWidth",
"(",
")",
";",
"float",
"height",
"=",
"rect",
".",
"getHeight",
"(",
")",
";",
"rect",
".",
"setLeft",
"(",
"x",
")",
";",
"rect",
".",
"setBottom",
"(",
"y",
")",
";",
"rect",
".",
"setRight",
"(",
"rect",
".",
"getLeft",
"(",
")",
"+",
"width",
")",
";",
"rect",
".",
"setTop",
"(",
"rect",
".",
"getBottom",
"(",
")",
"+",
"height",
")",
";",
"}"
] | Move this rectangle to the specified bottom-left point.
@param rect rectangle to move
@param x new x origin
@param y new y origin | [
"Move",
"this",
"rectangle",
"to",
"the",
"specified",
"bottom",
"-",
"left",
"point",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/print/print/src/main/java/org/geomajas/plugin/printing/component/PdfContext.java#L302-L309 | train |
geomajas/geomajas-project-server | plugin/print/print/src/main/java/org/geomajas/plugin/printing/component/PdfContext.java | PdfContext.translateRectangle | public void translateRectangle(Rectangle rect, float dx, float dy) {
float width = rect.getWidth();
float height = rect.getHeight();
rect.setLeft(rect.getLeft() + dx);
rect.setBottom(rect.getBottom() + dy);
rect.setRight(rect.getLeft() + dx + width);
rect.setTop(rect.getBottom() + dy + height);
} | java | public void translateRectangle(Rectangle rect, float dx, float dy) {
float width = rect.getWidth();
float height = rect.getHeight();
rect.setLeft(rect.getLeft() + dx);
rect.setBottom(rect.getBottom() + dy);
rect.setRight(rect.getLeft() + dx + width);
rect.setTop(rect.getBottom() + dy + height);
} | [
"public",
"void",
"translateRectangle",
"(",
"Rectangle",
"rect",
",",
"float",
"dx",
",",
"float",
"dy",
")",
"{",
"float",
"width",
"=",
"rect",
".",
"getWidth",
"(",
")",
";",
"float",
"height",
"=",
"rect",
".",
"getHeight",
"(",
")",
";",
"rect",
".",
"setLeft",
"(",
"rect",
".",
"getLeft",
"(",
")",
"+",
"dx",
")",
";",
"rect",
".",
"setBottom",
"(",
"rect",
".",
"getBottom",
"(",
")",
"+",
"dy",
")",
";",
"rect",
".",
"setRight",
"(",
"rect",
".",
"getLeft",
"(",
")",
"+",
"dx",
"+",
"width",
")",
";",
"rect",
".",
"setTop",
"(",
"rect",
".",
"getBottom",
"(",
")",
"+",
"dy",
"+",
"height",
")",
";",
"}"
] | Translate this rectangle over the specified following distances.
@param rect rectangle to move
@param dx delta x
@param dy delta y | [
"Translate",
"this",
"rectangle",
"over",
"the",
"specified",
"following",
"distances",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/print/print/src/main/java/org/geomajas/plugin/printing/component/PdfContext.java#L318-L325 | train |
Subsets and Splits