repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
aseovic/coherence-tools | core/src/main/java/com/seovic/core/Defaults.java | Defaults.createExpression | public static Expression createExpression(String expression) {
try {
return INSTANCE.ctorExpression.newInstance(expression);
}
catch (Exception e) {
throw new RuntimeException(e);
}
} | java | public static Expression createExpression(String expression) {
try {
return INSTANCE.ctorExpression.newInstance(expression);
}
catch (Exception e) {
throw new RuntimeException(e);
}
} | [
"public",
"static",
"Expression",
"createExpression",
"(",
"String",
"expression",
")",
"{",
"try",
"{",
"return",
"INSTANCE",
".",
"ctorExpression",
".",
"newInstance",
"(",
"expression",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] | Creates a default expression instance.
@param expression string expression
@return expression instance | [
"Creates",
"a",
"default",
"expression",
"instance",
"."
] | 561a1d7e572ad98657fcd26beb1164891b0cd6fe | https://github.com/aseovic/coherence-tools/blob/561a1d7e572ad98657fcd26beb1164891b0cd6fe/core/src/main/java/com/seovic/core/Defaults.java#L72-L79 | train |
aseovic/coherence-tools | core/src/main/java/com/seovic/core/Defaults.java | Defaults.createExtractor | public static Extractor createExtractor(String expression) {
try {
return INSTANCE.ctorExtractor.newInstance(expression);
}
catch (Exception e) {
throw new RuntimeException(e);
}
} | java | public static Extractor createExtractor(String expression) {
try {
return INSTANCE.ctorExtractor.newInstance(expression);
}
catch (Exception e) {
throw new RuntimeException(e);
}
} | [
"public",
"static",
"Extractor",
"createExtractor",
"(",
"String",
"expression",
")",
"{",
"try",
"{",
"return",
"INSTANCE",
".",
"ctorExtractor",
".",
"newInstance",
"(",
"expression",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] | Creates a default extractor instance.
@param expression string expression
@return extractor instance | [
"Creates",
"a",
"default",
"extractor",
"instance",
"."
] | 561a1d7e572ad98657fcd26beb1164891b0cd6fe | https://github.com/aseovic/coherence-tools/blob/561a1d7e572ad98657fcd26beb1164891b0cd6fe/core/src/main/java/com/seovic/core/Defaults.java#L88-L95 | train |
aseovic/coherence-tools | core/src/main/java/com/seovic/core/Defaults.java | Defaults.createUpdater | public static Updater createUpdater(String expression) {
try {
return INSTANCE.ctorUpdater.newInstance(expression);
}
catch (Exception e) {
throw new RuntimeException(e);
}
} | java | public static Updater createUpdater(String expression) {
try {
return INSTANCE.ctorUpdater.newInstance(expression);
}
catch (Exception e) {
throw new RuntimeException(e);
}
} | [
"public",
"static",
"Updater",
"createUpdater",
"(",
"String",
"expression",
")",
"{",
"try",
"{",
"return",
"INSTANCE",
".",
"ctorUpdater",
".",
"newInstance",
"(",
"expression",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] | Creates a default updater instance.
@param expression string expression
@return updater instance | [
"Creates",
"a",
"default",
"updater",
"instance",
"."
] | 561a1d7e572ad98657fcd26beb1164891b0cd6fe | https://github.com/aseovic/coherence-tools/blob/561a1d7e572ad98657fcd26beb1164891b0cd6fe/core/src/main/java/com/seovic/core/Defaults.java#L104-L111 | train |
aseovic/coherence-tools | core/src/main/java/com/seovic/core/Defaults.java | Defaults.createCondition | public static Condition createCondition(String expression) {
try {
return INSTANCE.ctorCondition.newInstance(expression);
}
catch (Exception e) {
throw new RuntimeException(e);
}
} | java | public static Condition createCondition(String expression) {
try {
return INSTANCE.ctorCondition.newInstance(expression);
}
catch (Exception e) {
throw new RuntimeException(e);
}
} | [
"public",
"static",
"Condition",
"createCondition",
"(",
"String",
"expression",
")",
"{",
"try",
"{",
"return",
"INSTANCE",
".",
"ctorCondition",
".",
"newInstance",
"(",
"expression",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] | Creates a default condition instance.
@param expression conditional expression
@return condition instance | [
"Creates",
"a",
"default",
"condition",
"instance",
"."
] | 561a1d7e572ad98657fcd26beb1164891b0cd6fe | https://github.com/aseovic/coherence-tools/blob/561a1d7e572ad98657fcd26beb1164891b0cd6fe/core/src/main/java/com/seovic/core/Defaults.java#L120-L127 | train |
aseovic/coherence-tools | core/src/main/java/com/seovic/core/Defaults.java | Defaults.getConstructor | protected Constructor getConstructor(Class type) {
try {
return type.getConstructor(String.class);
}
catch (NoSuchMethodException e) {
throw new RuntimeException(
"Unable to find a constructor that accepts"
+ " a single String argument in the "
+ type.getName() + " class.", e);
}
} | java | protected Constructor getConstructor(Class type) {
try {
return type.getConstructor(String.class);
}
catch (NoSuchMethodException e) {
throw new RuntimeException(
"Unable to find a constructor that accepts"
+ " a single String argument in the "
+ type.getName() + " class.", e);
}
} | [
"protected",
"Constructor",
"getConstructor",
"(",
"Class",
"type",
")",
"{",
"try",
"{",
"return",
"type",
".",
"getConstructor",
"(",
"String",
".",
"class",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to find a constructor that accepts\"",
"+",
"\" a single String argument in the \"",
"+",
"type",
".",
"getName",
"(",
")",
"+",
"\" class.\"",
",",
"e",
")",
";",
"}",
"}"
] | Gets a constructor for the specified class that accepts a single String
argument.
@param type the class to find the constructor for
@return a constructor for the specified class that accepts a single
String argument | [
"Gets",
"a",
"constructor",
"for",
"the",
"specified",
"class",
"that",
"accepts",
"a",
"single",
"String",
"argument",
"."
] | 561a1d7e572ad98657fcd26beb1164891b0cd6fe | https://github.com/aseovic/coherence-tools/blob/561a1d7e572ad98657fcd26beb1164891b0cd6fe/core/src/main/java/com/seovic/core/Defaults.java#L141-L151 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EngineeringObjectModelWrapper.java | EngineeringObjectModelWrapper.enhance | public static EngineeringObjectModelWrapper enhance(AdvancedModelWrapper model) {
if (!model.isEngineeringObject()) {
throw new IllegalArgumentException("The model of the AdvancedModelWrapper is no EngineeringObject");
}
return new EngineeringObjectModelWrapper(model.getUnderlyingModel());
} | java | public static EngineeringObjectModelWrapper enhance(AdvancedModelWrapper model) {
if (!model.isEngineeringObject()) {
throw new IllegalArgumentException("The model of the AdvancedModelWrapper is no EngineeringObject");
}
return new EngineeringObjectModelWrapper(model.getUnderlyingModel());
} | [
"public",
"static",
"EngineeringObjectModelWrapper",
"enhance",
"(",
"AdvancedModelWrapper",
"model",
")",
"{",
"if",
"(",
"!",
"model",
".",
"isEngineeringObject",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The model of the AdvancedModelWrapper is no EngineeringObject\"",
")",
";",
"}",
"return",
"new",
"EngineeringObjectModelWrapper",
"(",
"model",
".",
"getUnderlyingModel",
"(",
")",
")",
";",
"}"
] | Returns the corresponding engineering object model wrapper to the given advanced model wrapper. | [
"Returns",
"the",
"corresponding",
"engineering",
"object",
"model",
"wrapper",
"to",
"the",
"given",
"advanced",
"model",
"wrapper",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EngineeringObjectModelWrapper.java#L45-L50 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EngineeringObjectModelWrapper.java | EngineeringObjectModelWrapper.getForeignKeyFields | public List<Field> getForeignKeyFields() {
List<Field> fields = new ArrayList<Field>();
for (Field field : model.getClass().getDeclaredFields()) {
if (field.isAnnotationPresent(OpenEngSBForeignKey.class)) {
fields.add(field);
}
}
return fields;
} | java | public List<Field> getForeignKeyFields() {
List<Field> fields = new ArrayList<Field>();
for (Field field : model.getClass().getDeclaredFields()) {
if (field.isAnnotationPresent(OpenEngSBForeignKey.class)) {
fields.add(field);
}
}
return fields;
} | [
"public",
"List",
"<",
"Field",
">",
"getForeignKeyFields",
"(",
")",
"{",
"List",
"<",
"Field",
">",
"fields",
"=",
"new",
"ArrayList",
"<",
"Field",
">",
"(",
")",
";",
"for",
"(",
"Field",
"field",
":",
"model",
".",
"getClass",
"(",
")",
".",
"getDeclaredFields",
"(",
")",
")",
"{",
"if",
"(",
"field",
".",
"isAnnotationPresent",
"(",
"OpenEngSBForeignKey",
".",
"class",
")",
")",
"{",
"fields",
".",
"add",
"(",
"field",
")",
";",
"}",
"}",
"return",
"fields",
";",
"}"
] | Returns a list of foreign key fields for the Engineering Object model. | [
"Returns",
"a",
"list",
"of",
"foreign",
"key",
"fields",
"for",
"the",
"Engineering",
"Object",
"model",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EngineeringObjectModelWrapper.java#L55-L63 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EngineeringObjectModelWrapper.java | EngineeringObjectModelWrapper.loadReferencedModel | public AdvancedModelWrapper loadReferencedModel(Field field, ModelRegistry modelRegistry,
EngineeringDatabaseService edbService, EDBConverter edbConverter) {
try {
ModelDescription description = getModelDescriptionFromField(field);
String modelKey = (String) FieldUtils.readField(field, model, true);
if (modelKey == null) {
return null;
}
modelKey = appendContextId(modelKey);
Class<?> sourceClass = modelRegistry.loadModel(description);
Object model = edbConverter.convertEDBObjectToModel(sourceClass,
edbService.getObject(modelKey));
return new AdvancedModelWrapper((OpenEngSBModel) model);
} catch (SecurityException e) {
throw new EKBException(generateErrorMessage(field), e);
} catch (IllegalArgumentException e) {
throw new EKBException(generateErrorMessage(field), e);
} catch (IllegalAccessException e) {
throw new EKBException(generateErrorMessage(field), e);
} catch (ClassNotFoundException e) {
throw new EKBException(generateErrorMessage(field), e);
}
} | java | public AdvancedModelWrapper loadReferencedModel(Field field, ModelRegistry modelRegistry,
EngineeringDatabaseService edbService, EDBConverter edbConverter) {
try {
ModelDescription description = getModelDescriptionFromField(field);
String modelKey = (String) FieldUtils.readField(field, model, true);
if (modelKey == null) {
return null;
}
modelKey = appendContextId(modelKey);
Class<?> sourceClass = modelRegistry.loadModel(description);
Object model = edbConverter.convertEDBObjectToModel(sourceClass,
edbService.getObject(modelKey));
return new AdvancedModelWrapper((OpenEngSBModel) model);
} catch (SecurityException e) {
throw new EKBException(generateErrorMessage(field), e);
} catch (IllegalArgumentException e) {
throw new EKBException(generateErrorMessage(field), e);
} catch (IllegalAccessException e) {
throw new EKBException(generateErrorMessage(field), e);
} catch (ClassNotFoundException e) {
throw new EKBException(generateErrorMessage(field), e);
}
} | [
"public",
"AdvancedModelWrapper",
"loadReferencedModel",
"(",
"Field",
"field",
",",
"ModelRegistry",
"modelRegistry",
",",
"EngineeringDatabaseService",
"edbService",
",",
"EDBConverter",
"edbConverter",
")",
"{",
"try",
"{",
"ModelDescription",
"description",
"=",
"getModelDescriptionFromField",
"(",
"field",
")",
";",
"String",
"modelKey",
"=",
"(",
"String",
")",
"FieldUtils",
".",
"readField",
"(",
"field",
",",
"model",
",",
"true",
")",
";",
"if",
"(",
"modelKey",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"modelKey",
"=",
"appendContextId",
"(",
"modelKey",
")",
";",
"Class",
"<",
"?",
">",
"sourceClass",
"=",
"modelRegistry",
".",
"loadModel",
"(",
"description",
")",
";",
"Object",
"model",
"=",
"edbConverter",
".",
"convertEDBObjectToModel",
"(",
"sourceClass",
",",
"edbService",
".",
"getObject",
"(",
"modelKey",
")",
")",
";",
"return",
"new",
"AdvancedModelWrapper",
"(",
"(",
"OpenEngSBModel",
")",
"model",
")",
";",
"}",
"catch",
"(",
"SecurityException",
"e",
")",
"{",
"throw",
"new",
"EKBException",
"(",
"generateErrorMessage",
"(",
"field",
")",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"EKBException",
"(",
"generateErrorMessage",
"(",
"field",
")",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"new",
"EKBException",
"(",
"generateErrorMessage",
"(",
"field",
")",
",",
"e",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"throw",
"new",
"EKBException",
"(",
"generateErrorMessage",
"(",
"field",
")",
",",
"e",
")",
";",
"}",
"}"
] | Loads the model referenced by the given field for the given model instance. Returns null if the field has no
value set. | [
"Loads",
"the",
"model",
"referenced",
"by",
"the",
"given",
"field",
"for",
"the",
"given",
"model",
"instance",
".",
"Returns",
"null",
"if",
"the",
"field",
"has",
"no",
"value",
"set",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EngineeringObjectModelWrapper.java#L69-L91 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EngineeringObjectModelWrapper.java | EngineeringObjectModelWrapper.getModelDescriptionFromField | private ModelDescription getModelDescriptionFromField(Field field) {
OpenEngSBForeignKey key = field.getAnnotation(OpenEngSBForeignKey.class);
ModelDescription description = new ModelDescription(key.modelType(), key.modelVersion());
return description;
} | java | private ModelDescription getModelDescriptionFromField(Field field) {
OpenEngSBForeignKey key = field.getAnnotation(OpenEngSBForeignKey.class);
ModelDescription description = new ModelDescription(key.modelType(), key.modelVersion());
return description;
} | [
"private",
"ModelDescription",
"getModelDescriptionFromField",
"(",
"Field",
"field",
")",
"{",
"OpenEngSBForeignKey",
"key",
"=",
"field",
".",
"getAnnotation",
"(",
"OpenEngSBForeignKey",
".",
"class",
")",
";",
"ModelDescription",
"description",
"=",
"new",
"ModelDescription",
"(",
"key",
".",
"modelType",
"(",
")",
",",
"key",
".",
"modelVersion",
"(",
")",
")",
";",
"return",
"description",
";",
"}"
] | Generates the model description of a field which is annotated with the OpenEngSBForeignKey annotation. | [
"Generates",
"the",
"model",
"description",
"of",
"a",
"field",
"which",
"is",
"annotated",
"with",
"the",
"OpenEngSBForeignKey",
"annotation",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EngineeringObjectModelWrapper.java#L103-L107 | train |
aseovic/coherence-tools | identity/src/main/java/com/seovic/identity/SequenceGenerator.java | SequenceGenerator.generateId | public synchronized Long generateId() {
if (sequenceBlock == null || !sequenceBlock.hasNext()) {
sequenceBlock = allocateSequenceBlock();
}
return sequenceBlock.next();
} | java | public synchronized Long generateId() {
if (sequenceBlock == null || !sequenceBlock.hasNext()) {
sequenceBlock = allocateSequenceBlock();
}
return sequenceBlock.next();
} | [
"public",
"synchronized",
"Long",
"generateId",
"(",
")",
"{",
"if",
"(",
"sequenceBlock",
"==",
"null",
"||",
"!",
"sequenceBlock",
".",
"hasNext",
"(",
")",
")",
"{",
"sequenceBlock",
"=",
"allocateSequenceBlock",
"(",
")",
";",
"}",
"return",
"sequenceBlock",
".",
"next",
"(",
")",
";",
"}"
] | Return the next number in the sequence.
@return the next number in the sequence | [
"Return",
"the",
"next",
"number",
"in",
"the",
"sequence",
"."
] | 561a1d7e572ad98657fcd26beb1164891b0cd6fe | https://github.com/aseovic/coherence-tools/blob/561a1d7e572ad98657fcd26beb1164891b0cd6fe/identity/src/main/java/com/seovic/identity/SequenceGenerator.java#L88-L93 | train |
openengsb/openengsb | components/ekb/transformation-wonderland/src/main/java/org/openengsb/core/ekb/transformation/wonderland/internal/operation/RemoveLeadingOperation.java | RemoveLeadingOperation.performRemoveLeading | private String performRemoveLeading(String source, Integer length, Matcher matcher) {
if (length != null && length != 0) {
matcher.region(0, length);
}
if (matcher.find()) {
String matched = matcher.group();
return source.substring(matched.length());
}
return source;
} | java | private String performRemoveLeading(String source, Integer length, Matcher matcher) {
if (length != null && length != 0) {
matcher.region(0, length);
}
if (matcher.find()) {
String matched = matcher.group();
return source.substring(matched.length());
}
return source;
} | [
"private",
"String",
"performRemoveLeading",
"(",
"String",
"source",
",",
"Integer",
"length",
",",
"Matcher",
"matcher",
")",
"{",
"if",
"(",
"length",
"!=",
"null",
"&&",
"length",
"!=",
"0",
")",
"{",
"matcher",
".",
"region",
"(",
"0",
",",
"length",
")",
";",
"}",
"if",
"(",
"matcher",
".",
"find",
"(",
")",
")",
"{",
"String",
"matched",
"=",
"matcher",
".",
"group",
"(",
")",
";",
"return",
"source",
".",
"substring",
"(",
"matched",
".",
"length",
"(",
")",
")",
";",
"}",
"return",
"source",
";",
"}"
] | Perform the remove leading operation. Returns the original string if the matcher does not match with the string | [
"Perform",
"the",
"remove",
"leading",
"operation",
".",
"Returns",
"the",
"original",
"string",
"if",
"the",
"matcher",
"does",
"not",
"match",
"with",
"the",
"string"
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/transformation-wonderland/src/main/java/org/openengsb/core/ekb/transformation/wonderland/internal/operation/RemoveLeadingOperation.java#L75-L84 | train |
FedericoPecora/meta-csp-framework | src/main/java/org/metacsp/spatial/geometry/Mat2.java | Mat2.set | public void set( float radians )
{
float c = (float)StrictMath.cos( radians );
float s = (float)StrictMath.sin( radians );
m00 = c;
m01 = -s;
m10 = s;
m11 = c;
} | java | public void set( float radians )
{
float c = (float)StrictMath.cos( radians );
float s = (float)StrictMath.sin( radians );
m00 = c;
m01 = -s;
m10 = s;
m11 = c;
} | [
"public",
"void",
"set",
"(",
"float",
"radians",
")",
"{",
"float",
"c",
"=",
"(",
"float",
")",
"StrictMath",
".",
"cos",
"(",
"radians",
")",
";",
"float",
"s",
"=",
"(",
"float",
")",
"StrictMath",
".",
"sin",
"(",
"radians",
")",
";",
"m00",
"=",
"c",
";",
"m01",
"=",
"-",
"s",
";",
"m10",
"=",
"s",
";",
"m11",
"=",
"c",
";",
"}"
] | Sets this matrix to a rotation matrix with the given radians.
@param radians Rotation in radians. | [
"Sets",
"this",
"matrix",
"to",
"a",
"rotation",
"matrix",
"with",
"the",
"given",
"radians",
"."
] | 42aaef2e2b76d0f738427f0dd9653c4f62b40517 | https://github.com/FedericoPecora/meta-csp-framework/blob/42aaef2e2b76d0f738427f0dd9653c4f62b40517/src/main/java/org/metacsp/spatial/geometry/Mat2.java#L41-L50 | train |
openengsb/openengsb | components/edbi/jdbc/src/main/java/org/openengsb/core/edbi/jdbc/driver/AbstractTypeMap.java | AbstractTypeMap.put | protected DataType put(Class<?> clazz, int type, String name) {
DataType dataType = new DataType(type, name);
map.put(clazz, dataType);
return dataType;
} | java | protected DataType put(Class<?> clazz, int type, String name) {
DataType dataType = new DataType(type, name);
map.put(clazz, dataType);
return dataType;
} | [
"protected",
"DataType",
"put",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"int",
"type",
",",
"String",
"name",
")",
"{",
"DataType",
"dataType",
"=",
"new",
"DataType",
"(",
"type",
",",
"name",
")",
";",
"map",
".",
"put",
"(",
"clazz",
",",
"dataType",
")",
";",
"return",
"dataType",
";",
"}"
] | Create a new DataType instance for the given type and name, and place it in the map with the given Class as key.
@param clazz the key
@param type the type of {@code java.sql.Types}
@param name the name of the type corresponding to the used dbms
@return the DataType created | [
"Create",
"a",
"new",
"DataType",
"instance",
"for",
"the",
"given",
"type",
"and",
"name",
"and",
"place",
"it",
"in",
"the",
"map",
"with",
"the",
"given",
"Class",
"as",
"key",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/edbi/jdbc/src/main/java/org/openengsb/core/edbi/jdbc/driver/AbstractTypeMap.java#L51-L55 | train |
openengsb/openengsb | components/util/src/main/java/org/openengsb/core/util/CipherUtils.java | CipherUtils.decrypt | public static byte[] decrypt(byte[] text, Key key) throws DecryptionException {
return decrypt(text, key, key.getAlgorithm());
} | java | public static byte[] decrypt(byte[] text, Key key) throws DecryptionException {
return decrypt(text, key, key.getAlgorithm());
} | [
"public",
"static",
"byte",
"[",
"]",
"decrypt",
"(",
"byte",
"[",
"]",
"text",
",",
"Key",
"key",
")",
"throws",
"DecryptionException",
"{",
"return",
"decrypt",
"(",
"text",
",",
"key",
",",
"key",
".",
"getAlgorithm",
"(",
")",
")",
";",
"}"
] | Decrypts the given data using the given key. The key holds the algorithm used for decryption. If you are
decrypting data that is supposed to be a string, consider that it might be Base64-encoded.
@throws DecryptionException if the string cannot be decrypted with the given key | [
"Decrypts",
"the",
"given",
"data",
"using",
"the",
"given",
"key",
".",
"The",
"key",
"holds",
"the",
"algorithm",
"used",
"for",
"decryption",
".",
"If",
"you",
"are",
"decrypting",
"data",
"that",
"is",
"supposed",
"to",
"be",
"a",
"string",
"consider",
"that",
"it",
"might",
"be",
"Base64",
"-",
"encoded",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/util/src/main/java/org/openengsb/core/util/CipherUtils.java#L59-L61 | train |
openengsb/openengsb | components/util/src/main/java/org/openengsb/core/util/CipherUtils.java | CipherUtils.decrypt | public static byte[] decrypt(byte[] text, Key key, String algorithm) throws DecryptionException {
Cipher cipher;
try {
LOGGER.trace("start decrypting text using {} cipher", algorithm);
cipher = Cipher.getInstance(algorithm);
cipher.init(Cipher.DECRYPT_MODE, key);
LOGGER.trace("initialized decryption with key of type {}", key.getClass());
} catch (GeneralSecurityException e) {
throw new IllegalArgumentException("unable to initialize cipher for algorithm " + algorithm, e);
}
try {
return cipher.doFinal(text);
} catch (GeneralSecurityException e) {
throw new DecryptionException("unable to decrypt data using algorithm " + algorithm, e);
}
} | java | public static byte[] decrypt(byte[] text, Key key, String algorithm) throws DecryptionException {
Cipher cipher;
try {
LOGGER.trace("start decrypting text using {} cipher", algorithm);
cipher = Cipher.getInstance(algorithm);
cipher.init(Cipher.DECRYPT_MODE, key);
LOGGER.trace("initialized decryption with key of type {}", key.getClass());
} catch (GeneralSecurityException e) {
throw new IllegalArgumentException("unable to initialize cipher for algorithm " + algorithm, e);
}
try {
return cipher.doFinal(text);
} catch (GeneralSecurityException e) {
throw new DecryptionException("unable to decrypt data using algorithm " + algorithm, e);
}
} | [
"public",
"static",
"byte",
"[",
"]",
"decrypt",
"(",
"byte",
"[",
"]",
"text",
",",
"Key",
"key",
",",
"String",
"algorithm",
")",
"throws",
"DecryptionException",
"{",
"Cipher",
"cipher",
";",
"try",
"{",
"LOGGER",
".",
"trace",
"(",
"\"start decrypting text using {} cipher\"",
",",
"algorithm",
")",
";",
"cipher",
"=",
"Cipher",
".",
"getInstance",
"(",
"algorithm",
")",
";",
"cipher",
".",
"init",
"(",
"Cipher",
".",
"DECRYPT_MODE",
",",
"key",
")",
";",
"LOGGER",
".",
"trace",
"(",
"\"initialized decryption with key of type {}\"",
",",
"key",
".",
"getClass",
"(",
")",
")",
";",
"}",
"catch",
"(",
"GeneralSecurityException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"unable to initialize cipher for algorithm \"",
"+",
"algorithm",
",",
"e",
")",
";",
"}",
"try",
"{",
"return",
"cipher",
".",
"doFinal",
"(",
"text",
")",
";",
"}",
"catch",
"(",
"GeneralSecurityException",
"e",
")",
"{",
"throw",
"new",
"DecryptionException",
"(",
"\"unable to decrypt data using algorithm \"",
"+",
"algorithm",
",",
"e",
")",
";",
"}",
"}"
] | Decrypts the given data using the given key using the given algorithm. If you are decrypting data that is
supposed to be a string, consider that it might be Base64-encoded.
@throws DecryptionException if the string cannot be decrypted with the given key
@throws IllegalArgumentException if the algorithm is not supported. | [
"Decrypts",
"the",
"given",
"data",
"using",
"the",
"given",
"key",
"using",
"the",
"given",
"algorithm",
".",
"If",
"you",
"are",
"decrypting",
"data",
"that",
"is",
"supposed",
"to",
"be",
"a",
"string",
"consider",
"that",
"it",
"might",
"be",
"Base64",
"-",
"encoded",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/util/src/main/java/org/openengsb/core/util/CipherUtils.java#L70-L85 | train |
openengsb/openengsb | components/util/src/main/java/org/openengsb/core/util/CipherUtils.java | CipherUtils.encrypt | public static byte[] encrypt(byte[] text, Key key) throws EncryptionException {
return encrypt(text, key, key.getAlgorithm());
} | java | public static byte[] encrypt(byte[] text, Key key) throws EncryptionException {
return encrypt(text, key, key.getAlgorithm());
} | [
"public",
"static",
"byte",
"[",
"]",
"encrypt",
"(",
"byte",
"[",
"]",
"text",
",",
"Key",
"key",
")",
"throws",
"EncryptionException",
"{",
"return",
"encrypt",
"(",
"text",
",",
"key",
",",
"key",
".",
"getAlgorithm",
"(",
")",
")",
";",
"}"
] | Encrypts the given data using the given key. The key holds the algorithm used for encryption. If you are
encrypting data that is supposed to be a string, consider that it might be Base64-encoded.
@throws EncryptionException if the string cannot be encrypted with the given key | [
"Encrypts",
"the",
"given",
"data",
"using",
"the",
"given",
"key",
".",
"The",
"key",
"holds",
"the",
"algorithm",
"used",
"for",
"encryption",
".",
"If",
"you",
"are",
"encrypting",
"data",
"that",
"is",
"supposed",
"to",
"be",
"a",
"string",
"consider",
"that",
"it",
"might",
"be",
"Base64",
"-",
"encoded",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/util/src/main/java/org/openengsb/core/util/CipherUtils.java#L93-L95 | train |
openengsb/openengsb | components/util/src/main/java/org/openengsb/core/util/CipherUtils.java | CipherUtils.encrypt | public static byte[] encrypt(byte[] text, Key key, String algorithm) throws EncryptionException {
Cipher cipher;
try {
LOGGER.trace("start encrypting text using {} cipher", algorithm);
cipher = Cipher.getInstance(algorithm);
cipher.init(Cipher.ENCRYPT_MODE, key);
LOGGER.trace("initialized encryption with key of type {}", key.getClass());
} catch (GeneralSecurityException e) {
throw new IllegalArgumentException("unable to initialize cipher for algorithm " + algorithm, e);
}
try {
return cipher.doFinal(text);
} catch (GeneralSecurityException e) {
throw new EncryptionException("unable to encrypt data using algorithm " + algorithm, e);
}
} | java | public static byte[] encrypt(byte[] text, Key key, String algorithm) throws EncryptionException {
Cipher cipher;
try {
LOGGER.trace("start encrypting text using {} cipher", algorithm);
cipher = Cipher.getInstance(algorithm);
cipher.init(Cipher.ENCRYPT_MODE, key);
LOGGER.trace("initialized encryption with key of type {}", key.getClass());
} catch (GeneralSecurityException e) {
throw new IllegalArgumentException("unable to initialize cipher for algorithm " + algorithm, e);
}
try {
return cipher.doFinal(text);
} catch (GeneralSecurityException e) {
throw new EncryptionException("unable to encrypt data using algorithm " + algorithm, e);
}
} | [
"public",
"static",
"byte",
"[",
"]",
"encrypt",
"(",
"byte",
"[",
"]",
"text",
",",
"Key",
"key",
",",
"String",
"algorithm",
")",
"throws",
"EncryptionException",
"{",
"Cipher",
"cipher",
";",
"try",
"{",
"LOGGER",
".",
"trace",
"(",
"\"start encrypting text using {} cipher\"",
",",
"algorithm",
")",
";",
"cipher",
"=",
"Cipher",
".",
"getInstance",
"(",
"algorithm",
")",
";",
"cipher",
".",
"init",
"(",
"Cipher",
".",
"ENCRYPT_MODE",
",",
"key",
")",
";",
"LOGGER",
".",
"trace",
"(",
"\"initialized encryption with key of type {}\"",
",",
"key",
".",
"getClass",
"(",
")",
")",
";",
"}",
"catch",
"(",
"GeneralSecurityException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"unable to initialize cipher for algorithm \"",
"+",
"algorithm",
",",
"e",
")",
";",
"}",
"try",
"{",
"return",
"cipher",
".",
"doFinal",
"(",
"text",
")",
";",
"}",
"catch",
"(",
"GeneralSecurityException",
"e",
")",
"{",
"throw",
"new",
"EncryptionException",
"(",
"\"unable to encrypt data using algorithm \"",
"+",
"algorithm",
",",
"e",
")",
";",
"}",
"}"
] | Encrypts the given data using the given key using the given algorithm. If you are encrypting data that is
supposed to be a string, consider encoding it in Base64.
@throws EncryptionException if the string cannot be encrypted with the given key
@throws IllegalArgumentException if the algorithm is not supported. | [
"Encrypts",
"the",
"given",
"data",
"using",
"the",
"given",
"key",
"using",
"the",
"given",
"algorithm",
".",
"If",
"you",
"are",
"encrypting",
"data",
"that",
"is",
"supposed",
"to",
"be",
"a",
"string",
"consider",
"encoding",
"it",
"in",
"Base64",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/util/src/main/java/org/openengsb/core/util/CipherUtils.java#L104-L119 | train |
openengsb/openengsb | components/util/src/main/java/org/openengsb/core/util/CipherUtils.java | CipherUtils.sign | public static byte[] sign(byte[] text, PrivateKey key, String algorithm) throws SignatureException {
Signature signature;
try {
signature = Signature.getInstance(algorithm);
signature.initSign(key);
} catch (GeneralSecurityException e) {
throw new IllegalArgumentException("cannot initialize signature for algorithm " + algorithm, e);
}
signature.update(text);
return signature.sign();
} | java | public static byte[] sign(byte[] text, PrivateKey key, String algorithm) throws SignatureException {
Signature signature;
try {
signature = Signature.getInstance(algorithm);
signature.initSign(key);
} catch (GeneralSecurityException e) {
throw new IllegalArgumentException("cannot initialize signature for algorithm " + algorithm, e);
}
signature.update(text);
return signature.sign();
} | [
"public",
"static",
"byte",
"[",
"]",
"sign",
"(",
"byte",
"[",
"]",
"text",
",",
"PrivateKey",
"key",
",",
"String",
"algorithm",
")",
"throws",
"SignatureException",
"{",
"Signature",
"signature",
";",
"try",
"{",
"signature",
"=",
"Signature",
".",
"getInstance",
"(",
"algorithm",
")",
";",
"signature",
".",
"initSign",
"(",
"key",
")",
";",
"}",
"catch",
"(",
"GeneralSecurityException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"cannot initialize signature for algorithm \"",
"+",
"algorithm",
",",
"e",
")",
";",
"}",
"signature",
".",
"update",
"(",
"text",
")",
";",
"return",
"signature",
".",
"sign",
"(",
")",
";",
"}"
] | create a signature for the given text using the PrivateKey and algorithm
Example: CipherUtils.sign(data, key, CipherUtils.DEFAULT_SIGN_ALGORITHM)
@throws SignatureException if the data cannot not be signed | [
"create",
"a",
"signature",
"for",
"the",
"given",
"text",
"using",
"the",
"PrivateKey",
"and",
"algorithm"
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/util/src/main/java/org/openengsb/core/util/CipherUtils.java#L207-L217 | train |
openengsb/openengsb | components/util/src/main/java/org/openengsb/core/util/CipherUtils.java | CipherUtils.verify | public static boolean verify(byte[] text, byte[] signatureValue, PublicKey key, String algorithm)
throws SignatureException {
Signature signature;
try {
signature = Signature.getInstance(algorithm);
signature.initVerify(key);
} catch (GeneralSecurityException e) {
throw new IllegalArgumentException("cannot initialize signature for algorithm " + algorithm, e);
}
signature.update(text);
return signature.verify(signatureValue);
} | java | public static boolean verify(byte[] text, byte[] signatureValue, PublicKey key, String algorithm)
throws SignatureException {
Signature signature;
try {
signature = Signature.getInstance(algorithm);
signature.initVerify(key);
} catch (GeneralSecurityException e) {
throw new IllegalArgumentException("cannot initialize signature for algorithm " + algorithm, e);
}
signature.update(text);
return signature.verify(signatureValue);
} | [
"public",
"static",
"boolean",
"verify",
"(",
"byte",
"[",
"]",
"text",
",",
"byte",
"[",
"]",
"signatureValue",
",",
"PublicKey",
"key",
",",
"String",
"algorithm",
")",
"throws",
"SignatureException",
"{",
"Signature",
"signature",
";",
"try",
"{",
"signature",
"=",
"Signature",
".",
"getInstance",
"(",
"algorithm",
")",
";",
"signature",
".",
"initVerify",
"(",
"key",
")",
";",
"}",
"catch",
"(",
"GeneralSecurityException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"cannot initialize signature for algorithm \"",
"+",
"algorithm",
",",
"e",
")",
";",
"}",
"signature",
".",
"update",
"(",
"text",
")",
";",
"return",
"signature",
".",
"verify",
"(",
"signatureValue",
")",
";",
"}"
] | verifies if the given data is valid for the given signature and public key.
@throws SignatureException if the algorithm cannot be initialized | [
"verifies",
"if",
"the",
"given",
"data",
"is",
"valid",
"for",
"the",
"given",
"signature",
"and",
"public",
"key",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/util/src/main/java/org/openengsb/core/util/CipherUtils.java#L224-L235 | train |
aseovic/coherence-tools | core/src/main/java/com/seovic/core/expression/OgnlExpression.java | OgnlExpression.getCompiledExpression | protected synchronized Object getCompiledExpression() {
if (compiledExpression == null) {
try {
compiledExpression = Ognl.parseExpression(getExpression());
}
catch (OgnlException e) {
throw new IllegalArgumentException("[" + getExpression() + "] is not a valid OGNL expression", e);
}
}
return compiledExpression;
} | java | protected synchronized Object getCompiledExpression() {
if (compiledExpression == null) {
try {
compiledExpression = Ognl.parseExpression(getExpression());
}
catch (OgnlException e) {
throw new IllegalArgumentException("[" + getExpression() + "] is not a valid OGNL expression", e);
}
}
return compiledExpression;
} | [
"protected",
"synchronized",
"Object",
"getCompiledExpression",
"(",
")",
"{",
"if",
"(",
"compiledExpression",
"==",
"null",
")",
"{",
"try",
"{",
"compiledExpression",
"=",
"Ognl",
".",
"parseExpression",
"(",
"getExpression",
"(",
")",
")",
";",
"}",
"catch",
"(",
"OgnlException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"[\"",
"+",
"getExpression",
"(",
")",
"+",
"\"] is not a valid OGNL expression\"",
",",
"e",
")",
";",
"}",
"}",
"return",
"compiledExpression",
";",
"}"
] | Return a compiled OGNL expression.
@return compiled OGNL expression | [
"Return",
"a",
"compiled",
"OGNL",
"expression",
"."
] | 561a1d7e572ad98657fcd26beb1164891b0cd6fe | https://github.com/aseovic/coherence-tools/blob/561a1d7e572ad98657fcd26beb1164891b0cd6fe/core/src/main/java/com/seovic/core/expression/OgnlExpression.java#L105-L115 | train |
BrunoEberhard/minimal-j | src/main/java/org/minimalj/model/ViewUtil.java | ViewUtil.view | public static <T> T view(Object completeObject, T viewObject) {
if (completeObject == null) return null;
Map<String, PropertyInterface> propertiesOfCompleteObject = FlatProperties.getProperties(completeObject.getClass());
Map<String, PropertyInterface> properties = FlatProperties.getProperties(viewObject.getClass());
for (Map.Entry<String, PropertyInterface> entry : properties.entrySet()) {
PropertyInterface property = propertiesOfCompleteObject.get(entry.getKey());
Object value = property != null ? property.getValue(completeObject) : readByGetMethod(completeObject, entry.getKey());
entry.getValue().setValue(viewObject, value);
}
return viewObject;
} | java | public static <T> T view(Object completeObject, T viewObject) {
if (completeObject == null) return null;
Map<String, PropertyInterface> propertiesOfCompleteObject = FlatProperties.getProperties(completeObject.getClass());
Map<String, PropertyInterface> properties = FlatProperties.getProperties(viewObject.getClass());
for (Map.Entry<String, PropertyInterface> entry : properties.entrySet()) {
PropertyInterface property = propertiesOfCompleteObject.get(entry.getKey());
Object value = property != null ? property.getValue(completeObject) : readByGetMethod(completeObject, entry.getKey());
entry.getValue().setValue(viewObject, value);
}
return viewObject;
} | [
"public",
"static",
"<",
"T",
">",
"T",
"view",
"(",
"Object",
"completeObject",
",",
"T",
"viewObject",
")",
"{",
"if",
"(",
"completeObject",
"==",
"null",
")",
"return",
"null",
";",
"Map",
"<",
"String",
",",
"PropertyInterface",
">",
"propertiesOfCompleteObject",
"=",
"FlatProperties",
".",
"getProperties",
"(",
"completeObject",
".",
"getClass",
"(",
")",
")",
";",
"Map",
"<",
"String",
",",
"PropertyInterface",
">",
"properties",
"=",
"FlatProperties",
".",
"getProperties",
"(",
"viewObject",
".",
"getClass",
"(",
")",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"PropertyInterface",
">",
"entry",
":",
"properties",
".",
"entrySet",
"(",
")",
")",
"{",
"PropertyInterface",
"property",
"=",
"propertiesOfCompleteObject",
".",
"get",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"Object",
"value",
"=",
"property",
"!=",
"null",
"?",
"property",
".",
"getValue",
"(",
"completeObject",
")",
":",
"readByGetMethod",
"(",
"completeObject",
",",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"entry",
".",
"getValue",
"(",
")",
".",
"setValue",
"(",
"viewObject",
",",
"value",
")",
";",
"}",
"return",
"viewObject",
";",
"}"
] | Creates a view to a complete object. Meaning all fields existing on view and
the complete object are copied from the complete object to the view.
@param <T> type of the view object
@param completeObject the source
@param viewObject the filled view object
@return the view object (same as input) | [
"Creates",
"a",
"view",
"to",
"a",
"complete",
"object",
".",
"Meaning",
"all",
"fields",
"existing",
"on",
"view",
"and",
"the",
"complete",
"object",
"are",
"copied",
"from",
"the",
"complete",
"object",
"to",
"the",
"view",
"."
] | f7c5461b2b47a10b383aee1e2f1f150f6773703b | https://github.com/BrunoEberhard/minimal-j/blob/f7c5461b2b47a10b383aee1e2f1f150f6773703b/src/main/java/org/minimalj/model/ViewUtil.java#L27-L39 | train |
BrunoEberhard/minimal-j | src/main/java/org/minimalj/model/ViewUtil.java | ViewUtil.viewed | public static <T> T viewed(View<T> viewObject) {
if (viewObject == null) return null;
@SuppressWarnings("unchecked")
Class<T> viewedClass = (Class<T>) getViewedClass(viewObject.getClass());
Object id = IdUtils.getId(viewObject);
if (id == null) {
return null;
}
return Backend.read(viewedClass, id);
} | java | public static <T> T viewed(View<T> viewObject) {
if (viewObject == null) return null;
@SuppressWarnings("unchecked")
Class<T> viewedClass = (Class<T>) getViewedClass(viewObject.getClass());
Object id = IdUtils.getId(viewObject);
if (id == null) {
return null;
}
return Backend.read(viewedClass, id);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"viewed",
"(",
"View",
"<",
"T",
">",
"viewObject",
")",
"{",
"if",
"(",
"viewObject",
"==",
"null",
")",
"return",
"null",
";",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Class",
"<",
"T",
">",
"viewedClass",
"=",
"(",
"Class",
"<",
"T",
">",
")",
"getViewedClass",
"(",
"viewObject",
".",
"getClass",
"(",
")",
")",
";",
"Object",
"id",
"=",
"IdUtils",
".",
"getId",
"(",
"viewObject",
")",
";",
"if",
"(",
"id",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"Backend",
".",
"read",
"(",
"viewedClass",
",",
"id",
")",
";",
"}"
] | Resolves a view object to the real object. Of course this is only possible by
asking the Backend to read the complete object. This method expects the view
to have an id.
@param <T> type of the complete object
@param viewObject the view object
@return the complete object (could be newer as the view object as the Backend
is asked) | [
"Resolves",
"a",
"view",
"object",
"to",
"the",
"real",
"object",
".",
"Of",
"course",
"this",
"is",
"only",
"possible",
"by",
"asking",
"the",
"Backend",
"to",
"read",
"the",
"complete",
"object",
".",
"This",
"method",
"expects",
"the",
"view",
"to",
"have",
"an",
"id",
"."
] | f7c5461b2b47a10b383aee1e2f1f150f6773703b | https://github.com/BrunoEberhard/minimal-j/blob/f7c5461b2b47a10b383aee1e2f1f150f6773703b/src/main/java/org/minimalj/model/ViewUtil.java#L62-L74 | train |
openengsb/openengsb | components/ekb/persistence-persist-edb/src/main/java/org/openengsb/core/ekb/persistence/persist/edb/internal/ModelDiff.java | ModelDiff.createModelDiff | public static ModelDiff createModelDiff(OpenEngSBModel before, OpenEngSBModel after) {
ModelDiff diff = new ModelDiff(before, after);
calculateDifferences(diff);
return diff;
} | java | public static ModelDiff createModelDiff(OpenEngSBModel before, OpenEngSBModel after) {
ModelDiff diff = new ModelDiff(before, after);
calculateDifferences(diff);
return diff;
} | [
"public",
"static",
"ModelDiff",
"createModelDiff",
"(",
"OpenEngSBModel",
"before",
",",
"OpenEngSBModel",
"after",
")",
"{",
"ModelDiff",
"diff",
"=",
"new",
"ModelDiff",
"(",
"before",
",",
"after",
")",
";",
"calculateDifferences",
"(",
"diff",
")",
";",
"return",
"diff",
";",
"}"
] | Creates an instance of the ModelDiff class based on the both models which are passed to the function. It
instantiate the class and calculates the differences of this two models. | [
"Creates",
"an",
"instance",
"of",
"the",
"ModelDiff",
"class",
"based",
"on",
"the",
"both",
"models",
"which",
"are",
"passed",
"to",
"the",
"function",
".",
"It",
"instantiate",
"the",
"class",
"and",
"calculates",
"the",
"differences",
"of",
"this",
"two",
"models",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/persistence-persist-edb/src/main/java/org/openengsb/core/ekb/persistence/persist/edb/internal/ModelDiff.java#L50-L54 | train |
openengsb/openengsb | components/ekb/persistence-persist-edb/src/main/java/org/openengsb/core/ekb/persistence/persist/edb/internal/ModelDiff.java | ModelDiff.createModelDiff | public static ModelDiff createModelDiff(OpenEngSBModel updated, String completeModelId,
EngineeringDatabaseService edbService, EDBConverter edbConverter) {
EDBObject queryResult = edbService.getObject(completeModelId);
OpenEngSBModel old = edbConverter.convertEDBObjectToModel(updated.getClass(), queryResult);
ModelDiff diff = new ModelDiff(old, updated);
calculateDifferences(diff);
return diff;
} | java | public static ModelDiff createModelDiff(OpenEngSBModel updated, String completeModelId,
EngineeringDatabaseService edbService, EDBConverter edbConverter) {
EDBObject queryResult = edbService.getObject(completeModelId);
OpenEngSBModel old = edbConverter.convertEDBObjectToModel(updated.getClass(), queryResult);
ModelDiff diff = new ModelDiff(old, updated);
calculateDifferences(diff);
return diff;
} | [
"public",
"static",
"ModelDiff",
"createModelDiff",
"(",
"OpenEngSBModel",
"updated",
",",
"String",
"completeModelId",
",",
"EngineeringDatabaseService",
"edbService",
",",
"EDBConverter",
"edbConverter",
")",
"{",
"EDBObject",
"queryResult",
"=",
"edbService",
".",
"getObject",
"(",
"completeModelId",
")",
";",
"OpenEngSBModel",
"old",
"=",
"edbConverter",
".",
"convertEDBObjectToModel",
"(",
"updated",
".",
"getClass",
"(",
")",
",",
"queryResult",
")",
";",
"ModelDiff",
"diff",
"=",
"new",
"ModelDiff",
"(",
"old",
",",
"updated",
")",
";",
"calculateDifferences",
"(",
"diff",
")",
";",
"return",
"diff",
";",
"}"
] | Creates an instance of the ModelDiff class based on the given model. It loads the old status of the model and
calculates the differences of this two models. | [
"Creates",
"an",
"instance",
"of",
"the",
"ModelDiff",
"class",
"based",
"on",
"the",
"given",
"model",
".",
"It",
"loads",
"the",
"old",
"status",
"of",
"the",
"model",
"and",
"calculates",
"the",
"differences",
"of",
"this",
"two",
"models",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/persistence-persist-edb/src/main/java/org/openengsb/core/ekb/persistence/persist/edb/internal/ModelDiff.java#L60-L67 | train |
openengsb/openengsb | components/ekb/persistence-persist-edb/src/main/java/org/openengsb/core/ekb/persistence/persist/edb/internal/ModelDiff.java | ModelDiff.calculateDifferences | private static void calculateDifferences(ModelDiff diff) {
Class<?> modelClass = diff.getBefore().getClass();
for (Field field : modelClass.getDeclaredFields()) {
if (field.getName().equals(ModelUtils.MODEL_TAIL_FIELD_NAME)) {
continue;
}
try {
Object before = FieldUtils.readField(field, diff.getBefore(), true);
Object after = FieldUtils.readField(field, diff.getAfter(), true);
if (!Objects.equal(before, after)) {
diff.addDifference(field, before, after);
}
} catch (IllegalAccessException e) {
LOGGER.warn("Skipped field '{}' because of illegal access to it", field.getName(), e);
}
}
} | java | private static void calculateDifferences(ModelDiff diff) {
Class<?> modelClass = diff.getBefore().getClass();
for (Field field : modelClass.getDeclaredFields()) {
if (field.getName().equals(ModelUtils.MODEL_TAIL_FIELD_NAME)) {
continue;
}
try {
Object before = FieldUtils.readField(field, diff.getBefore(), true);
Object after = FieldUtils.readField(field, diff.getAfter(), true);
if (!Objects.equal(before, after)) {
diff.addDifference(field, before, after);
}
} catch (IllegalAccessException e) {
LOGGER.warn("Skipped field '{}' because of illegal access to it", field.getName(), e);
}
}
} | [
"private",
"static",
"void",
"calculateDifferences",
"(",
"ModelDiff",
"diff",
")",
"{",
"Class",
"<",
"?",
">",
"modelClass",
"=",
"diff",
".",
"getBefore",
"(",
")",
".",
"getClass",
"(",
")",
";",
"for",
"(",
"Field",
"field",
":",
"modelClass",
".",
"getDeclaredFields",
"(",
")",
")",
"{",
"if",
"(",
"field",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"ModelUtils",
".",
"MODEL_TAIL_FIELD_NAME",
")",
")",
"{",
"continue",
";",
"}",
"try",
"{",
"Object",
"before",
"=",
"FieldUtils",
".",
"readField",
"(",
"field",
",",
"diff",
".",
"getBefore",
"(",
")",
",",
"true",
")",
";",
"Object",
"after",
"=",
"FieldUtils",
".",
"readField",
"(",
"field",
",",
"diff",
".",
"getAfter",
"(",
")",
",",
"true",
")",
";",
"if",
"(",
"!",
"Objects",
".",
"equal",
"(",
"before",
",",
"after",
")",
")",
"{",
"diff",
".",
"addDifference",
"(",
"field",
",",
"before",
",",
"after",
")",
";",
"}",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"Skipped field '{}' because of illegal access to it\"",
",",
"field",
".",
"getName",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}"
] | Calculates the real differences between the two models of the given ModelDiff and saves them to the differences
field of the ModelDiff class. | [
"Calculates",
"the",
"real",
"differences",
"between",
"the",
"two",
"models",
"of",
"the",
"given",
"ModelDiff",
"and",
"saves",
"them",
"to",
"the",
"differences",
"field",
"of",
"the",
"ModelDiff",
"class",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/persistence-persist-edb/src/main/java/org/openengsb/core/ekb/persistence/persist/edb/internal/ModelDiff.java#L79-L95 | train |
openengsb/openengsb | components/ekb/persistence-persist-edb/src/main/java/org/openengsb/core/ekb/persistence/persist/edb/internal/ModelDiff.java | ModelDiff.addDifference | public void addDifference(Field field, Object before, Object after) {
ModelDiffEntry entry = new ModelDiffEntry();
entry.setBefore(before);
entry.setAfter(after);
entry.setField(field);
differences.put(field, entry);
} | java | public void addDifference(Field field, Object before, Object after) {
ModelDiffEntry entry = new ModelDiffEntry();
entry.setBefore(before);
entry.setAfter(after);
entry.setField(field);
differences.put(field, entry);
} | [
"public",
"void",
"addDifference",
"(",
"Field",
"field",
",",
"Object",
"before",
",",
"Object",
"after",
")",
"{",
"ModelDiffEntry",
"entry",
"=",
"new",
"ModelDiffEntry",
"(",
")",
";",
"entry",
".",
"setBefore",
"(",
"before",
")",
";",
"entry",
".",
"setAfter",
"(",
"after",
")",
";",
"entry",
".",
"setField",
"(",
"field",
")",
";",
"differences",
".",
"put",
"(",
"field",
",",
"entry",
")",
";",
"}"
] | Adds a difference to the list of differences of this ModelDiff instance. | [
"Adds",
"a",
"difference",
"to",
"the",
"list",
"of",
"differences",
"of",
"this",
"ModelDiff",
"instance",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/persistence-persist-edb/src/main/java/org/openengsb/core/ekb/persistence/persist/edb/internal/ModelDiff.java#L100-L106 | train |
openengsb/openengsb | components/ekb/persistence-persist-edb/src/main/java/org/openengsb/core/ekb/persistence/persist/edb/internal/ModelDiff.java | ModelDiff.isForeignKeyChanged | public boolean isForeignKeyChanged() {
return CollectionUtils.exists(differences.values(), new Predicate() {
@Override
public boolean evaluate(Object object) {
return ((ModelDiffEntry) object).isForeignKey();
}
});
} | java | public boolean isForeignKeyChanged() {
return CollectionUtils.exists(differences.values(), new Predicate() {
@Override
public boolean evaluate(Object object) {
return ((ModelDiffEntry) object).isForeignKey();
}
});
} | [
"public",
"boolean",
"isForeignKeyChanged",
"(",
")",
"{",
"return",
"CollectionUtils",
".",
"exists",
"(",
"differences",
".",
"values",
"(",
")",
",",
"new",
"Predicate",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"evaluate",
"(",
"Object",
"object",
")",
"{",
"return",
"(",
"(",
"ModelDiffEntry",
")",
"object",
")",
".",
"isForeignKey",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Returns true if one of the differences of this ModelDiff instance is an OpenEngSBForeignKey. Returns false
otherwise. | [
"Returns",
"true",
"if",
"one",
"of",
"the",
"differences",
"of",
"this",
"ModelDiff",
"instance",
"is",
"an",
"OpenEngSBForeignKey",
".",
"Returns",
"false",
"otherwise",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/persistence-persist-edb/src/main/java/org/openengsb/core/ekb/persistence/persist/edb/internal/ModelDiff.java#L112-L119 | train |
FedericoPecora/meta-csp-framework | src/main/java/org/metacsp/multi/spatial/DE9IM/PolygonalDomain.java | PolygonalDomain.containsPoint | public boolean containsPoint(Coordinate point) {
Point p = new GeometryFactory().createPoint(point);
return this.getGeometry().contains(p);
} | java | public boolean containsPoint(Coordinate point) {
Point p = new GeometryFactory().createPoint(point);
return this.getGeometry().contains(p);
} | [
"public",
"boolean",
"containsPoint",
"(",
"Coordinate",
"point",
")",
"{",
"Point",
"p",
"=",
"new",
"GeometryFactory",
"(",
")",
".",
"createPoint",
"(",
"point",
")",
";",
"return",
"this",
".",
"getGeometry",
"(",
")",
".",
"contains",
"(",
"p",
")",
";",
"}"
] | Check whether this polygon contains a given point.
@param point The coordinates specifying the point to check.
@return <code>true</code> this {@link PolygonalDomain} contains this point. | [
"Check",
"whether",
"this",
"polygon",
"contains",
"a",
"given",
"point",
"."
] | 42aaef2e2b76d0f738427f0dd9653c4f62b40517 | https://github.com/FedericoPecora/meta-csp-framework/blob/42aaef2e2b76d0f738427f0dd9653c4f62b40517/src/main/java/org/metacsp/multi/spatial/DE9IM/PolygonalDomain.java#L46-L49 | train |
openengsb/openengsb | components/services/src/main/java/org/openengsb/core/services/SecurityContext.java | SecurityContext.executeWithSystemPermissions | public static <ReturnType> ReturnType executeWithSystemPermissions(Callable<ReturnType> task)
throws ExecutionException {
ContextAwareCallable<ReturnType> contextAwareCallable = new ContextAwareCallable<ReturnType>(task);
Subject newsubject = new Subject.Builder().buildSubject();
newsubject.login(new RootAuthenticationToken());
try {
return newsubject.execute(contextAwareCallable);
} finally {
newsubject.logout();
}
} | java | public static <ReturnType> ReturnType executeWithSystemPermissions(Callable<ReturnType> task)
throws ExecutionException {
ContextAwareCallable<ReturnType> contextAwareCallable = new ContextAwareCallable<ReturnType>(task);
Subject newsubject = new Subject.Builder().buildSubject();
newsubject.login(new RootAuthenticationToken());
try {
return newsubject.execute(contextAwareCallable);
} finally {
newsubject.logout();
}
} | [
"public",
"static",
"<",
"ReturnType",
">",
"ReturnType",
"executeWithSystemPermissions",
"(",
"Callable",
"<",
"ReturnType",
">",
"task",
")",
"throws",
"ExecutionException",
"{",
"ContextAwareCallable",
"<",
"ReturnType",
">",
"contextAwareCallable",
"=",
"new",
"ContextAwareCallable",
"<",
"ReturnType",
">",
"(",
"task",
")",
";",
"Subject",
"newsubject",
"=",
"new",
"Subject",
".",
"Builder",
"(",
")",
".",
"buildSubject",
"(",
")",
";",
"newsubject",
".",
"login",
"(",
"new",
"RootAuthenticationToken",
"(",
")",
")",
";",
"try",
"{",
"return",
"newsubject",
".",
"execute",
"(",
"contextAwareCallable",
")",
";",
"}",
"finally",
"{",
"newsubject",
".",
"logout",
"(",
")",
";",
"}",
"}"
] | Executes the given task with root-permissions. Use with care.
@throws ExecutionException if an exception occurs during the execution of the task | [
"Executes",
"the",
"given",
"task",
"with",
"root",
"-",
"permissions",
".",
"Use",
"with",
"care",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/services/src/main/java/org/openengsb/core/services/SecurityContext.java#L39-L49 | train |
openengsb/openengsb | components/services/src/main/java/org/openengsb/core/services/SecurityContext.java | SecurityContext.executeWithSystemPermissions | public static void executeWithSystemPermissions(Runnable task) {
ContextAwareRunnable contextAwaretask = new ContextAwareRunnable(task);
Subject newsubject = new Subject.Builder().buildSubject();
newsubject.login(new RootAuthenticationToken());
try {
newsubject.execute(contextAwaretask);
} finally {
newsubject.logout();
}
} | java | public static void executeWithSystemPermissions(Runnable task) {
ContextAwareRunnable contextAwaretask = new ContextAwareRunnable(task);
Subject newsubject = new Subject.Builder().buildSubject();
newsubject.login(new RootAuthenticationToken());
try {
newsubject.execute(contextAwaretask);
} finally {
newsubject.logout();
}
} | [
"public",
"static",
"void",
"executeWithSystemPermissions",
"(",
"Runnable",
"task",
")",
"{",
"ContextAwareRunnable",
"contextAwaretask",
"=",
"new",
"ContextAwareRunnable",
"(",
"task",
")",
";",
"Subject",
"newsubject",
"=",
"new",
"Subject",
".",
"Builder",
"(",
")",
".",
"buildSubject",
"(",
")",
";",
"newsubject",
".",
"login",
"(",
"new",
"RootAuthenticationToken",
"(",
")",
")",
";",
"try",
"{",
"newsubject",
".",
"execute",
"(",
"contextAwaretask",
")",
";",
"}",
"finally",
"{",
"newsubject",
".",
"logout",
"(",
")",
";",
"}",
"}"
] | wraps an existing ExecutorService to handle context- and security-related threadlocal variables | [
"wraps",
"an",
"existing",
"ExecutorService",
"to",
"handle",
"context",
"-",
"and",
"security",
"-",
"related",
"threadlocal",
"variables"
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/services/src/main/java/org/openengsb/core/services/SecurityContext.java#L54-L63 | train |
openengsb/openengsb | components/services/src/main/java/org/openengsb/core/services/SecurityContext.java | SecurityContext.getSecurityContextAwareExecutor | public static ExecutorService getSecurityContextAwareExecutor(ExecutorService original) {
SubjectAwareExecutorService subjectAwareExecutor = new SubjectAwareExecutorService(original);
return ThreadLocalUtil.contextAwareExecutor(subjectAwareExecutor);
} | java | public static ExecutorService getSecurityContextAwareExecutor(ExecutorService original) {
SubjectAwareExecutorService subjectAwareExecutor = new SubjectAwareExecutorService(original);
return ThreadLocalUtil.contextAwareExecutor(subjectAwareExecutor);
} | [
"public",
"static",
"ExecutorService",
"getSecurityContextAwareExecutor",
"(",
"ExecutorService",
"original",
")",
"{",
"SubjectAwareExecutorService",
"subjectAwareExecutor",
"=",
"new",
"SubjectAwareExecutorService",
"(",
"original",
")",
";",
"return",
"ThreadLocalUtil",
".",
"contextAwareExecutor",
"(",
"subjectAwareExecutor",
")",
";",
"}"
] | Wrap the given executor so that it takes authentication-information and context are inherited to tasks when they
are submitted. | [
"Wrap",
"the",
"given",
"executor",
"so",
"that",
"it",
"takes",
"authentication",
"-",
"information",
"and",
"context",
"are",
"inherited",
"to",
"tasks",
"when",
"they",
"are",
"submitted",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/services/src/main/java/org/openengsb/core/services/SecurityContext.java#L69-L72 | train |
openengsb/openengsb | components/util/src/main/java/org/openengsb/core/util/BeanUtilsExtended.java | BeanUtilsExtended.createBeanFromAttributeMap | public static <BeanType> BeanType createBeanFromAttributeMap(Class<BeanType> beanType,
Map<String, ? extends Object> attributeValues) {
BeanType instance;
try {
instance = beanType.newInstance();
BeanUtils.populate(instance, attributeValues);
} catch (Exception e) {
ReflectionUtils.handleReflectionException(e);
throw new IllegalStateException("Should never get here");
}
return instance;
} | java | public static <BeanType> BeanType createBeanFromAttributeMap(Class<BeanType> beanType,
Map<String, ? extends Object> attributeValues) {
BeanType instance;
try {
instance = beanType.newInstance();
BeanUtils.populate(instance, attributeValues);
} catch (Exception e) {
ReflectionUtils.handleReflectionException(e);
throw new IllegalStateException("Should never get here");
}
return instance;
} | [
"public",
"static",
"<",
"BeanType",
">",
"BeanType",
"createBeanFromAttributeMap",
"(",
"Class",
"<",
"BeanType",
">",
"beanType",
",",
"Map",
"<",
"String",
",",
"?",
"extends",
"Object",
">",
"attributeValues",
")",
"{",
"BeanType",
"instance",
";",
"try",
"{",
"instance",
"=",
"beanType",
".",
"newInstance",
"(",
")",
";",
"BeanUtils",
".",
"populate",
"(",
"instance",
",",
"attributeValues",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"ReflectionUtils",
".",
"handleReflectionException",
"(",
"e",
")",
";",
"throw",
"new",
"IllegalStateException",
"(",
"\"Should never get here\"",
")",
";",
"}",
"return",
"instance",
";",
"}"
] | Creates a new instance of the beanType and populates it with the property-values from the map
@throws IllegalArgumentException if the bean cannot be populated because of errors in the definition of the
beantype | [
"Creates",
"a",
"new",
"instance",
"of",
"the",
"beanType",
"and",
"populates",
"it",
"with",
"the",
"property",
"-",
"values",
"from",
"the",
"map"
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/util/src/main/java/org/openengsb/core/util/BeanUtilsExtended.java#L83-L94 | train |
openengsb/openengsb | components/workflow/src/main/java/org/openengsb/core/workflow/drools/internal/RulebaseBuilder.java | RulebaseBuilder.reloadRulebase | public synchronized void reloadRulebase() throws RuleBaseException {
long start = System.currentTimeMillis();
reloadDeclarations();
packageStrings.clear();
for (RuleBaseElementId id : manager.listAll(RuleBaseElementType.Function)) {
String packageName = id.getPackageName();
StringBuffer packageString = getPackageString(packageName);
String code = manager.get(id);
packageString.append(code);
}
for (RuleBaseElementId id : manager.listAll(RuleBaseElementType.Rule)) {
String packageName = id.getPackageName();
StringBuffer packageString = getPackageString(packageName);
String code = manager.get(id);
String formattedRule = String.format(RULE_TEMPLATE, id.getName(), code);
packageString.append(formattedRule);
}
for (RuleBaseElementId id : manager.listAll(RuleBaseElementType.Process)) {
getPackageString(id.getPackageName());
}
Collection<KnowledgePackage> compiledPackages = new HashSet<KnowledgePackage>();
if (packageStrings.isEmpty()) {
Set<String> emptySet = Collections.emptySet();
compiledPackages.addAll(compileDrlString("package dummy;\n" + declarations, emptySet));
} else {
for (Map.Entry<String, StringBuffer> entry : packageStrings.entrySet()) {
String packageName = entry.getKey();
StringBuffer drlCode = entry.getValue();
Collection<String> flows = queryFlows(packageName);
Collection<KnowledgePackage> compiledDrlPackage = compileDrlString(drlCode.toString(), flows);
compiledPackages.addAll(compiledDrlPackage);
}
}
lockRuleBase();
clearRulebase();
base.addKnowledgePackages(compiledPackages);
unlockRuleBase();
LOGGER.info("Reloading the rulebase took {}ms", System.currentTimeMillis() - start);
} | java | public synchronized void reloadRulebase() throws RuleBaseException {
long start = System.currentTimeMillis();
reloadDeclarations();
packageStrings.clear();
for (RuleBaseElementId id : manager.listAll(RuleBaseElementType.Function)) {
String packageName = id.getPackageName();
StringBuffer packageString = getPackageString(packageName);
String code = manager.get(id);
packageString.append(code);
}
for (RuleBaseElementId id : manager.listAll(RuleBaseElementType.Rule)) {
String packageName = id.getPackageName();
StringBuffer packageString = getPackageString(packageName);
String code = manager.get(id);
String formattedRule = String.format(RULE_TEMPLATE, id.getName(), code);
packageString.append(formattedRule);
}
for (RuleBaseElementId id : manager.listAll(RuleBaseElementType.Process)) {
getPackageString(id.getPackageName());
}
Collection<KnowledgePackage> compiledPackages = new HashSet<KnowledgePackage>();
if (packageStrings.isEmpty()) {
Set<String> emptySet = Collections.emptySet();
compiledPackages.addAll(compileDrlString("package dummy;\n" + declarations, emptySet));
} else {
for (Map.Entry<String, StringBuffer> entry : packageStrings.entrySet()) {
String packageName = entry.getKey();
StringBuffer drlCode = entry.getValue();
Collection<String> flows = queryFlows(packageName);
Collection<KnowledgePackage> compiledDrlPackage = compileDrlString(drlCode.toString(), flows);
compiledPackages.addAll(compiledDrlPackage);
}
}
lockRuleBase();
clearRulebase();
base.addKnowledgePackages(compiledPackages);
unlockRuleBase();
LOGGER.info("Reloading the rulebase took {}ms", System.currentTimeMillis() - start);
} | [
"public",
"synchronized",
"void",
"reloadRulebase",
"(",
")",
"throws",
"RuleBaseException",
"{",
"long",
"start",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"reloadDeclarations",
"(",
")",
";",
"packageStrings",
".",
"clear",
"(",
")",
";",
"for",
"(",
"RuleBaseElementId",
"id",
":",
"manager",
".",
"listAll",
"(",
"RuleBaseElementType",
".",
"Function",
")",
")",
"{",
"String",
"packageName",
"=",
"id",
".",
"getPackageName",
"(",
")",
";",
"StringBuffer",
"packageString",
"=",
"getPackageString",
"(",
"packageName",
")",
";",
"String",
"code",
"=",
"manager",
".",
"get",
"(",
"id",
")",
";",
"packageString",
".",
"append",
"(",
"code",
")",
";",
"}",
"for",
"(",
"RuleBaseElementId",
"id",
":",
"manager",
".",
"listAll",
"(",
"RuleBaseElementType",
".",
"Rule",
")",
")",
"{",
"String",
"packageName",
"=",
"id",
".",
"getPackageName",
"(",
")",
";",
"StringBuffer",
"packageString",
"=",
"getPackageString",
"(",
"packageName",
")",
";",
"String",
"code",
"=",
"manager",
".",
"get",
"(",
"id",
")",
";",
"String",
"formattedRule",
"=",
"String",
".",
"format",
"(",
"RULE_TEMPLATE",
",",
"id",
".",
"getName",
"(",
")",
",",
"code",
")",
";",
"packageString",
".",
"append",
"(",
"formattedRule",
")",
";",
"}",
"for",
"(",
"RuleBaseElementId",
"id",
":",
"manager",
".",
"listAll",
"(",
"RuleBaseElementType",
".",
"Process",
")",
")",
"{",
"getPackageString",
"(",
"id",
".",
"getPackageName",
"(",
")",
")",
";",
"}",
"Collection",
"<",
"KnowledgePackage",
">",
"compiledPackages",
"=",
"new",
"HashSet",
"<",
"KnowledgePackage",
">",
"(",
")",
";",
"if",
"(",
"packageStrings",
".",
"isEmpty",
"(",
")",
")",
"{",
"Set",
"<",
"String",
">",
"emptySet",
"=",
"Collections",
".",
"emptySet",
"(",
")",
";",
"compiledPackages",
".",
"addAll",
"(",
"compileDrlString",
"(",
"\"package dummy;\\n\"",
"+",
"declarations",
",",
"emptySet",
")",
")",
";",
"}",
"else",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"StringBuffer",
">",
"entry",
":",
"packageStrings",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"packageName",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"StringBuffer",
"drlCode",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"Collection",
"<",
"String",
">",
"flows",
"=",
"queryFlows",
"(",
"packageName",
")",
";",
"Collection",
"<",
"KnowledgePackage",
">",
"compiledDrlPackage",
"=",
"compileDrlString",
"(",
"drlCode",
".",
"toString",
"(",
")",
",",
"flows",
")",
";",
"compiledPackages",
".",
"addAll",
"(",
"compiledDrlPackage",
")",
";",
"}",
"}",
"lockRuleBase",
"(",
")",
";",
"clearRulebase",
"(",
")",
";",
"base",
".",
"addKnowledgePackages",
"(",
"compiledPackages",
")",
";",
"unlockRuleBase",
"(",
")",
";",
"LOGGER",
".",
"info",
"(",
"\"Reloading the rulebase took {}ms\"",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"start",
")",
";",
"}"
] | reloads the rulebase but keeps references intact
@throws RuleBaseException if the rulebase contains errors | [
"reloads",
"the",
"rulebase",
"but",
"keeps",
"references",
"intact"
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/workflow/src/main/java/org/openengsb/core/workflow/drools/internal/RulebaseBuilder.java#L73-L112 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java | EDBConverter.convertEDBObjectToModel | @SuppressWarnings("unchecked")
public <T> T convertEDBObjectToModel(Class<T> model, EDBObject object) {
return (T) convertEDBObjectToUncheckedModel(model, object);
} | java | @SuppressWarnings("unchecked")
public <T> T convertEDBObjectToModel(Class<T> model, EDBObject object) {
return (T) convertEDBObjectToUncheckedModel(model, object);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"T",
"convertEDBObjectToModel",
"(",
"Class",
"<",
"T",
">",
"model",
",",
"EDBObject",
"object",
")",
"{",
"return",
"(",
"T",
")",
"convertEDBObjectToUncheckedModel",
"(",
"model",
",",
"object",
")",
";",
"}"
] | Converts an EDBObject to a model of the given model type. | [
"Converts",
"an",
"EDBObject",
"to",
"a",
"model",
"of",
"the",
"given",
"model",
"type",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java#L77-L80 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java | EDBConverter.convertEDBObjectsToModelObjects | public <T> List<T> convertEDBObjectsToModelObjects(Class<T> model, List<EDBObject> objects) {
List<T> models = new ArrayList<>();
for (EDBObject object : objects) {
T instance = convertEDBObjectToModel(model, object);
if (instance != null) {
models.add(instance);
}
}
return models;
} | java | public <T> List<T> convertEDBObjectsToModelObjects(Class<T> model, List<EDBObject> objects) {
List<T> models = new ArrayList<>();
for (EDBObject object : objects) {
T instance = convertEDBObjectToModel(model, object);
if (instance != null) {
models.add(instance);
}
}
return models;
} | [
"public",
"<",
"T",
">",
"List",
"<",
"T",
">",
"convertEDBObjectsToModelObjects",
"(",
"Class",
"<",
"T",
">",
"model",
",",
"List",
"<",
"EDBObject",
">",
"objects",
")",
"{",
"List",
"<",
"T",
">",
"models",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"EDBObject",
"object",
":",
"objects",
")",
"{",
"T",
"instance",
"=",
"convertEDBObjectToModel",
"(",
"model",
",",
"object",
")",
";",
"if",
"(",
"instance",
"!=",
"null",
")",
"{",
"models",
".",
"add",
"(",
"instance",
")",
";",
"}",
"}",
"return",
"models",
";",
"}"
] | Converts a list of EDBObjects to a list of models of the given model type. | [
"Converts",
"a",
"list",
"of",
"EDBObjects",
"to",
"a",
"list",
"of",
"models",
"of",
"the",
"given",
"model",
"type",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java#L85-L94 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java | EDBConverter.checkEDBObjectModelType | private boolean checkEDBObjectModelType(EDBObject object, Class<?> model) {
String modelClass = object.getString(EDBConstants.MODEL_TYPE);
if (modelClass == null) {
LOGGER.warn(String.format("The EDBObject with the oid %s has no model type information."
+ "The resulting model may be a different model type than expected.", object.getOID()));
}
if (modelClass != null && !modelClass.equals(model.getName())) {
return false;
}
return true;
} | java | private boolean checkEDBObjectModelType(EDBObject object, Class<?> model) {
String modelClass = object.getString(EDBConstants.MODEL_TYPE);
if (modelClass == null) {
LOGGER.warn(String.format("The EDBObject with the oid %s has no model type information."
+ "The resulting model may be a different model type than expected.", object.getOID()));
}
if (modelClass != null && !modelClass.equals(model.getName())) {
return false;
}
return true;
} | [
"private",
"boolean",
"checkEDBObjectModelType",
"(",
"EDBObject",
"object",
",",
"Class",
"<",
"?",
">",
"model",
")",
"{",
"String",
"modelClass",
"=",
"object",
".",
"getString",
"(",
"EDBConstants",
".",
"MODEL_TYPE",
")",
";",
"if",
"(",
"modelClass",
"==",
"null",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"String",
".",
"format",
"(",
"\"The EDBObject with the oid %s has no model type information.\"",
"+",
"\"The resulting model may be a different model type than expected.\"",
",",
"object",
".",
"getOID",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"modelClass",
"!=",
"null",
"&&",
"!",
"modelClass",
".",
"equals",
"(",
"model",
".",
"getName",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Tests if an EDBObject has the correct model class in which it should be converted. Returns false if the model
type is not fitting, returns true if the model type is fitting or model type is unknown. | [
"Tests",
"if",
"an",
"EDBObject",
"has",
"the",
"correct",
"model",
"class",
"in",
"which",
"it",
"should",
"be",
"converted",
".",
"Returns",
"false",
"if",
"the",
"model",
"type",
"is",
"not",
"fitting",
"returns",
"true",
"if",
"the",
"model",
"type",
"is",
"fitting",
"or",
"model",
"type",
"is",
"unknown",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java#L100-L110 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java | EDBConverter.convertEDBObjectToUncheckedModel | private Object convertEDBObjectToUncheckedModel(Class<?> model, EDBObject object) {
if (!checkEDBObjectModelType(object, model)) {
return null;
}
filterEngineeringObjectInformation(object, model);
List<OpenEngSBModelEntry> entries = new ArrayList<>();
for (PropertyDescriptor propertyDescriptor : getPropertyDescriptorsForClass(model)) {
if (propertyDescriptor.getWriteMethod() == null
|| propertyDescriptor.getName().equals(ModelUtils.MODEL_TAIL_FIELD_NAME)) {
continue;
}
Object value = getValueForProperty(propertyDescriptor, object);
Class<?> propertyClass = propertyDescriptor.getPropertyType();
if (propertyClass.isPrimitive()) {
entries.add(new OpenEngSBModelEntry(propertyDescriptor.getName(), value, ClassUtils
.primitiveToWrapper(propertyClass)));
} else {
entries.add(new OpenEngSBModelEntry(propertyDescriptor.getName(), value, propertyClass));
}
}
for (Map.Entry<String, EDBObjectEntry> objectEntry : object.entrySet()) {
EDBObjectEntry entry = objectEntry.getValue();
Class<?> entryType;
try {
entryType = model.getClassLoader().loadClass(entry.getType());
entries.add(new OpenEngSBModelEntry(entry.getKey(), entry.getValue(), entryType));
} catch (ClassNotFoundException e) {
LOGGER.error("Unable to load class {} of the model tail", entry.getType());
}
}
return ModelUtils.createModel(model, entries);
} | java | private Object convertEDBObjectToUncheckedModel(Class<?> model, EDBObject object) {
if (!checkEDBObjectModelType(object, model)) {
return null;
}
filterEngineeringObjectInformation(object, model);
List<OpenEngSBModelEntry> entries = new ArrayList<>();
for (PropertyDescriptor propertyDescriptor : getPropertyDescriptorsForClass(model)) {
if (propertyDescriptor.getWriteMethod() == null
|| propertyDescriptor.getName().equals(ModelUtils.MODEL_TAIL_FIELD_NAME)) {
continue;
}
Object value = getValueForProperty(propertyDescriptor, object);
Class<?> propertyClass = propertyDescriptor.getPropertyType();
if (propertyClass.isPrimitive()) {
entries.add(new OpenEngSBModelEntry(propertyDescriptor.getName(), value, ClassUtils
.primitiveToWrapper(propertyClass)));
} else {
entries.add(new OpenEngSBModelEntry(propertyDescriptor.getName(), value, propertyClass));
}
}
for (Map.Entry<String, EDBObjectEntry> objectEntry : object.entrySet()) {
EDBObjectEntry entry = objectEntry.getValue();
Class<?> entryType;
try {
entryType = model.getClassLoader().loadClass(entry.getType());
entries.add(new OpenEngSBModelEntry(entry.getKey(), entry.getValue(), entryType));
} catch (ClassNotFoundException e) {
LOGGER.error("Unable to load class {} of the model tail", entry.getType());
}
}
return ModelUtils.createModel(model, entries);
} | [
"private",
"Object",
"convertEDBObjectToUncheckedModel",
"(",
"Class",
"<",
"?",
">",
"model",
",",
"EDBObject",
"object",
")",
"{",
"if",
"(",
"!",
"checkEDBObjectModelType",
"(",
"object",
",",
"model",
")",
")",
"{",
"return",
"null",
";",
"}",
"filterEngineeringObjectInformation",
"(",
"object",
",",
"model",
")",
";",
"List",
"<",
"OpenEngSBModelEntry",
">",
"entries",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"PropertyDescriptor",
"propertyDescriptor",
":",
"getPropertyDescriptorsForClass",
"(",
"model",
")",
")",
"{",
"if",
"(",
"propertyDescriptor",
".",
"getWriteMethod",
"(",
")",
"==",
"null",
"||",
"propertyDescriptor",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"ModelUtils",
".",
"MODEL_TAIL_FIELD_NAME",
")",
")",
"{",
"continue",
";",
"}",
"Object",
"value",
"=",
"getValueForProperty",
"(",
"propertyDescriptor",
",",
"object",
")",
";",
"Class",
"<",
"?",
">",
"propertyClass",
"=",
"propertyDescriptor",
".",
"getPropertyType",
"(",
")",
";",
"if",
"(",
"propertyClass",
".",
"isPrimitive",
"(",
")",
")",
"{",
"entries",
".",
"add",
"(",
"new",
"OpenEngSBModelEntry",
"(",
"propertyDescriptor",
".",
"getName",
"(",
")",
",",
"value",
",",
"ClassUtils",
".",
"primitiveToWrapper",
"(",
"propertyClass",
")",
")",
")",
";",
"}",
"else",
"{",
"entries",
".",
"add",
"(",
"new",
"OpenEngSBModelEntry",
"(",
"propertyDescriptor",
".",
"getName",
"(",
")",
",",
"value",
",",
"propertyClass",
")",
")",
";",
"}",
"}",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"EDBObjectEntry",
">",
"objectEntry",
":",
"object",
".",
"entrySet",
"(",
")",
")",
"{",
"EDBObjectEntry",
"entry",
"=",
"objectEntry",
".",
"getValue",
"(",
")",
";",
"Class",
"<",
"?",
">",
"entryType",
";",
"try",
"{",
"entryType",
"=",
"model",
".",
"getClassLoader",
"(",
")",
".",
"loadClass",
"(",
"entry",
".",
"getType",
"(",
")",
")",
";",
"entries",
".",
"add",
"(",
"new",
"OpenEngSBModelEntry",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
",",
"entryType",
")",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Unable to load class {} of the model tail\"",
",",
"entry",
".",
"getType",
"(",
")",
")",
";",
"}",
"}",
"return",
"ModelUtils",
".",
"createModel",
"(",
"model",
",",
"entries",
")",
";",
"}"
] | Converts an EDBObject to a model by analyzing the object and trying to call the corresponding setters of the
model. | [
"Converts",
"an",
"EDBObject",
"to",
"a",
"model",
"by",
"analyzing",
"the",
"object",
"and",
"trying",
"to",
"call",
"the",
"corresponding",
"setters",
"of",
"the",
"model",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java#L116-L148 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java | EDBConverter.getPropertyDescriptorsForClass | private List<PropertyDescriptor> getPropertyDescriptorsForClass(Class<?> clasz) {
try {
BeanInfo beanInfo = Introspector.getBeanInfo(clasz);
return Arrays.asList(beanInfo.getPropertyDescriptors());
} catch (IntrospectionException e) {
LOGGER.error("instantiation exception while trying to create instance of class {}", clasz.getName());
}
return Lists.newArrayList();
} | java | private List<PropertyDescriptor> getPropertyDescriptorsForClass(Class<?> clasz) {
try {
BeanInfo beanInfo = Introspector.getBeanInfo(clasz);
return Arrays.asList(beanInfo.getPropertyDescriptors());
} catch (IntrospectionException e) {
LOGGER.error("instantiation exception while trying to create instance of class {}", clasz.getName());
}
return Lists.newArrayList();
} | [
"private",
"List",
"<",
"PropertyDescriptor",
">",
"getPropertyDescriptorsForClass",
"(",
"Class",
"<",
"?",
">",
"clasz",
")",
"{",
"try",
"{",
"BeanInfo",
"beanInfo",
"=",
"Introspector",
".",
"getBeanInfo",
"(",
"clasz",
")",
";",
"return",
"Arrays",
".",
"asList",
"(",
"beanInfo",
".",
"getPropertyDescriptors",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IntrospectionException",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"instantiation exception while trying to create instance of class {}\"",
",",
"clasz",
".",
"getName",
"(",
")",
")",
";",
"}",
"return",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"}"
] | Returns all property descriptors for a given class. | [
"Returns",
"all",
"property",
"descriptors",
"for",
"a",
"given",
"class",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java#L153-L161 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java | EDBConverter.getValueForProperty | private Object getValueForProperty(PropertyDescriptor propertyDescriptor, EDBObject object) {
Method setterMethod = propertyDescriptor.getWriteMethod();
String propertyName = propertyDescriptor.getName();
Object value = object.getObject(propertyName);
Class<?> parameterType = setterMethod.getParameterTypes()[0];
// TODO: OPENENGSB-2719 do that in a better way than just an if-else series
if (Map.class.isAssignableFrom(parameterType)) {
List<Class<?>> classes = getGenericMapParameterClasses(setterMethod);
value = getMapValue(classes.get(0), classes.get(1), propertyName, object);
} else if (List.class.isAssignableFrom(parameterType)) {
Class<?> clazz = getGenericListParameterClass(setterMethod);
value = getListValue(clazz, propertyName, object);
} else if (parameterType.isArray()) {
Class<?> clazz = parameterType.getComponentType();
value = getArrayValue(clazz, propertyName, object);
} else if (value == null) {
return null;
} else if (OpenEngSBModel.class.isAssignableFrom(parameterType)) {
Object timestamp = object.getObject(EDBConstants.MODEL_TIMESTAMP);
Long time = System.currentTimeMillis();
if (timestamp != null) {
try {
time = Long.parseLong(timestamp.toString());
} catch (NumberFormatException e) {
LOGGER.warn("The model with the oid {} has an invalid timestamp.", object.getOID());
}
}
EDBObject obj = edbService.getObject((String) value, time);
value = convertEDBObjectToUncheckedModel(parameterType, obj);
object.remove(propertyName);
} else if (parameterType.equals(FileWrapper.class)) {
FileWrapper wrapper = new FileWrapper();
String filename = object.getString(propertyName + FILEWRAPPER_FILENAME_SUFFIX);
String content = (String) value;
wrapper.setFilename(filename);
wrapper.setContent(Base64.decodeBase64(content));
value = wrapper;
object.remove(propertyName + FILEWRAPPER_FILENAME_SUFFIX);
} else if (parameterType.equals(File.class)) {
return null;
} else if (object.containsKey(propertyName)) {
if (parameterType.isEnum()) {
value = getEnumValue(parameterType, value);
}
}
object.remove(propertyName);
return value;
} | java | private Object getValueForProperty(PropertyDescriptor propertyDescriptor, EDBObject object) {
Method setterMethod = propertyDescriptor.getWriteMethod();
String propertyName = propertyDescriptor.getName();
Object value = object.getObject(propertyName);
Class<?> parameterType = setterMethod.getParameterTypes()[0];
// TODO: OPENENGSB-2719 do that in a better way than just an if-else series
if (Map.class.isAssignableFrom(parameterType)) {
List<Class<?>> classes = getGenericMapParameterClasses(setterMethod);
value = getMapValue(classes.get(0), classes.get(1), propertyName, object);
} else if (List.class.isAssignableFrom(parameterType)) {
Class<?> clazz = getGenericListParameterClass(setterMethod);
value = getListValue(clazz, propertyName, object);
} else if (parameterType.isArray()) {
Class<?> clazz = parameterType.getComponentType();
value = getArrayValue(clazz, propertyName, object);
} else if (value == null) {
return null;
} else if (OpenEngSBModel.class.isAssignableFrom(parameterType)) {
Object timestamp = object.getObject(EDBConstants.MODEL_TIMESTAMP);
Long time = System.currentTimeMillis();
if (timestamp != null) {
try {
time = Long.parseLong(timestamp.toString());
} catch (NumberFormatException e) {
LOGGER.warn("The model with the oid {} has an invalid timestamp.", object.getOID());
}
}
EDBObject obj = edbService.getObject((String) value, time);
value = convertEDBObjectToUncheckedModel(parameterType, obj);
object.remove(propertyName);
} else if (parameterType.equals(FileWrapper.class)) {
FileWrapper wrapper = new FileWrapper();
String filename = object.getString(propertyName + FILEWRAPPER_FILENAME_SUFFIX);
String content = (String) value;
wrapper.setFilename(filename);
wrapper.setContent(Base64.decodeBase64(content));
value = wrapper;
object.remove(propertyName + FILEWRAPPER_FILENAME_SUFFIX);
} else if (parameterType.equals(File.class)) {
return null;
} else if (object.containsKey(propertyName)) {
if (parameterType.isEnum()) {
value = getEnumValue(parameterType, value);
}
}
object.remove(propertyName);
return value;
} | [
"private",
"Object",
"getValueForProperty",
"(",
"PropertyDescriptor",
"propertyDescriptor",
",",
"EDBObject",
"object",
")",
"{",
"Method",
"setterMethod",
"=",
"propertyDescriptor",
".",
"getWriteMethod",
"(",
")",
";",
"String",
"propertyName",
"=",
"propertyDescriptor",
".",
"getName",
"(",
")",
";",
"Object",
"value",
"=",
"object",
".",
"getObject",
"(",
"propertyName",
")",
";",
"Class",
"<",
"?",
">",
"parameterType",
"=",
"setterMethod",
".",
"getParameterTypes",
"(",
")",
"[",
"0",
"]",
";",
"// TODO: OPENENGSB-2719 do that in a better way than just an if-else series",
"if",
"(",
"Map",
".",
"class",
".",
"isAssignableFrom",
"(",
"parameterType",
")",
")",
"{",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"classes",
"=",
"getGenericMapParameterClasses",
"(",
"setterMethod",
")",
";",
"value",
"=",
"getMapValue",
"(",
"classes",
".",
"get",
"(",
"0",
")",
",",
"classes",
".",
"get",
"(",
"1",
")",
",",
"propertyName",
",",
"object",
")",
";",
"}",
"else",
"if",
"(",
"List",
".",
"class",
".",
"isAssignableFrom",
"(",
"parameterType",
")",
")",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"getGenericListParameterClass",
"(",
"setterMethod",
")",
";",
"value",
"=",
"getListValue",
"(",
"clazz",
",",
"propertyName",
",",
"object",
")",
";",
"}",
"else",
"if",
"(",
"parameterType",
".",
"isArray",
"(",
")",
")",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"parameterType",
".",
"getComponentType",
"(",
")",
";",
"value",
"=",
"getArrayValue",
"(",
"clazz",
",",
"propertyName",
",",
"object",
")",
";",
"}",
"else",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"OpenEngSBModel",
".",
"class",
".",
"isAssignableFrom",
"(",
"parameterType",
")",
")",
"{",
"Object",
"timestamp",
"=",
"object",
".",
"getObject",
"(",
"EDBConstants",
".",
"MODEL_TIMESTAMP",
")",
";",
"Long",
"time",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"if",
"(",
"timestamp",
"!=",
"null",
")",
"{",
"try",
"{",
"time",
"=",
"Long",
".",
"parseLong",
"(",
"timestamp",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"The model with the oid {} has an invalid timestamp.\"",
",",
"object",
".",
"getOID",
"(",
")",
")",
";",
"}",
"}",
"EDBObject",
"obj",
"=",
"edbService",
".",
"getObject",
"(",
"(",
"String",
")",
"value",
",",
"time",
")",
";",
"value",
"=",
"convertEDBObjectToUncheckedModel",
"(",
"parameterType",
",",
"obj",
")",
";",
"object",
".",
"remove",
"(",
"propertyName",
")",
";",
"}",
"else",
"if",
"(",
"parameterType",
".",
"equals",
"(",
"FileWrapper",
".",
"class",
")",
")",
"{",
"FileWrapper",
"wrapper",
"=",
"new",
"FileWrapper",
"(",
")",
";",
"String",
"filename",
"=",
"object",
".",
"getString",
"(",
"propertyName",
"+",
"FILEWRAPPER_FILENAME_SUFFIX",
")",
";",
"String",
"content",
"=",
"(",
"String",
")",
"value",
";",
"wrapper",
".",
"setFilename",
"(",
"filename",
")",
";",
"wrapper",
".",
"setContent",
"(",
"Base64",
".",
"decodeBase64",
"(",
"content",
")",
")",
";",
"value",
"=",
"wrapper",
";",
"object",
".",
"remove",
"(",
"propertyName",
"+",
"FILEWRAPPER_FILENAME_SUFFIX",
")",
";",
"}",
"else",
"if",
"(",
"parameterType",
".",
"equals",
"(",
"File",
".",
"class",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"object",
".",
"containsKey",
"(",
"propertyName",
")",
")",
"{",
"if",
"(",
"parameterType",
".",
"isEnum",
"(",
")",
")",
"{",
"value",
"=",
"getEnumValue",
"(",
"parameterType",
",",
"value",
")",
";",
"}",
"}",
"object",
".",
"remove",
"(",
"propertyName",
")",
";",
"return",
"value",
";",
"}"
] | Generate the value for a specific property of a model out of an EDBObject. | [
"Generate",
"the",
"value",
"for",
"a",
"specific",
"property",
"of",
"a",
"model",
"out",
"of",
"an",
"EDBObject",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java#L166-L214 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java | EDBConverter.getListValue | @SuppressWarnings("unchecked")
private <T> List<T> getListValue(Class<T> type, String propertyName, EDBObject object) {
List<T> temp = new ArrayList<>();
for (int i = 0;; i++) {
String property = getEntryNameForList(propertyName, i);
Object obj = object.getObject(property);
if (obj == null) {
break;
}
if (OpenEngSBModel.class.isAssignableFrom(type)) {
obj = convertEDBObjectToUncheckedModel(type, edbService.getObject(object.getString(property)));
}
temp.add((T) obj);
object.remove(property);
}
return temp;
} | java | @SuppressWarnings("unchecked")
private <T> List<T> getListValue(Class<T> type, String propertyName, EDBObject object) {
List<T> temp = new ArrayList<>();
for (int i = 0;; i++) {
String property = getEntryNameForList(propertyName, i);
Object obj = object.getObject(property);
if (obj == null) {
break;
}
if (OpenEngSBModel.class.isAssignableFrom(type)) {
obj = convertEDBObjectToUncheckedModel(type, edbService.getObject(object.getString(property)));
}
temp.add((T) obj);
object.remove(property);
}
return temp;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"<",
"T",
">",
"List",
"<",
"T",
">",
"getListValue",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"String",
"propertyName",
",",
"EDBObject",
"object",
")",
"{",
"List",
"<",
"T",
">",
"temp",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
";",
"i",
"++",
")",
"{",
"String",
"property",
"=",
"getEntryNameForList",
"(",
"propertyName",
",",
"i",
")",
";",
"Object",
"obj",
"=",
"object",
".",
"getObject",
"(",
"property",
")",
";",
"if",
"(",
"obj",
"==",
"null",
")",
"{",
"break",
";",
"}",
"if",
"(",
"OpenEngSBModel",
".",
"class",
".",
"isAssignableFrom",
"(",
"type",
")",
")",
"{",
"obj",
"=",
"convertEDBObjectToUncheckedModel",
"(",
"type",
",",
"edbService",
".",
"getObject",
"(",
"object",
".",
"getString",
"(",
"property",
")",
")",
")",
";",
"}",
"temp",
".",
"add",
"(",
"(",
"T",
")",
"obj",
")",
";",
"object",
".",
"remove",
"(",
"property",
")",
";",
"}",
"return",
"temp",
";",
"}"
] | Gets a list object out of an EDBObject. | [
"Gets",
"a",
"list",
"object",
"out",
"of",
"an",
"EDBObject",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java#L246-L262 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java | EDBConverter.getArrayValue | @SuppressWarnings("unchecked")
private <T> T[] getArrayValue(Class<T> type, String propertyName, EDBObject object) {
List<T> elements = getListValue(type, propertyName, object);
T[] ar = (T[]) Array.newInstance(type, elements.size());
return elements.toArray(ar);
} | java | @SuppressWarnings("unchecked")
private <T> T[] getArrayValue(Class<T> type, String propertyName, EDBObject object) {
List<T> elements = getListValue(type, propertyName, object);
T[] ar = (T[]) Array.newInstance(type, elements.size());
return elements.toArray(ar);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"<",
"T",
">",
"T",
"[",
"]",
"getArrayValue",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"String",
"propertyName",
",",
"EDBObject",
"object",
")",
"{",
"List",
"<",
"T",
">",
"elements",
"=",
"getListValue",
"(",
"type",
",",
"propertyName",
",",
"object",
")",
";",
"T",
"[",
"]",
"ar",
"=",
"(",
"T",
"[",
"]",
")",
"Array",
".",
"newInstance",
"(",
"type",
",",
"elements",
".",
"size",
"(",
")",
")",
";",
"return",
"elements",
".",
"toArray",
"(",
"ar",
")",
";",
"}"
] | Gets an array object out of an EDBObject. | [
"Gets",
"an",
"array",
"object",
"out",
"of",
"an",
"EDBObject",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java#L267-L272 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java | EDBConverter.getMapValue | private Object getMapValue(Class<?> keyType, Class<?> valueType, String propertyName, EDBObject object) {
Map<Object, Object> temp = new HashMap<>();
for (int i = 0;; i++) {
String keyProperty = getEntryNameForMapKey(propertyName, i);
String valueProperty = getEntryNameForMapValue(propertyName, i);
if (!object.containsKey(keyProperty)) {
break;
}
Object key = object.getObject(keyProperty);
Object value = object.getObject(valueProperty);
if (OpenEngSBModel.class.isAssignableFrom(keyType)) {
key = convertEDBObjectToUncheckedModel(keyType, edbService.getObject(key.toString()));
}
if (OpenEngSBModel.class.isAssignableFrom(valueType)) {
value = convertEDBObjectToUncheckedModel(valueType, edbService.getObject(value.toString()));
}
temp.put(key, value);
object.remove(keyProperty);
object.remove(valueProperty);
}
return temp;
} | java | private Object getMapValue(Class<?> keyType, Class<?> valueType, String propertyName, EDBObject object) {
Map<Object, Object> temp = new HashMap<>();
for (int i = 0;; i++) {
String keyProperty = getEntryNameForMapKey(propertyName, i);
String valueProperty = getEntryNameForMapValue(propertyName, i);
if (!object.containsKey(keyProperty)) {
break;
}
Object key = object.getObject(keyProperty);
Object value = object.getObject(valueProperty);
if (OpenEngSBModel.class.isAssignableFrom(keyType)) {
key = convertEDBObjectToUncheckedModel(keyType, edbService.getObject(key.toString()));
}
if (OpenEngSBModel.class.isAssignableFrom(valueType)) {
value = convertEDBObjectToUncheckedModel(valueType, edbService.getObject(value.toString()));
}
temp.put(key, value);
object.remove(keyProperty);
object.remove(valueProperty);
}
return temp;
} | [
"private",
"Object",
"getMapValue",
"(",
"Class",
"<",
"?",
">",
"keyType",
",",
"Class",
"<",
"?",
">",
"valueType",
",",
"String",
"propertyName",
",",
"EDBObject",
"object",
")",
"{",
"Map",
"<",
"Object",
",",
"Object",
">",
"temp",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
";",
"i",
"++",
")",
"{",
"String",
"keyProperty",
"=",
"getEntryNameForMapKey",
"(",
"propertyName",
",",
"i",
")",
";",
"String",
"valueProperty",
"=",
"getEntryNameForMapValue",
"(",
"propertyName",
",",
"i",
")",
";",
"if",
"(",
"!",
"object",
".",
"containsKey",
"(",
"keyProperty",
")",
")",
"{",
"break",
";",
"}",
"Object",
"key",
"=",
"object",
".",
"getObject",
"(",
"keyProperty",
")",
";",
"Object",
"value",
"=",
"object",
".",
"getObject",
"(",
"valueProperty",
")",
";",
"if",
"(",
"OpenEngSBModel",
".",
"class",
".",
"isAssignableFrom",
"(",
"keyType",
")",
")",
"{",
"key",
"=",
"convertEDBObjectToUncheckedModel",
"(",
"keyType",
",",
"edbService",
".",
"getObject",
"(",
"key",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"OpenEngSBModel",
".",
"class",
".",
"isAssignableFrom",
"(",
"valueType",
")",
")",
"{",
"value",
"=",
"convertEDBObjectToUncheckedModel",
"(",
"valueType",
",",
"edbService",
".",
"getObject",
"(",
"value",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"temp",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"object",
".",
"remove",
"(",
"keyProperty",
")",
";",
"object",
".",
"remove",
"(",
"valueProperty",
")",
";",
"}",
"return",
"temp",
";",
"}"
] | Gets a map object out of an EDBObject. | [
"Gets",
"a",
"map",
"object",
"out",
"of",
"an",
"EDBObject",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java#L277-L298 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java | EDBConverter.getEnumValue | private Object getEnumValue(Class<?> type, Object value) {
Object[] enumValues = type.getEnumConstants();
for (Object enumValue : enumValues) {
if (enumValue.toString().equals(value.toString())) {
value = enumValue;
break;
}
}
return value;
} | java | private Object getEnumValue(Class<?> type, Object value) {
Object[] enumValues = type.getEnumConstants();
for (Object enumValue : enumValues) {
if (enumValue.toString().equals(value.toString())) {
value = enumValue;
break;
}
}
return value;
} | [
"private",
"Object",
"getEnumValue",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"Object",
"value",
")",
"{",
"Object",
"[",
"]",
"enumValues",
"=",
"type",
".",
"getEnumConstants",
"(",
")",
";",
"for",
"(",
"Object",
"enumValue",
":",
"enumValues",
")",
"{",
"if",
"(",
"enumValue",
".",
"toString",
"(",
")",
".",
"equals",
"(",
"value",
".",
"toString",
"(",
")",
")",
")",
"{",
"value",
"=",
"enumValue",
";",
"break",
";",
"}",
"}",
"return",
"value",
";",
"}"
] | Gets an enum value out of an object. | [
"Gets",
"an",
"enum",
"value",
"out",
"of",
"an",
"object",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java#L303-L312 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java | EDBConverter.convertEKBCommit | public ConvertedCommit convertEKBCommit(EKBCommit commit) {
ConvertedCommit result = new ConvertedCommit();
ConnectorInformation information = commit.getConnectorInformation();
result.setInserts(convertModelsToEDBObjects(commit.getInserts(), information));
result.setUpdates(convertModelsToEDBObjects(commit.getUpdates(), information));
result.setDeletes(convertModelsToEDBObjects(commit.getDeletes(), information));
return result;
} | java | public ConvertedCommit convertEKBCommit(EKBCommit commit) {
ConvertedCommit result = new ConvertedCommit();
ConnectorInformation information = commit.getConnectorInformation();
result.setInserts(convertModelsToEDBObjects(commit.getInserts(), information));
result.setUpdates(convertModelsToEDBObjects(commit.getUpdates(), information));
result.setDeletes(convertModelsToEDBObjects(commit.getDeletes(), information));
return result;
} | [
"public",
"ConvertedCommit",
"convertEKBCommit",
"(",
"EKBCommit",
"commit",
")",
"{",
"ConvertedCommit",
"result",
"=",
"new",
"ConvertedCommit",
"(",
")",
";",
"ConnectorInformation",
"information",
"=",
"commit",
".",
"getConnectorInformation",
"(",
")",
";",
"result",
".",
"setInserts",
"(",
"convertModelsToEDBObjects",
"(",
"commit",
".",
"getInserts",
"(",
")",
",",
"information",
")",
")",
";",
"result",
".",
"setUpdates",
"(",
"convertModelsToEDBObjects",
"(",
"commit",
".",
"getUpdates",
"(",
")",
",",
"information",
")",
")",
";",
"result",
".",
"setDeletes",
"(",
"convertModelsToEDBObjects",
"(",
"commit",
".",
"getDeletes",
"(",
")",
",",
"information",
")",
")",
";",
"return",
"result",
";",
"}"
] | Converts the models of an EKBCommit to EDBObjects and return an object which contains the three corresponding
lists | [
"Converts",
"the",
"models",
"of",
"an",
"EKBCommit",
"to",
"EDBObjects",
"and",
"return",
"an",
"object",
"which",
"contains",
"the",
"three",
"corresponding",
"lists"
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java#L318-L325 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java | EDBConverter.fillEDBObjectWithEngineeringObjectInformation | private void fillEDBObjectWithEngineeringObjectInformation(EDBObject object, OpenEngSBModel model)
throws IllegalAccessException {
if (!new AdvancedModelWrapper(model).isEngineeringObject()) {
return;
}
for (Field field : model.getClass().getDeclaredFields()) {
OpenEngSBForeignKey annotation = field.getAnnotation(OpenEngSBForeignKey.class);
if (annotation == null) {
continue;
}
String value = (String) FieldUtils.readField(field, model, true);
if (value == null) {
continue;
}
value = String.format("%s/%s", ContextHolder.get().getCurrentContextId(), value);
String key = getEOReferenceStringFromAnnotation(annotation);
object.put(key, new EDBObjectEntry(key, value, String.class));
}
} | java | private void fillEDBObjectWithEngineeringObjectInformation(EDBObject object, OpenEngSBModel model)
throws IllegalAccessException {
if (!new AdvancedModelWrapper(model).isEngineeringObject()) {
return;
}
for (Field field : model.getClass().getDeclaredFields()) {
OpenEngSBForeignKey annotation = field.getAnnotation(OpenEngSBForeignKey.class);
if (annotation == null) {
continue;
}
String value = (String) FieldUtils.readField(field, model, true);
if (value == null) {
continue;
}
value = String.format("%s/%s", ContextHolder.get().getCurrentContextId(), value);
String key = getEOReferenceStringFromAnnotation(annotation);
object.put(key, new EDBObjectEntry(key, value, String.class));
}
} | [
"private",
"void",
"fillEDBObjectWithEngineeringObjectInformation",
"(",
"EDBObject",
"object",
",",
"OpenEngSBModel",
"model",
")",
"throws",
"IllegalAccessException",
"{",
"if",
"(",
"!",
"new",
"AdvancedModelWrapper",
"(",
"model",
")",
".",
"isEngineeringObject",
"(",
")",
")",
"{",
"return",
";",
"}",
"for",
"(",
"Field",
"field",
":",
"model",
".",
"getClass",
"(",
")",
".",
"getDeclaredFields",
"(",
")",
")",
"{",
"OpenEngSBForeignKey",
"annotation",
"=",
"field",
".",
"getAnnotation",
"(",
"OpenEngSBForeignKey",
".",
"class",
")",
";",
"if",
"(",
"annotation",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"String",
"value",
"=",
"(",
"String",
")",
"FieldUtils",
".",
"readField",
"(",
"field",
",",
"model",
",",
"true",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"value",
"=",
"String",
".",
"format",
"(",
"\"%s/%s\"",
",",
"ContextHolder",
".",
"get",
"(",
")",
".",
"getCurrentContextId",
"(",
")",
",",
"value",
")",
";",
"String",
"key",
"=",
"getEOReferenceStringFromAnnotation",
"(",
"annotation",
")",
";",
"object",
".",
"put",
"(",
"key",
",",
"new",
"EDBObjectEntry",
"(",
"key",
",",
"value",
",",
"String",
".",
"class",
")",
")",
";",
"}",
"}"
] | Adds to the EDBObject special entries which mark that a model is referring to other models through
OpenEngSBForeignKey annotations | [
"Adds",
"to",
"the",
"EDBObject",
"special",
"entries",
"which",
"mark",
"that",
"a",
"model",
"is",
"referring",
"to",
"other",
"models",
"through",
"OpenEngSBForeignKey",
"annotations"
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java#L465-L483 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java | EDBConverter.filterEngineeringObjectInformation | private void filterEngineeringObjectInformation(EDBObject object, Class<?> model) {
if (!AdvancedModelWrapper.isEngineeringObjectClass(model)) {
return;
}
Iterator<String> keys = object.keySet().iterator();
while (keys.hasNext()) {
if (keys.next().startsWith(REFERENCE_PREFIX)) {
keys.remove();
}
}
} | java | private void filterEngineeringObjectInformation(EDBObject object, Class<?> model) {
if (!AdvancedModelWrapper.isEngineeringObjectClass(model)) {
return;
}
Iterator<String> keys = object.keySet().iterator();
while (keys.hasNext()) {
if (keys.next().startsWith(REFERENCE_PREFIX)) {
keys.remove();
}
}
} | [
"private",
"void",
"filterEngineeringObjectInformation",
"(",
"EDBObject",
"object",
",",
"Class",
"<",
"?",
">",
"model",
")",
"{",
"if",
"(",
"!",
"AdvancedModelWrapper",
".",
"isEngineeringObjectClass",
"(",
"model",
")",
")",
"{",
"return",
";",
"}",
"Iterator",
"<",
"String",
">",
"keys",
"=",
"object",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"keys",
".",
"hasNext",
"(",
")",
")",
"{",
"if",
"(",
"keys",
".",
"next",
"(",
")",
".",
"startsWith",
"(",
"REFERENCE_PREFIX",
")",
")",
"{",
"keys",
".",
"remove",
"(",
")",
";",
"}",
"}",
"}"
] | Filters the reference prefix values added in the model to EDBObject conversion out of the EDBObject | [
"Filters",
"the",
"reference",
"prefix",
"values",
"added",
"in",
"the",
"model",
"to",
"EDBObject",
"conversion",
"out",
"of",
"the",
"EDBObject"
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java#L488-L498 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java | EDBConverter.getEntryNameForMapKey | public static String getEntryNameForMapKey(String property, Integer index) {
return getEntryNameForMap(property, true, index);
} | java | public static String getEntryNameForMapKey(String property, Integer index) {
return getEntryNameForMap(property, true, index);
} | [
"public",
"static",
"String",
"getEntryNameForMapKey",
"(",
"String",
"property",
",",
"Integer",
"index",
")",
"{",
"return",
"getEntryNameForMap",
"(",
"property",
",",
"true",
",",
"index",
")",
";",
"}"
] | Returns the entry name for a map key in the EDB format. E.g. the map key for the property "map" with the index 0
would be "map.0.key". | [
"Returns",
"the",
"entry",
"name",
"for",
"a",
"map",
"key",
"in",
"the",
"EDB",
"format",
".",
"E",
".",
"g",
".",
"the",
"map",
"key",
"for",
"the",
"property",
"map",
"with",
"the",
"index",
"0",
"would",
"be",
"map",
".",
"0",
".",
"key",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java#L504-L506 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java | EDBConverter.getEntryNameForMapValue | public static String getEntryNameForMapValue(String property, Integer index) {
return getEntryNameForMap(property, false, index);
} | java | public static String getEntryNameForMapValue(String property, Integer index) {
return getEntryNameForMap(property, false, index);
} | [
"public",
"static",
"String",
"getEntryNameForMapValue",
"(",
"String",
"property",
",",
"Integer",
"index",
")",
"{",
"return",
"getEntryNameForMap",
"(",
"property",
",",
"false",
",",
"index",
")",
";",
"}"
] | Returns the entry name for a map value in the EDB format. E.g. the map value for the property "map" with the
index 0 would be "map.0.value". | [
"Returns",
"the",
"entry",
"name",
"for",
"a",
"map",
"value",
"in",
"the",
"EDB",
"format",
".",
"E",
".",
"g",
".",
"the",
"map",
"value",
"for",
"the",
"property",
"map",
"with",
"the",
"index",
"0",
"would",
"be",
"map",
".",
"0",
".",
"value",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java#L512-L514 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java | EDBConverter.getEntryNameForMap | private static String getEntryNameForMap(String property, Boolean key, Integer index) {
return String.format("%s.%d.%s", property, index, key ? "key" : "value");
} | java | private static String getEntryNameForMap(String property, Boolean key, Integer index) {
return String.format("%s.%d.%s", property, index, key ? "key" : "value");
} | [
"private",
"static",
"String",
"getEntryNameForMap",
"(",
"String",
"property",
",",
"Boolean",
"key",
",",
"Integer",
"index",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"%s.%d.%s\"",
",",
"property",
",",
"index",
",",
"key",
"?",
"\"key\"",
":",
"\"value\"",
")",
";",
"}"
] | Returns the entry name for a map element in the EDB format. The key parameter defines if the entry name should be
generated for the key or the value of the map. E.g. the map key for the property "map" with the index 0 would be
"map.0.key". | [
"Returns",
"the",
"entry",
"name",
"for",
"a",
"map",
"element",
"in",
"the",
"EDB",
"format",
".",
"The",
"key",
"parameter",
"defines",
"if",
"the",
"entry",
"name",
"should",
"be",
"generated",
"for",
"the",
"key",
"or",
"the",
"value",
"of",
"the",
"map",
".",
"E",
".",
"g",
".",
"the",
"map",
"key",
"for",
"the",
"property",
"map",
"with",
"the",
"index",
"0",
"would",
"be",
"map",
".",
"0",
".",
"key",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java#L521-L523 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java | EDBConverter.getEntryNameForList | public static String getEntryNameForList(String property, Integer index) {
return String.format("%s.%d", property, index);
} | java | public static String getEntryNameForList(String property, Integer index) {
return String.format("%s.%d", property, index);
} | [
"public",
"static",
"String",
"getEntryNameForList",
"(",
"String",
"property",
",",
"Integer",
"index",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"%s.%d\"",
",",
"property",
",",
"index",
")",
";",
"}"
] | Returns the entry name for a list element in the EDB format. E.g. the list element for the property "list" with
the index 0 would be "list.0". | [
"Returns",
"the",
"entry",
"name",
"for",
"a",
"list",
"element",
"in",
"the",
"EDB",
"format",
".",
"E",
".",
"g",
".",
"the",
"list",
"element",
"for",
"the",
"property",
"list",
"with",
"the",
"index",
"0",
"would",
"be",
"list",
".",
"0",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java#L529-L531 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java | EDBConverter.getEOReferenceStringFromAnnotation | public static String getEOReferenceStringFromAnnotation(OpenEngSBForeignKey key) {
return String.format("%s%s:%s", REFERENCE_PREFIX, key.modelType(), key.modelVersion().toString());
} | java | public static String getEOReferenceStringFromAnnotation(OpenEngSBForeignKey key) {
return String.format("%s%s:%s", REFERENCE_PREFIX, key.modelType(), key.modelVersion().toString());
} | [
"public",
"static",
"String",
"getEOReferenceStringFromAnnotation",
"(",
"OpenEngSBForeignKey",
"key",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"%s%s:%s\"",
",",
"REFERENCE_PREFIX",
",",
"key",
".",
"modelType",
"(",
")",
",",
"key",
".",
"modelVersion",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}"
] | Converts an OpenEngSBForeignKey annotation to the fitting format which will be added to an EDBObject. | [
"Converts",
"an",
"OpenEngSBForeignKey",
"annotation",
"to",
"the",
"fitting",
"format",
"which",
"will",
"be",
"added",
"to",
"an",
"EDBObject",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java#L536-L538 | train |
openengsb/openengsb | components/services/src/main/java/org/openengsb/core/services/xlink/XLinkUtils.java | XLinkUtils.assigneModelsToViews | private static Map<String, ModelDescription> assigneModelsToViews(Map<ModelDescription,
XLinkConnectorView[]> modelsToViews) {
HashMap<String, ModelDescription> viewsToModels = new HashMap<String, ModelDescription>();
for (ModelDescription modelInfo : modelsToViews.keySet()) {
List<XLinkConnectorView> currentViewList = Arrays.asList(modelsToViews.get(modelInfo));
for (XLinkConnectorView view : currentViewList) {
if (!viewsToModels.containsKey(view.getViewId())) {
viewsToModels.put(view.getViewId(), modelInfo);
}
}
}
return viewsToModels;
} | java | private static Map<String, ModelDescription> assigneModelsToViews(Map<ModelDescription,
XLinkConnectorView[]> modelsToViews) {
HashMap<String, ModelDescription> viewsToModels = new HashMap<String, ModelDescription>();
for (ModelDescription modelInfo : modelsToViews.keySet()) {
List<XLinkConnectorView> currentViewList = Arrays.asList(modelsToViews.get(modelInfo));
for (XLinkConnectorView view : currentViewList) {
if (!viewsToModels.containsKey(view.getViewId())) {
viewsToModels.put(view.getViewId(), modelInfo);
}
}
}
return viewsToModels;
} | [
"private",
"static",
"Map",
"<",
"String",
",",
"ModelDescription",
">",
"assigneModelsToViews",
"(",
"Map",
"<",
"ModelDescription",
",",
"XLinkConnectorView",
"[",
"]",
">",
"modelsToViews",
")",
"{",
"HashMap",
"<",
"String",
",",
"ModelDescription",
">",
"viewsToModels",
"=",
"new",
"HashMap",
"<",
"String",
",",
"ModelDescription",
">",
"(",
")",
";",
"for",
"(",
"ModelDescription",
"modelInfo",
":",
"modelsToViews",
".",
"keySet",
"(",
")",
")",
"{",
"List",
"<",
"XLinkConnectorView",
">",
"currentViewList",
"=",
"Arrays",
".",
"asList",
"(",
"modelsToViews",
".",
"get",
"(",
"modelInfo",
")",
")",
";",
"for",
"(",
"XLinkConnectorView",
"view",
":",
"currentViewList",
")",
"{",
"if",
"(",
"!",
"viewsToModels",
".",
"containsKey",
"(",
"view",
".",
"getViewId",
"(",
")",
")",
")",
"{",
"viewsToModels",
".",
"put",
"(",
"view",
".",
"getViewId",
"(",
")",
",",
"modelInfo",
")",
";",
"}",
"}",
"}",
"return",
"viewsToModels",
";",
"}"
] | Naive model to view assignment.
The current model is choosen for the first occurence of the view. | [
"Naive",
"model",
"to",
"view",
"assignment",
".",
"The",
"current",
"model",
"is",
"choosen",
"for",
"the",
"first",
"occurence",
"of",
"the",
"view",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/services/src/main/java/org/openengsb/core/services/xlink/XLinkUtils.java#L90-L102 | train |
openengsb/openengsb | components/services/src/main/java/org/openengsb/core/services/xlink/XLinkUtils.java | XLinkUtils.getExpirationDate | private static String getExpirationDate(int futureDays) {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_YEAR, futureDays);
Format formatter = new SimpleDateFormat(XLinkConstants.DATEFORMAT);
return formatter.format(calendar.getTime());
} | java | private static String getExpirationDate(int futureDays) {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_YEAR, futureDays);
Format formatter = new SimpleDateFormat(XLinkConstants.DATEFORMAT);
return formatter.format(calendar.getTime());
} | [
"private",
"static",
"String",
"getExpirationDate",
"(",
"int",
"futureDays",
")",
"{",
"Calendar",
"calendar",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"calendar",
".",
"add",
"(",
"Calendar",
".",
"DAY_OF_YEAR",
",",
"futureDays",
")",
";",
"Format",
"formatter",
"=",
"new",
"SimpleDateFormat",
"(",
"XLinkConstants",
".",
"DATEFORMAT",
")",
";",
"return",
"formatter",
".",
"format",
"(",
"calendar",
".",
"getTime",
"(",
")",
")",
";",
"}"
] | Returns a future Date-String in the format 'yyyyMMddkkmmss'. | [
"Returns",
"a",
"future",
"Date",
"-",
"String",
"in",
"the",
"format",
"yyyyMMddkkmmss",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/services/src/main/java/org/openengsb/core/services/xlink/XLinkUtils.java#L107-L112 | train |
openengsb/openengsb | components/services/src/main/java/org/openengsb/core/services/xlink/XLinkUtils.java | XLinkUtils.setValueOfModel | public static void setValueOfModel(Object model, OpenEngSBModelEntry entry, Object value) throws
NoSuchFieldException,
IllegalArgumentException,
IllegalAccessException {
Class clazz = model.getClass();
Field field = clazz.getDeclaredField(entry.getKey());
field.setAccessible(true);
field.set(model, value);
} | java | public static void setValueOfModel(Object model, OpenEngSBModelEntry entry, Object value) throws
NoSuchFieldException,
IllegalArgumentException,
IllegalAccessException {
Class clazz = model.getClass();
Field field = clazz.getDeclaredField(entry.getKey());
field.setAccessible(true);
field.set(model, value);
} | [
"public",
"static",
"void",
"setValueOfModel",
"(",
"Object",
"model",
",",
"OpenEngSBModelEntry",
"entry",
",",
"Object",
"value",
")",
"throws",
"NoSuchFieldException",
",",
"IllegalArgumentException",
",",
"IllegalAccessException",
"{",
"Class",
"clazz",
"=",
"model",
".",
"getClass",
"(",
")",
";",
"Field",
"field",
"=",
"clazz",
".",
"getDeclaredField",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"field",
".",
"setAccessible",
"(",
"true",
")",
";",
"field",
".",
"set",
"(",
"model",
",",
"value",
")",
";",
"}"
] | Sets the value, of the field defined in the OpenEngSBModelEntry, the the given model,
with reflection. | [
"Sets",
"the",
"value",
"of",
"the",
"field",
"defined",
"in",
"the",
"OpenEngSBModelEntry",
"the",
"the",
"given",
"model",
"with",
"reflection",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/services/src/main/java/org/openengsb/core/services/xlink/XLinkUtils.java#L120-L128 | train |
openengsb/openengsb | components/services/src/main/java/org/openengsb/core/services/xlink/XLinkUtils.java | XLinkUtils.createInstanceOfModelClass | public static Object createInstanceOfModelClass(Class clazzObject,
List<OpenEngSBModelEntry> entries) {
return ModelUtils.createModel(clazzObject, entries);
} | java | public static Object createInstanceOfModelClass(Class clazzObject,
List<OpenEngSBModelEntry> entries) {
return ModelUtils.createModel(clazzObject, entries);
} | [
"public",
"static",
"Object",
"createInstanceOfModelClass",
"(",
"Class",
"clazzObject",
",",
"List",
"<",
"OpenEngSBModelEntry",
">",
"entries",
")",
"{",
"return",
"ModelUtils",
".",
"createModel",
"(",
"clazzObject",
",",
"entries",
")",
";",
"}"
] | Returns an instance to a given Classobject and a List of OpenEngSBModelEntries.
Returns null, if an error happens during the instantiation. | [
"Returns",
"an",
"instance",
"to",
"a",
"given",
"Classobject",
"and",
"a",
"List",
"of",
"OpenEngSBModelEntries",
".",
"Returns",
"null",
"if",
"an",
"error",
"happens",
"during",
"the",
"instantiation",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/services/src/main/java/org/openengsb/core/services/xlink/XLinkUtils.java#L143-L146 | train |
openengsb/openengsb | components/services/src/main/java/org/openengsb/core/services/xlink/XLinkUtils.java | XLinkUtils.dateStringToCalendar | public static Calendar dateStringToCalendar(String dateString) {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat formatter = new SimpleDateFormat(XLinkConstants.DATEFORMAT);
try {
calendar.setTime(formatter.parse(dateString));
} catch (Exception ex) {
return null;
}
return calendar;
} | java | public static Calendar dateStringToCalendar(String dateString) {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat formatter = new SimpleDateFormat(XLinkConstants.DATEFORMAT);
try {
calendar.setTime(formatter.parse(dateString));
} catch (Exception ex) {
return null;
}
return calendar;
} | [
"public",
"static",
"Calendar",
"dateStringToCalendar",
"(",
"String",
"dateString",
")",
"{",
"Calendar",
"calendar",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"SimpleDateFormat",
"formatter",
"=",
"new",
"SimpleDateFormat",
"(",
"XLinkConstants",
".",
"DATEFORMAT",
")",
";",
"try",
"{",
"calendar",
".",
"setTime",
"(",
"formatter",
".",
"parse",
"(",
"dateString",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"return",
"null",
";",
"}",
"return",
"calendar",
";",
"}"
] | Returns a Calendarobject to a given dateString in the Format 'DATEFORMAT'.
If the given String is of the wrong format, null is returned.
@see XLinkUtils#DATEFORMAT | [
"Returns",
"a",
"Calendarobject",
"to",
"a",
"given",
"dateString",
"in",
"the",
"Format",
"DATEFORMAT",
".",
"If",
"the",
"given",
"String",
"is",
"of",
"the",
"wrong",
"format",
"null",
"is",
"returned",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/services/src/main/java/org/openengsb/core/services/xlink/XLinkUtils.java#L166-L175 | train |
openengsb/openengsb | components/services/src/main/java/org/openengsb/core/services/xlink/XLinkUtils.java | XLinkUtils.urlEncodeParameter | private static String urlEncodeParameter(String parameter) {
try {
return URLEncoder.encode(parameter, "UTF-8");
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(XLinkUtils.class.getName()).log(Level.SEVERE, null, ex);
}
return parameter;
} | java | private static String urlEncodeParameter(String parameter) {
try {
return URLEncoder.encode(parameter, "UTF-8");
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(XLinkUtils.class.getName()).log(Level.SEVERE, null, ex);
}
return parameter;
} | [
"private",
"static",
"String",
"urlEncodeParameter",
"(",
"String",
"parameter",
")",
"{",
"try",
"{",
"return",
"URLEncoder",
".",
"encode",
"(",
"parameter",
",",
"\"UTF-8\"",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"ex",
")",
"{",
"Logger",
".",
"getLogger",
"(",
"XLinkUtils",
".",
"class",
".",
"getName",
"(",
")",
")",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"null",
",",
"ex",
")",
";",
"}",
"return",
"parameter",
";",
"}"
] | Encodes a given Parameter in UTF-8. | [
"Encodes",
"a",
"given",
"Parameter",
"in",
"UTF",
"-",
"8",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/services/src/main/java/org/openengsb/core/services/xlink/XLinkUtils.java#L180-L187 | train |
openengsb/openengsb | components/services/src/main/java/org/openengsb/core/services/xlink/XLinkUtils.java | XLinkUtils.getViewsOfRegistration | public static XLinkConnectorView[] getViewsOfRegistration(XLinkConnectorRegistration registration) {
List<XLinkConnectorView> viewsOfRegistration = new ArrayList<XLinkConnectorView>();
Map<ModelDescription, XLinkConnectorView[]> modelsToViews = registration.getModelsToViews();
for (XLinkConnectorView[] views : modelsToViews.values()) {
for (int i = 0; i < views.length; i++) {
XLinkConnectorView view = views[i];
if (!viewsOfRegistration.contains(view)) {
viewsOfRegistration.add(view);
}
}
}
return viewsOfRegistration.toArray(new XLinkConnectorView[0]);
} | java | public static XLinkConnectorView[] getViewsOfRegistration(XLinkConnectorRegistration registration) {
List<XLinkConnectorView> viewsOfRegistration = new ArrayList<XLinkConnectorView>();
Map<ModelDescription, XLinkConnectorView[]> modelsToViews = registration.getModelsToViews();
for (XLinkConnectorView[] views : modelsToViews.values()) {
for (int i = 0; i < views.length; i++) {
XLinkConnectorView view = views[i];
if (!viewsOfRegistration.contains(view)) {
viewsOfRegistration.add(view);
}
}
}
return viewsOfRegistration.toArray(new XLinkConnectorView[0]);
} | [
"public",
"static",
"XLinkConnectorView",
"[",
"]",
"getViewsOfRegistration",
"(",
"XLinkConnectorRegistration",
"registration",
")",
"{",
"List",
"<",
"XLinkConnectorView",
">",
"viewsOfRegistration",
"=",
"new",
"ArrayList",
"<",
"XLinkConnectorView",
">",
"(",
")",
";",
"Map",
"<",
"ModelDescription",
",",
"XLinkConnectorView",
"[",
"]",
">",
"modelsToViews",
"=",
"registration",
".",
"getModelsToViews",
"(",
")",
";",
"for",
"(",
"XLinkConnectorView",
"[",
"]",
"views",
":",
"modelsToViews",
".",
"values",
"(",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"views",
".",
"length",
";",
"i",
"++",
")",
"{",
"XLinkConnectorView",
"view",
"=",
"views",
"[",
"i",
"]",
";",
"if",
"(",
"!",
"viewsOfRegistration",
".",
"contains",
"(",
"view",
")",
")",
"{",
"viewsOfRegistration",
".",
"add",
"(",
"view",
")",
";",
"}",
"}",
"}",
"return",
"viewsOfRegistration",
".",
"toArray",
"(",
"new",
"XLinkConnectorView",
"[",
"0",
"]",
")",
";",
"}"
] | Returns a distinct List of all RemoteToolViews, contained in a RemoteToolRegistration.
@see RemoteToolView
@see RemoteToolRegistration | [
"Returns",
"a",
"distinct",
"List",
"of",
"all",
"RemoteToolViews",
"contained",
"in",
"a",
"RemoteToolRegistration",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/services/src/main/java/org/openengsb/core/services/xlink/XLinkUtils.java#L194-L206 | train |
openengsb/openengsb | components/services/src/main/java/org/openengsb/core/services/xlink/XLinkUtils.java | XLinkUtils.getLocalToolFromRegistrations | public static XLinkConnector[] getLocalToolFromRegistrations(List<XLinkConnectorRegistration> registrations) {
List<XLinkConnector> tools = new ArrayList<XLinkConnector>();
for (XLinkConnectorRegistration registration : registrations) {
XLinkConnector newLocalTools
= new XLinkConnector(
registration.getConnectorId(),
registration.getToolName(),
getViewsOfRegistration(registration));
tools.add(newLocalTools);
}
return tools.toArray(new XLinkConnector[0]);
} | java | public static XLinkConnector[] getLocalToolFromRegistrations(List<XLinkConnectorRegistration> registrations) {
List<XLinkConnector> tools = new ArrayList<XLinkConnector>();
for (XLinkConnectorRegistration registration : registrations) {
XLinkConnector newLocalTools
= new XLinkConnector(
registration.getConnectorId(),
registration.getToolName(),
getViewsOfRegistration(registration));
tools.add(newLocalTools);
}
return tools.toArray(new XLinkConnector[0]);
} | [
"public",
"static",
"XLinkConnector",
"[",
"]",
"getLocalToolFromRegistrations",
"(",
"List",
"<",
"XLinkConnectorRegistration",
">",
"registrations",
")",
"{",
"List",
"<",
"XLinkConnector",
">",
"tools",
"=",
"new",
"ArrayList",
"<",
"XLinkConnector",
">",
"(",
")",
";",
"for",
"(",
"XLinkConnectorRegistration",
"registration",
":",
"registrations",
")",
"{",
"XLinkConnector",
"newLocalTools",
"=",
"new",
"XLinkConnector",
"(",
"registration",
".",
"getConnectorId",
"(",
")",
",",
"registration",
".",
"getToolName",
"(",
")",
",",
"getViewsOfRegistration",
"(",
"registration",
")",
")",
";",
"tools",
".",
"add",
"(",
"newLocalTools",
")",
";",
"}",
"return",
"tools",
".",
"toArray",
"(",
"new",
"XLinkConnector",
"[",
"0",
"]",
")",
";",
"}"
] | Returns a list of RemoteTools to a list of RemoteToolRegistrations.
The list of RemoteTool can be sent to a remote host. A RemoteToolRegistration
is for internal usage only.
@see RemoteToolRegistration
@see RemoteTool | [
"Returns",
"a",
"list",
"of",
"RemoteTools",
"to",
"a",
"list",
"of",
"RemoteToolRegistrations",
".",
"The",
"list",
"of",
"RemoteTool",
"can",
"be",
"sent",
"to",
"a",
"remote",
"host",
".",
"A",
"RemoteToolRegistration",
"is",
"for",
"internal",
"usage",
"only",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/services/src/main/java/org/openengsb/core/services/xlink/XLinkUtils.java#L215-L226 | train |
aseovic/coherence-tools | loader/src/main/java/com/seovic/loader/target/JpaTarget.java | JpaTarget.mergeInTransaction | private void mergeInTransaction(EntityManager em, Collection objects) {
EntityTransaction tx = null;
try {
tx = em.getTransaction();
tx.begin();
for (Object o : objects) {
em.merge(o);
}
tx.commit();
}
catch (RuntimeException e) {
if (tx != null && tx.isActive()) {
tx.rollback();
}
throw e;
}
} | java | private void mergeInTransaction(EntityManager em, Collection objects) {
EntityTransaction tx = null;
try {
tx = em.getTransaction();
tx.begin();
for (Object o : objects) {
em.merge(o);
}
tx.commit();
}
catch (RuntimeException e) {
if (tx != null && tx.isActive()) {
tx.rollback();
}
throw e;
}
} | [
"private",
"void",
"mergeInTransaction",
"(",
"EntityManager",
"em",
",",
"Collection",
"objects",
")",
"{",
"EntityTransaction",
"tx",
"=",
"null",
";",
"try",
"{",
"tx",
"=",
"em",
".",
"getTransaction",
"(",
")",
";",
"tx",
".",
"begin",
"(",
")",
";",
"for",
"(",
"Object",
"o",
":",
"objects",
")",
"{",
"em",
".",
"merge",
"(",
"o",
")",
";",
"}",
"tx",
".",
"commit",
"(",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"e",
")",
"{",
"if",
"(",
"tx",
"!=",
"null",
"&&",
"tx",
".",
"isActive",
"(",
")",
")",
"{",
"tx",
".",
"rollback",
"(",
")",
";",
"}",
"throw",
"e",
";",
"}",
"}"
] | Persist collection of objects.
@param em entity manager used to persist objects
@param objects objects to persist | [
"Persist",
"collection",
"of",
"objects",
"."
] | 561a1d7e572ad98657fcd26beb1164891b0cd6fe | https://github.com/aseovic/coherence-tools/blob/561a1d7e572ad98657fcd26beb1164891b0cd6fe/loader/src/main/java/com/seovic/loader/target/JpaTarget.java#L98-L114 | train |
openengsb/openengsb | components/edbi/jdbc/src/main/java/org/openengsb/core/edbi/jdbc/driver/h2/SchemaCreateCommand.java | SchemaCreateCommand.execute | public void execute() {
try {
new JdbcTemplate(dataSource).execute(readResourceContent(SCHEMA_FILE)); // TODO: sql independence
} catch (IOException e) {
throw new RuntimeException("Could not create schema for EDBI Index", e);
}
} | java | public void execute() {
try {
new JdbcTemplate(dataSource).execute(readResourceContent(SCHEMA_FILE)); // TODO: sql independence
} catch (IOException e) {
throw new RuntimeException("Could not create schema for EDBI Index", e);
}
} | [
"public",
"void",
"execute",
"(",
")",
"{",
"try",
"{",
"new",
"JdbcTemplate",
"(",
"dataSource",
")",
".",
"execute",
"(",
"readResourceContent",
"(",
"SCHEMA_FILE",
")",
")",
";",
"// TODO: sql independence",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Could not create schema for EDBI Index\"",
",",
"e",
")",
";",
"}",
"}"
] | Creates the necessary relations to save Index and IndexField instances. | [
"Creates",
"the",
"necessary",
"relations",
"to",
"save",
"Index",
"and",
"IndexField",
"instances",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/edbi/jdbc/src/main/java/org/openengsb/core/edbi/jdbc/driver/h2/SchemaCreateCommand.java#L44-L50 | train |
openengsb/openengsb | components/services/src/main/java/org/openengsb/core/services/internal/security/ldap/TimebasedOrderFilter.java | TimebasedOrderFilter.addId | public static void addId(Entry entry, boolean updateRdn) {
String uuid = newUUID().toString();
try {
entry.add(SchemaConstants.OBJECT_CLASS_ATTRIBUTE, UNIQUE_OBJECT_OC);
entry.add(ID_ATTRIBUTE, uuid);
} catch (LdapException e) {
throw new LdapRuntimeException(e);
}
if (updateRdn) {
Dn newDn = LdapUtils.concatDn(ID_ATTRIBUTE, uuid, entry.getDn().getParent());
entry.setDn(newDn);
}
} | java | public static void addId(Entry entry, boolean updateRdn) {
String uuid = newUUID().toString();
try {
entry.add(SchemaConstants.OBJECT_CLASS_ATTRIBUTE, UNIQUE_OBJECT_OC);
entry.add(ID_ATTRIBUTE, uuid);
} catch (LdapException e) {
throw new LdapRuntimeException(e);
}
if (updateRdn) {
Dn newDn = LdapUtils.concatDn(ID_ATTRIBUTE, uuid, entry.getDn().getParent());
entry.setDn(newDn);
}
} | [
"public",
"static",
"void",
"addId",
"(",
"Entry",
"entry",
",",
"boolean",
"updateRdn",
")",
"{",
"String",
"uuid",
"=",
"newUUID",
"(",
")",
".",
"toString",
"(",
")",
";",
"try",
"{",
"entry",
".",
"add",
"(",
"SchemaConstants",
".",
"OBJECT_CLASS_ATTRIBUTE",
",",
"UNIQUE_OBJECT_OC",
")",
";",
"entry",
".",
"add",
"(",
"ID_ATTRIBUTE",
",",
"uuid",
")",
";",
"}",
"catch",
"(",
"LdapException",
"e",
")",
"{",
"throw",
"new",
"LdapRuntimeException",
"(",
"e",
")",
";",
"}",
"if",
"(",
"updateRdn",
")",
"{",
"Dn",
"newDn",
"=",
"LdapUtils",
".",
"concatDn",
"(",
"ID_ATTRIBUTE",
",",
"uuid",
",",
"entry",
".",
"getDn",
"(",
")",
".",
"getParent",
"(",
")",
")",
";",
"entry",
".",
"setDn",
"(",
"newDn",
")",
";",
"}",
"}"
] | Adds a timebased uuid to entry. If updateRdn is true, the uuid becomes the rdn. Use this to handle duplicates. | [
"Adds",
"a",
"timebased",
"uuid",
"to",
"entry",
".",
"If",
"updateRdn",
"is",
"true",
"the",
"uuid",
"becomes",
"the",
"rdn",
".",
"Use",
"this",
"to",
"handle",
"duplicates",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/services/src/main/java/org/openengsb/core/services/internal/security/ldap/TimebasedOrderFilter.java#L57-L69 | train |
openengsb/openengsb | components/services/src/main/java/org/openengsb/core/services/internal/security/ldap/TimebasedOrderFilter.java | TimebasedOrderFilter.addIds | public static void addIds(List<Entry> entries, boolean updateRdn) {
for (Entry entry : entries) {
addId(entry, updateRdn);
}
} | java | public static void addIds(List<Entry> entries, boolean updateRdn) {
for (Entry entry : entries) {
addId(entry, updateRdn);
}
} | [
"public",
"static",
"void",
"addIds",
"(",
"List",
"<",
"Entry",
">",
"entries",
",",
"boolean",
"updateRdn",
")",
"{",
"for",
"(",
"Entry",
"entry",
":",
"entries",
")",
"{",
"addId",
"(",
"entry",
",",
"updateRdn",
")",
";",
"}",
"}"
] | Iterates over entries and adds a timebased uuid to each entry. If updateRdn is true, the uuid becomes the rdn.
Use this to handle duplicates. | [
"Iterates",
"over",
"entries",
"and",
"adds",
"a",
"timebased",
"uuid",
"to",
"each",
"entry",
".",
"If",
"updateRdn",
"is",
"true",
"the",
"uuid",
"becomes",
"the",
"rdn",
".",
"Use",
"this",
"to",
"handle",
"duplicates",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/services/src/main/java/org/openengsb/core/services/internal/security/ldap/TimebasedOrderFilter.java#L75-L79 | train |
aseovic/coherence-tools | core/src/main/java/com/seovic/core/concurrent/ClusteredExecutorService.java | ClusteredExecutorService.initialize | protected synchronized void initialize() {
String invocationServiceName = this.invocationServiceName;
invocationService = (InvocationService)
CacheFactory.getService(invocationServiceName);
if (invocationService == null) {
throw new IllegalArgumentException("Invocation service ["
+ invocationServiceName
+ "] is not defined.");
}
invocationService.addMemberListener(this);
serviceMembers = invocationService.getInfo().getServiceMembers();
memberIterator = serviceMembers.iterator();
} | java | protected synchronized void initialize() {
String invocationServiceName = this.invocationServiceName;
invocationService = (InvocationService)
CacheFactory.getService(invocationServiceName);
if (invocationService == null) {
throw new IllegalArgumentException("Invocation service ["
+ invocationServiceName
+ "] is not defined.");
}
invocationService.addMemberListener(this);
serviceMembers = invocationService.getInfo().getServiceMembers();
memberIterator = serviceMembers.iterator();
} | [
"protected",
"synchronized",
"void",
"initialize",
"(",
")",
"{",
"String",
"invocationServiceName",
"=",
"this",
".",
"invocationServiceName",
";",
"invocationService",
"=",
"(",
"InvocationService",
")",
"CacheFactory",
".",
"getService",
"(",
"invocationServiceName",
")",
";",
"if",
"(",
"invocationService",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invocation service [\"",
"+",
"invocationServiceName",
"+",
"\"] is not defined.\"",
")",
";",
"}",
"invocationService",
".",
"addMemberListener",
"(",
"this",
")",
";",
"serviceMembers",
"=",
"invocationService",
".",
"getInfo",
"(",
")",
".",
"getServiceMembers",
"(",
")",
";",
"memberIterator",
"=",
"serviceMembers",
".",
"iterator",
"(",
")",
";",
"}"
] | Initialize this executor service. | [
"Initialize",
"this",
"executor",
"service",
"."
] | 561a1d7e572ad98657fcd26beb1164891b0cd6fe | https://github.com/aseovic/coherence-tools/blob/561a1d7e572ad98657fcd26beb1164891b0cd6fe/core/src/main/java/com/seovic/core/concurrent/ClusteredExecutorService.java#L101-L114 | train |
aseovic/coherence-tools | core/src/main/java/com/seovic/core/concurrent/ClusteredExecutorService.java | ClusteredExecutorService.execute | public void execute(Runnable command) {
if (!(command instanceof ClusteredFutureTask)) {
command = new ClusteredFutureTask<Object>(command, null);
}
command.run();
} | java | public void execute(Runnable command) {
if (!(command instanceof ClusteredFutureTask)) {
command = new ClusteredFutureTask<Object>(command, null);
}
command.run();
} | [
"public",
"void",
"execute",
"(",
"Runnable",
"command",
")",
"{",
"if",
"(",
"!",
"(",
"command",
"instanceof",
"ClusteredFutureTask",
")",
")",
"{",
"command",
"=",
"new",
"ClusteredFutureTask",
"<",
"Object",
">",
"(",
"command",
",",
"null",
")",
";",
"}",
"command",
".",
"run",
"(",
")",
";",
"}"
] | Executes the given command at some time in the future.
@param command the runnable task | [
"Executes",
"the",
"given",
"command",
"at",
"some",
"time",
"in",
"the",
"future",
"."
] | 561a1d7e572ad98657fcd26beb1164891b0cd6fe | https://github.com/aseovic/coherence-tools/blob/561a1d7e572ad98657fcd26beb1164891b0cd6fe/core/src/main/java/com/seovic/core/concurrent/ClusteredExecutorService.java#L124-L129 | train |
aseovic/coherence-tools | core/src/main/java/com/seovic/core/concurrent/ClusteredExecutorService.java | ClusteredExecutorService.getExecutionMember | protected synchronized Member getExecutionMember() {
Iterator<Member> it = memberIterator;
if (it == null || !it.hasNext()) {
memberIterator = it = serviceMembers.iterator();
}
return it.next();
} | java | protected synchronized Member getExecutionMember() {
Iterator<Member> it = memberIterator;
if (it == null || !it.hasNext()) {
memberIterator = it = serviceMembers.iterator();
}
return it.next();
} | [
"protected",
"synchronized",
"Member",
"getExecutionMember",
"(",
")",
"{",
"Iterator",
"<",
"Member",
">",
"it",
"=",
"memberIterator",
";",
"if",
"(",
"it",
"==",
"null",
"||",
"!",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"memberIterator",
"=",
"it",
"=",
"serviceMembers",
".",
"iterator",
"(",
")",
";",
"}",
"return",
"it",
".",
"next",
"(",
")",
";",
"}"
] | Return the member that should execute submitted command.
@return the member to execute submitted command on | [
"Return",
"the",
"member",
"that",
"should",
"execute",
"submitted",
"command",
"."
] | 561a1d7e572ad98657fcd26beb1164891b0cd6fe | https://github.com/aseovic/coherence-tools/blob/561a1d7e572ad98657fcd26beb1164891b0cd6fe/core/src/main/java/com/seovic/core/concurrent/ClusteredExecutorService.java#L185-L191 | train |
cloudfoundry-community/cf-java-component | cf-spring/src/main/java/cf/spring/servicebroker/AbstractAnnotationCatalogAccessorProvider.java | AbstractAnnotationCatalogAccessorProvider.getMethodAccessor | protected BrokerServiceAccessor getMethodAccessor(String serviceBrokerName, CatalogService description) {
return new AnnotationBrokerServiceAccessor(description, serviceBrokerName, getBeanClass(serviceBrokerName),
context.getBean(serviceBrokerName));
} | java | protected BrokerServiceAccessor getMethodAccessor(String serviceBrokerName, CatalogService description) {
return new AnnotationBrokerServiceAccessor(description, serviceBrokerName, getBeanClass(serviceBrokerName),
context.getBean(serviceBrokerName));
} | [
"protected",
"BrokerServiceAccessor",
"getMethodAccessor",
"(",
"String",
"serviceBrokerName",
",",
"CatalogService",
"description",
")",
"{",
"return",
"new",
"AnnotationBrokerServiceAccessor",
"(",
"description",
",",
"serviceBrokerName",
",",
"getBeanClass",
"(",
"serviceBrokerName",
")",
",",
"context",
".",
"getBean",
"(",
"serviceBrokerName",
")",
")",
";",
"}"
] | Returns the accessor used to access the specified service of the
specified broker.
@param serviceBrokerName the name of the broker offering the specified service
@param description the service description | [
"Returns",
"the",
"accessor",
"used",
"to",
"access",
"the",
"specified",
"service",
"of",
"the",
"specified",
"broker",
"."
] | 9d7d54f2b599f3e4f4706bc0c471e144065671fa | https://github.com/cloudfoundry-community/cf-java-component/blob/9d7d54f2b599f3e4f4706bc0c471e144065671fa/cf-spring/src/main/java/cf/spring/servicebroker/AbstractAnnotationCatalogAccessorProvider.java#L48-L51 | train |
cloudfoundry-community/cf-java-component | cf-spring/src/main/java/cf/spring/servicebroker/AbstractAnnotationCatalogAccessorProvider.java | AbstractAnnotationCatalogAccessorProvider.getBeanClass | protected Class<?> getBeanClass(String beanName) {
Class<?> clazz = context.getType(beanName);
while (Proxy.isProxyClass(clazz) || Enhancer.isEnhanced(clazz)) {
clazz = clazz.getSuperclass();
}
return clazz;
} | java | protected Class<?> getBeanClass(String beanName) {
Class<?> clazz = context.getType(beanName);
while (Proxy.isProxyClass(clazz) || Enhancer.isEnhanced(clazz)) {
clazz = clazz.getSuperclass();
}
return clazz;
} | [
"protected",
"Class",
"<",
"?",
">",
"getBeanClass",
"(",
"String",
"beanName",
")",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"context",
".",
"getType",
"(",
"beanName",
")",
";",
"while",
"(",
"Proxy",
".",
"isProxyClass",
"(",
"clazz",
")",
"||",
"Enhancer",
".",
"isEnhanced",
"(",
"clazz",
")",
")",
"{",
"clazz",
"=",
"clazz",
".",
"getSuperclass",
"(",
")",
";",
"}",
"return",
"clazz",
";",
"}"
] | Returns the class of the specified bean name. | [
"Returns",
"the",
"class",
"of",
"the",
"specified",
"bean",
"name",
"."
] | 9d7d54f2b599f3e4f4706bc0c471e144065671fa | https://github.com/cloudfoundry-community/cf-java-component/blob/9d7d54f2b599f3e4f4706bc0c471e144065671fa/cf-spring/src/main/java/cf/spring/servicebroker/AbstractAnnotationCatalogAccessorProvider.java#L56-L62 | train |
FedericoPecora/meta-csp-framework | src/main/java/org/metacsp/framework/Constraint.java | Constraint.skipSolver | public void skipSolver(ConstraintSolver ... solvers) {
if (solversToSkip == null) solversToSkip = new HashSet<ConstraintSolver>();
for (ConstraintSolver solver : solvers) solversToSkip.add(solver);
} | java | public void skipSolver(ConstraintSolver ... solvers) {
if (solversToSkip == null) solversToSkip = new HashSet<ConstraintSolver>();
for (ConstraintSolver solver : solvers) solversToSkip.add(solver);
} | [
"public",
"void",
"skipSolver",
"(",
"ConstraintSolver",
"...",
"solvers",
")",
"{",
"if",
"(",
"solversToSkip",
"==",
"null",
")",
"solversToSkip",
"=",
"new",
"HashSet",
"<",
"ConstraintSolver",
">",
"(",
")",
";",
"for",
"(",
"ConstraintSolver",
"solver",
":",
"solvers",
")",
"solversToSkip",
".",
"(",
"solver",
")",
";",
"}"
] | Provide a list of solvers that should not process this constraint.
@param solvers Solvers that should not process this constraint. | [
"Provide",
"a",
"list",
"of",
"solvers",
"that",
"should",
"not",
"process",
"this",
"constraint",
"."
] | 42aaef2e2b76d0f738427f0dd9653c4f62b40517 | https://github.com/FedericoPecora/meta-csp-framework/blob/42aaef2e2b76d0f738427f0dd9653c4f62b40517/src/main/java/org/metacsp/framework/Constraint.java#L72-L75 | train |
aseovic/coherence-tools | loader/src/main/java/com/seovic/loader/target/XmlTarget.java | XmlTarget.initAttributesAndElements | private void initAttributesAndElements(String... propertyNames)
{
for (String propertyName : propertyNames)
{
Property property = new Property(propertyName);
if (property.isAttribute())
{
m_attributes.add(property);
}
else
{
m_elements.add(property);
}
}
} | java | private void initAttributesAndElements(String... propertyNames)
{
for (String propertyName : propertyNames)
{
Property property = new Property(propertyName);
if (property.isAttribute())
{
m_attributes.add(property);
}
else
{
m_elements.add(property);
}
}
} | [
"private",
"void",
"initAttributesAndElements",
"(",
"String",
"...",
"propertyNames",
")",
"{",
"for",
"(",
"String",
"propertyName",
":",
"propertyNames",
")",
"{",
"Property",
"property",
"=",
"new",
"Property",
"(",
"propertyName",
")",
";",
"if",
"(",
"property",
".",
"isAttribute",
"(",
")",
")",
"{",
"m_attributes",
".",
"add",
"(",
"property",
")",
";",
"}",
"else",
"{",
"m_elements",
".",
"add",
"(",
"property",
")",
";",
"}",
"}",
"}"
] | Parses user-specified property names and determines which properties
should be written out as attributes and which as child elements.
@param propertyNames property names | [
"Parses",
"user",
"-",
"specified",
"property",
"names",
"and",
"determines",
"which",
"properties",
"should",
"be",
"written",
"out",
"as",
"attributes",
"and",
"which",
"as",
"child",
"elements",
"."
] | 561a1d7e572ad98657fcd26beb1164891b0cd6fe | https://github.com/aseovic/coherence-tools/blob/561a1d7e572ad98657fcd26beb1164891b0cd6fe/loader/src/main/java/com/seovic/loader/target/XmlTarget.java#L384-L398 | train |
FedericoPecora/meta-csp-framework | src/main/java/org/metacsp/time/TimePoint.java | TimePoint.setUsed | public void setUsed(boolean newVal){
if(isUsed() && newVal == false) {
Arrays.fill(out, null);
}
used = newVal;
} | java | public void setUsed(boolean newVal){
if(isUsed() && newVal == false) {
Arrays.fill(out, null);
}
used = newVal;
} | [
"public",
"void",
"setUsed",
"(",
"boolean",
"newVal",
")",
"{",
"if",
"(",
"isUsed",
"(",
")",
"&&",
"newVal",
"==",
"false",
")",
"{",
"Arrays",
".",
"fill",
"(",
"out",
",",
"null",
")",
";",
"}",
"used",
"=",
"newVal",
";",
"}"
] | Set whether this time point as used in the underlying temporal network.
@param newVal Set to true iff the time point should be included in the underlying temporal network. | [
"Set",
"whether",
"this",
"time",
"point",
"as",
"used",
"in",
"the",
"underlying",
"temporal",
"network",
"."
] | 42aaef2e2b76d0f738427f0dd9653c4f62b40517 | https://github.com/FedericoPecora/meta-csp-framework/blob/42aaef2e2b76d0f738427f0dd9653c4f62b40517/src/main/java/org/metacsp/time/TimePoint.java#L182-L189 | train |
openengsb/openengsb | components/ekb/transformation-wonderland/src/main/java/org/openengsb/core/ekb/transformation/wonderland/internal/operation/PadOperation.java | PadOperation.getPadCharacter | private Character getPadCharacter(String characterString) {
if (characterString.length() > 0) {
getLogger().debug("The given character string is longer than one element. The first character is used.");
}
return characterString.charAt(0);
} | java | private Character getPadCharacter(String characterString) {
if (characterString.length() > 0) {
getLogger().debug("The given character string is longer than one element. The first character is used.");
}
return characterString.charAt(0);
} | [
"private",
"Character",
"getPadCharacter",
"(",
"String",
"characterString",
")",
"{",
"if",
"(",
"characterString",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"getLogger",
"(",
")",
".",
"debug",
"(",
"\"The given character string is longer than one element. The first character is used.\"",
")",
";",
"}",
"return",
"characterString",
".",
"charAt",
"(",
"0",
")",
";",
"}"
] | Returns the character which is used for the padding. If the character string is longer than one char, the first
char will be used. | [
"Returns",
"the",
"character",
"which",
"is",
"used",
"for",
"the",
"padding",
".",
"If",
"the",
"character",
"string",
"is",
"longer",
"than",
"one",
"char",
"the",
"first",
"char",
"will",
"be",
"used",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/transformation-wonderland/src/main/java/org/openengsb/core/ekb/transformation/wonderland/internal/operation/PadOperation.java#L80-L85 | train |
openengsb/openengsb | components/ekb/transformation-wonderland/src/main/java/org/openengsb/core/ekb/transformation/wonderland/internal/operation/PadOperation.java | PadOperation.getDirectionString | private String getDirectionString(String direction) {
if (direction == null || !(direction.equals("Start") || direction.equals("End"))) {
getLogger().debug("Unrecognized direction string. The standard value 'Start' will be used.");
return "Start";
}
return direction;
} | java | private String getDirectionString(String direction) {
if (direction == null || !(direction.equals("Start") || direction.equals("End"))) {
getLogger().debug("Unrecognized direction string. The standard value 'Start' will be used.");
return "Start";
}
return direction;
} | [
"private",
"String",
"getDirectionString",
"(",
"String",
"direction",
")",
"{",
"if",
"(",
"direction",
"==",
"null",
"||",
"!",
"(",
"direction",
".",
"equals",
"(",
"\"Start\"",
")",
"||",
"direction",
".",
"equals",
"(",
"\"End\"",
")",
")",
")",
"{",
"getLogger",
"(",
")",
".",
"debug",
"(",
"\"Unrecognized direction string. The standard value 'Start' will be used.\"",
")",
";",
"return",
"\"Start\"",
";",
"}",
"return",
"direction",
";",
"}"
] | Returns the direction in which the padding will be done. If the direction string is null or invalid, 'Start' will
be taken instead. | [
"Returns",
"the",
"direction",
"in",
"which",
"the",
"padding",
"will",
"be",
"done",
".",
"If",
"the",
"direction",
"string",
"is",
"null",
"or",
"invalid",
"Start",
"will",
"be",
"taken",
"instead",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/transformation-wonderland/src/main/java/org/openengsb/core/ekb/transformation/wonderland/internal/operation/PadOperation.java#L91-L97 | train |
openengsb/openengsb | components/ekb/transformation-wonderland/src/main/java/org/openengsb/core/ekb/transformation/wonderland/internal/operation/PadOperation.java | PadOperation.performPadOperation | private String performPadOperation(String source, Integer length, Character padChar, String direction) {
if (direction.equals("Start")) {
return Strings.padStart(source, length, padChar);
} else {
return Strings.padEnd(source, length, padChar);
}
} | java | private String performPadOperation(String source, Integer length, Character padChar, String direction) {
if (direction.equals("Start")) {
return Strings.padStart(source, length, padChar);
} else {
return Strings.padEnd(source, length, padChar);
}
} | [
"private",
"String",
"performPadOperation",
"(",
"String",
"source",
",",
"Integer",
"length",
",",
"Character",
"padChar",
",",
"String",
"direction",
")",
"{",
"if",
"(",
"direction",
".",
"equals",
"(",
"\"Start\"",
")",
")",
"{",
"return",
"Strings",
".",
"padStart",
"(",
"source",
",",
"length",
",",
"padChar",
")",
";",
"}",
"else",
"{",
"return",
"Strings",
".",
"padEnd",
"(",
"source",
",",
"length",
",",
"padChar",
")",
";",
"}",
"}"
] | Perform the pad operation itself and returns the result | [
"Perform",
"the",
"pad",
"operation",
"itself",
"and",
"returns",
"the",
"result"
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/transformation-wonderland/src/main/java/org/openengsb/core/ekb/transformation/wonderland/internal/operation/PadOperation.java#L102-L108 | train |
openengsb/openengsb | connector/userprojectsfile/src/main/java/org/openengsb/connector/userprojects/file/internal/file/ProjectFileAccessObject.java | ProjectFileAccessObject.findAllProjects | public List<Project> findAllProjects() {
List<Project> list = new ArrayList<>();
List<String> projectNames;
try {
projectNames = readLines(projectsFile);
} catch (IOException e) {
throw new FileBasedRuntimeException(e);
}
for (String projectName : projectNames) {
if (StringUtils.isNotBlank(projectName)) {
list.add(new Project(projectName));
}
}
return list;
} | java | public List<Project> findAllProjects() {
List<Project> list = new ArrayList<>();
List<String> projectNames;
try {
projectNames = readLines(projectsFile);
} catch (IOException e) {
throw new FileBasedRuntimeException(e);
}
for (String projectName : projectNames) {
if (StringUtils.isNotBlank(projectName)) {
list.add(new Project(projectName));
}
}
return list;
} | [
"public",
"List",
"<",
"Project",
">",
"findAllProjects",
"(",
")",
"{",
"List",
"<",
"Project",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"List",
"<",
"String",
">",
"projectNames",
";",
"try",
"{",
"projectNames",
"=",
"readLines",
"(",
"projectsFile",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"FileBasedRuntimeException",
"(",
"e",
")",
";",
"}",
"for",
"(",
"String",
"projectName",
":",
"projectNames",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"projectName",
")",
")",
"{",
"list",
".",
"add",
"(",
"new",
"Project",
"(",
"projectName",
")",
")",
";",
"}",
"}",
"return",
"list",
";",
"}"
] | Finds all the available projects.
@return the list of available projects | [
"Finds",
"all",
"the",
"available",
"projects",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/connector/userprojectsfile/src/main/java/org/openengsb/connector/userprojects/file/internal/file/ProjectFileAccessObject.java#L44-L59 | train |
openengsb/openengsb | components/edbi/jdbc/src/main/java/org/openengsb/core/edbi/jdbc/util/Introspector.java | Introspector.getPropertyTypeMap | public static Map<String, Class<?>> getPropertyTypeMap(Class<?> clazz, String... exclude) {
PropertyDescriptor[] descriptors;
try {
descriptors = getPropertyDescriptors(clazz);
} catch (IntrospectionException e) {
LOG.error("Failed to introspect " + clazz, e);
return Collections.emptyMap();
}
HashMap<String, Class<?>> map = new HashMap<>(descriptors.length);
for (PropertyDescriptor pd : descriptors) {
map.put(pd.getName(), pd.getPropertyType());
}
for (String property : exclude) {
map.remove(property);
}
return map;
} | java | public static Map<String, Class<?>> getPropertyTypeMap(Class<?> clazz, String... exclude) {
PropertyDescriptor[] descriptors;
try {
descriptors = getPropertyDescriptors(clazz);
} catch (IntrospectionException e) {
LOG.error("Failed to introspect " + clazz, e);
return Collections.emptyMap();
}
HashMap<String, Class<?>> map = new HashMap<>(descriptors.length);
for (PropertyDescriptor pd : descriptors) {
map.put(pd.getName(), pd.getPropertyType());
}
for (String property : exclude) {
map.remove(property);
}
return map;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"Class",
"<",
"?",
">",
">",
"getPropertyTypeMap",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"...",
"exclude",
")",
"{",
"PropertyDescriptor",
"[",
"]",
"descriptors",
";",
"try",
"{",
"descriptors",
"=",
"getPropertyDescriptors",
"(",
"clazz",
")",
";",
"}",
"catch",
"(",
"IntrospectionException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Failed to introspect \"",
"+",
"clazz",
",",
"e",
")",
";",
"return",
"Collections",
".",
"emptyMap",
"(",
")",
";",
"}",
"HashMap",
"<",
"String",
",",
"Class",
"<",
"?",
">",
">",
"map",
"=",
"new",
"HashMap",
"<>",
"(",
"descriptors",
".",
"length",
")",
";",
"for",
"(",
"PropertyDescriptor",
"pd",
":",
"descriptors",
")",
"{",
"map",
".",
"put",
"(",
"pd",
".",
"getName",
"(",
")",
",",
"pd",
".",
"getPropertyType",
"(",
")",
")",
";",
"}",
"for",
"(",
"String",
"property",
":",
"exclude",
")",
"{",
"map",
".",
"remove",
"(",
"property",
")",
";",
"}",
"return",
"map",
";",
"}"
] | Returns a create of all property names and their respective type. Any property passed via exclude are removed
from the create before hand.
@param clazz the class to introspect
@param exclude the properties to exclude
@return a mapping between property names and their type. | [
"Returns",
"a",
"create",
"of",
"all",
"property",
"names",
"and",
"their",
"respective",
"type",
".",
"Any",
"property",
"passed",
"via",
"exclude",
"are",
"removed",
"from",
"the",
"create",
"before",
"hand",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/edbi/jdbc/src/main/java/org/openengsb/core/edbi/jdbc/util/Introspector.java#L66-L87 | train |
openengsb/openengsb | components/edbi/jdbc/src/main/java/org/openengsb/core/edbi/jdbc/util/Introspector.java | Introspector.read | public static Map<String, Object> read(Object object) {
PropertyDescriptor[] descriptors;
Class<?> clazz = object.getClass();
try {
descriptors = getPropertyDescriptors(clazz);
} catch (IntrospectionException e) {
LOG.error("Failed to introspect " + clazz, e);
return Collections.emptyMap();
}
HashMap<String, Object> map = new HashMap<>(descriptors.length);
for (PropertyDescriptor pd : descriptors) {
try {
Object value = pd.getReadMethod().invoke(object);
map.put(pd.getName(), value);
} catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException e) {
LOG.error("Failed to visit property " + pd.getName(), e);
}
}
map.remove("class");
return map;
} | java | public static Map<String, Object> read(Object object) {
PropertyDescriptor[] descriptors;
Class<?> clazz = object.getClass();
try {
descriptors = getPropertyDescriptors(clazz);
} catch (IntrospectionException e) {
LOG.error("Failed to introspect " + clazz, e);
return Collections.emptyMap();
}
HashMap<String, Object> map = new HashMap<>(descriptors.length);
for (PropertyDescriptor pd : descriptors) {
try {
Object value = pd.getReadMethod().invoke(object);
map.put(pd.getName(), value);
} catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException e) {
LOG.error("Failed to visit property " + pd.getName(), e);
}
}
map.remove("class");
return map;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"read",
"(",
"Object",
"object",
")",
"{",
"PropertyDescriptor",
"[",
"]",
"descriptors",
";",
"Class",
"<",
"?",
">",
"clazz",
"=",
"object",
".",
"getClass",
"(",
")",
";",
"try",
"{",
"descriptors",
"=",
"getPropertyDescriptors",
"(",
"clazz",
")",
";",
"}",
"catch",
"(",
"IntrospectionException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Failed to introspect \"",
"+",
"clazz",
",",
"e",
")",
";",
"return",
"Collections",
".",
"emptyMap",
"(",
")",
";",
"}",
"HashMap",
"<",
"String",
",",
"Object",
">",
"map",
"=",
"new",
"HashMap",
"<>",
"(",
"descriptors",
".",
"length",
")",
";",
"for",
"(",
"PropertyDescriptor",
"pd",
":",
"descriptors",
")",
"{",
"try",
"{",
"Object",
"value",
"=",
"pd",
".",
"getReadMethod",
"(",
")",
".",
"invoke",
"(",
"object",
")",
";",
"map",
".",
"put",
"(",
"pd",
".",
"getName",
"(",
")",
",",
"value",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"|",
"InvocationTargetException",
"|",
"IllegalArgumentException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Failed to visit property \"",
"+",
"pd",
".",
"getName",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"map",
".",
"remove",
"(",
"\"class\"",
")",
";",
"return",
"map",
";",
"}"
] | Returns a create of all property names and their values contained in the given object.
@param object the object to visit out of
@return the extracted value create | [
"Returns",
"a",
"create",
"of",
"all",
"property",
"names",
"and",
"their",
"values",
"contained",
"in",
"the",
"given",
"object",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/edbi/jdbc/src/main/java/org/openengsb/core/edbi/jdbc/util/Introspector.java#L95-L120 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/AdvancedModelWrapper.java | AdvancedModelWrapper.wrap | public static AdvancedModelWrapper wrap(Object model) {
if (!(isModel(model.getClass()))) {
throw new IllegalArgumentException("The given object is no model");
}
return new AdvancedModelWrapper((OpenEngSBModel) model);
} | java | public static AdvancedModelWrapper wrap(Object model) {
if (!(isModel(model.getClass()))) {
throw new IllegalArgumentException("The given object is no model");
}
return new AdvancedModelWrapper((OpenEngSBModel) model);
} | [
"public",
"static",
"AdvancedModelWrapper",
"wrap",
"(",
"Object",
"model",
")",
"{",
"if",
"(",
"!",
"(",
"isModel",
"(",
"model",
".",
"getClass",
"(",
")",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The given object is no model\"",
")",
";",
"}",
"return",
"new",
"AdvancedModelWrapper",
"(",
"(",
"OpenEngSBModel",
")",
"model",
")",
";",
"}"
] | Creates an advanced model wrapper object out of the given model object. Throws IllegalArgumentException in case
the given model object is no model. | [
"Creates",
"an",
"advanced",
"model",
"wrapper",
"object",
"out",
"of",
"the",
"given",
"model",
"object",
".",
"Throws",
"IllegalArgumentException",
"in",
"case",
"the",
"given",
"model",
"object",
"is",
"no",
"model",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/AdvancedModelWrapper.java#L45-L50 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/AdvancedModelWrapper.java | AdvancedModelWrapper.getModelsReferringToThisModel | public List<EDBObject> getModelsReferringToThisModel(EngineeringDatabaseService edbService) {
return edbService.query(QueryRequest.query(
EDBConverter.REFERENCE_PREFIX + "%", getCompleteModelOID()));
} | java | public List<EDBObject> getModelsReferringToThisModel(EngineeringDatabaseService edbService) {
return edbService.query(QueryRequest.query(
EDBConverter.REFERENCE_PREFIX + "%", getCompleteModelOID()));
} | [
"public",
"List",
"<",
"EDBObject",
">",
"getModelsReferringToThisModel",
"(",
"EngineeringDatabaseService",
"edbService",
")",
"{",
"return",
"edbService",
".",
"query",
"(",
"QueryRequest",
".",
"query",
"(",
"EDBConverter",
".",
"REFERENCE_PREFIX",
"+",
"\"%\"",
",",
"getCompleteModelOID",
"(",
")",
")",
")",
";",
"}"
] | Returns a list of EDBObjects which are referring to this model. | [
"Returns",
"a",
"list",
"of",
"EDBObjects",
"which",
"are",
"referring",
"to",
"this",
"model",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/AdvancedModelWrapper.java#L55-L58 | train |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/AdvancedModelWrapper.java | AdvancedModelWrapper.isEngineeringObjectClass | public static Boolean isEngineeringObjectClass(Class<?> clazz) {
for (Field field : clazz.getDeclaredFields()) {
if (field.isAnnotationPresent(OpenEngSBForeignKey.class)) {
return true;
}
}
return false;
} | java | public static Boolean isEngineeringObjectClass(Class<?> clazz) {
for (Field field : clazz.getDeclaredFields()) {
if (field.isAnnotationPresent(OpenEngSBForeignKey.class)) {
return true;
}
}
return false;
} | [
"public",
"static",
"Boolean",
"isEngineeringObjectClass",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"for",
"(",
"Field",
"field",
":",
"clazz",
".",
"getDeclaredFields",
"(",
")",
")",
"{",
"if",
"(",
"field",
".",
"isAnnotationPresent",
"(",
"OpenEngSBForeignKey",
".",
"class",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns true if the class is the class of an engineering object, returns false if not. | [
"Returns",
"true",
"if",
"the",
"class",
"is",
"the",
"class",
"of",
"an",
"engineering",
"object",
"returns",
"false",
"if",
"not",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/AdvancedModelWrapper.java#L77-L84 | train |
openengsb/openengsb | components/util/src/main/java/org/openengsb/core/util/JsonUtils.java | JsonUtils.convertObject | public static <T> T convertObject(String json, Class<T> clazz) throws IOException {
try {
if (clazz.isAnnotationPresent(Model.class)) {
return MODEL_MAPPER.readValue(json, clazz);
}
return MAPPER.readValue(json, clazz);
} catch (IOException e) {
String error = String.format("Unable to parse given json '%s' into class '%s'.", json, clazz.getName());
LOGGER.error(error, e);
throw new IOException(error, e);
}
} | java | public static <T> T convertObject(String json, Class<T> clazz) throws IOException {
try {
if (clazz.isAnnotationPresent(Model.class)) {
return MODEL_MAPPER.readValue(json, clazz);
}
return MAPPER.readValue(json, clazz);
} catch (IOException e) {
String error = String.format("Unable to parse given json '%s' into class '%s'.", json, clazz.getName());
LOGGER.error(error, e);
throw new IOException(error, e);
}
} | [
"public",
"static",
"<",
"T",
">",
"T",
"convertObject",
"(",
"String",
"json",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"throws",
"IOException",
"{",
"try",
"{",
"if",
"(",
"clazz",
".",
"isAnnotationPresent",
"(",
"Model",
".",
"class",
")",
")",
"{",
"return",
"MODEL_MAPPER",
".",
"readValue",
"(",
"json",
",",
"clazz",
")",
";",
"}",
"return",
"MAPPER",
".",
"readValue",
"(",
"json",
",",
"clazz",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"String",
"error",
"=",
"String",
".",
"format",
"(",
"\"Unable to parse given json '%s' into class '%s'.\"",
",",
"json",
",",
"clazz",
".",
"getName",
"(",
")",
")",
";",
"LOGGER",
".",
"error",
"(",
"error",
",",
"e",
")",
";",
"throw",
"new",
"IOException",
"(",
"error",
",",
"e",
")",
";",
"}",
"}"
] | Converts an object in JSON format to the given class. Throws an IOException if the conversion could not be
performed. | [
"Converts",
"an",
"object",
"in",
"JSON",
"format",
"to",
"the",
"given",
"class",
".",
"Throws",
"an",
"IOException",
"if",
"the",
"conversion",
"could",
"not",
"be",
"performed",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/util/src/main/java/org/openengsb/core/util/JsonUtils.java#L65-L76 | train |
openengsb/openengsb | components/edbi/hook/src/main/java/org/openengsb/framework/edbi/hook/internal/CommitConverter.java | CommitConverter.convert | public IndexCommit convert(EKBCommit ekbCommit) {
IndexCommit commit = new IndexCommit();
commit.setCommitId(ekbCommit.getRevisionNumber());
commit.setParentCommitId(ekbCommit.getParentRevisionNumber());
commit.setConnectorId(ekbCommit.getConnectorId());
commit.setDomainId(ekbCommit.getDomainId());
commit.setInstanceId(ekbCommit.getInstanceId());
commit.setTimestamp(new Date());
commit.setUser(getUser());
commit.setContextId(getContextId());
List<OpenEngSBModel> inserts = ekbCommit.getInserts();
List<OpenEngSBModel> updates = ekbCommit.getUpdates();
List<OpenEngSBModel> deletes = ekbCommit.getDeletes();
Set<Class<?>> modelClasses = extractTypes(inserts, updates, deletes);
commit.setModelClasses(modelClasses);
commit.setInserts(mapByClass(inserts));
commit.setUpdates(mapByClass(updates));
commit.setDeletes(mapByClass(deletes));
return commit;
} | java | public IndexCommit convert(EKBCommit ekbCommit) {
IndexCommit commit = new IndexCommit();
commit.setCommitId(ekbCommit.getRevisionNumber());
commit.setParentCommitId(ekbCommit.getParentRevisionNumber());
commit.setConnectorId(ekbCommit.getConnectorId());
commit.setDomainId(ekbCommit.getDomainId());
commit.setInstanceId(ekbCommit.getInstanceId());
commit.setTimestamp(new Date());
commit.setUser(getUser());
commit.setContextId(getContextId());
List<OpenEngSBModel> inserts = ekbCommit.getInserts();
List<OpenEngSBModel> updates = ekbCommit.getUpdates();
List<OpenEngSBModel> deletes = ekbCommit.getDeletes();
Set<Class<?>> modelClasses = extractTypes(inserts, updates, deletes);
commit.setModelClasses(modelClasses);
commit.setInserts(mapByClass(inserts));
commit.setUpdates(mapByClass(updates));
commit.setDeletes(mapByClass(deletes));
return commit;
} | [
"public",
"IndexCommit",
"convert",
"(",
"EKBCommit",
"ekbCommit",
")",
"{",
"IndexCommit",
"commit",
"=",
"new",
"IndexCommit",
"(",
")",
";",
"commit",
".",
"setCommitId",
"(",
"ekbCommit",
".",
"getRevisionNumber",
"(",
")",
")",
";",
"commit",
".",
"setParentCommitId",
"(",
"ekbCommit",
".",
"getParentRevisionNumber",
"(",
")",
")",
";",
"commit",
".",
"setConnectorId",
"(",
"ekbCommit",
".",
"getConnectorId",
"(",
")",
")",
";",
"commit",
".",
"setDomainId",
"(",
"ekbCommit",
".",
"getDomainId",
"(",
")",
")",
";",
"commit",
".",
"setInstanceId",
"(",
"ekbCommit",
".",
"getInstanceId",
"(",
")",
")",
";",
"commit",
".",
"setTimestamp",
"(",
"new",
"Date",
"(",
")",
")",
";",
"commit",
".",
"setUser",
"(",
"getUser",
"(",
")",
")",
";",
"commit",
".",
"setContextId",
"(",
"getContextId",
"(",
")",
")",
";",
"List",
"<",
"OpenEngSBModel",
">",
"inserts",
"=",
"ekbCommit",
".",
"getInserts",
"(",
")",
";",
"List",
"<",
"OpenEngSBModel",
">",
"updates",
"=",
"ekbCommit",
".",
"getUpdates",
"(",
")",
";",
"List",
"<",
"OpenEngSBModel",
">",
"deletes",
"=",
"ekbCommit",
".",
"getDeletes",
"(",
")",
";",
"Set",
"<",
"Class",
"<",
"?",
">",
">",
"modelClasses",
"=",
"extractTypes",
"(",
"inserts",
",",
"updates",
",",
"deletes",
")",
";",
"commit",
".",
"setModelClasses",
"(",
"modelClasses",
")",
";",
"commit",
".",
"setInserts",
"(",
"mapByClass",
"(",
"inserts",
")",
")",
";",
"commit",
".",
"setUpdates",
"(",
"mapByClass",
"(",
"updates",
")",
")",
";",
"commit",
".",
"setDeletes",
"(",
"mapByClass",
"(",
"deletes",
")",
")",
";",
"return",
"commit",
";",
"}"
] | Convert the given EKBCommit to an IndexCommit.
@param ekbCommit the commit to convert
@return a new IndexCommit instance representing the given EKBCommit | [
"Convert",
"the",
"given",
"EKBCommit",
"to",
"an",
"IndexCommit",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/edbi/hook/src/main/java/org/openengsb/framework/edbi/hook/internal/CommitConverter.java#L60-L86 | train |
openengsb/openengsb | components/edbi/hook/src/main/java/org/openengsb/framework/edbi/hook/internal/CommitConverter.java | CommitConverter.mapByClass | protected Map<Class<?>, List<OpenEngSBModel>> mapByClass(Collection<OpenEngSBModel> models) {
return group(models, new Function<OpenEngSBModel, Class<?>>() {
@Override
public Class<?> apply(OpenEngSBModel input) {
return input.getClass();
}
});
} | java | protected Map<Class<?>, List<OpenEngSBModel>> mapByClass(Collection<OpenEngSBModel> models) {
return group(models, new Function<OpenEngSBModel, Class<?>>() {
@Override
public Class<?> apply(OpenEngSBModel input) {
return input.getClass();
}
});
} | [
"protected",
"Map",
"<",
"Class",
"<",
"?",
">",
",",
"List",
"<",
"OpenEngSBModel",
">",
">",
"mapByClass",
"(",
"Collection",
"<",
"OpenEngSBModel",
">",
"models",
")",
"{",
"return",
"group",
"(",
"models",
",",
"new",
"Function",
"<",
"OpenEngSBModel",
",",
"Class",
"<",
"?",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Class",
"<",
"?",
">",
"apply",
"(",
"OpenEngSBModel",
"input",
")",
"{",
"return",
"input",
".",
"getClass",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Groups all models in the given collection by their class.
@param models the models
@return a map containing all given models grouped by their type | [
"Groups",
"all",
"models",
"in",
"the",
"given",
"collection",
"by",
"their",
"class",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/edbi/hook/src/main/java/org/openengsb/framework/edbi/hook/internal/CommitConverter.java#L94-L101 | train |
cloudfoundry-community/cf-java-component | cf-spring/src/main/java/cf/spring/servicebroker/CatalogAccessor.java | CatalogAccessor.createCatalog | public Catalog createCatalog() {
final List<CatalogService> services = new ArrayList<>();
for (BrokerServiceAccessor serviceAccessor : serviceAccessors) {
services.add(serviceAccessor.getServiceDescription());
}
return new Catalog(services);
} | java | public Catalog createCatalog() {
final List<CatalogService> services = new ArrayList<>();
for (BrokerServiceAccessor serviceAccessor : serviceAccessors) {
services.add(serviceAccessor.getServiceDescription());
}
return new Catalog(services);
} | [
"public",
"Catalog",
"createCatalog",
"(",
")",
"{",
"final",
"List",
"<",
"CatalogService",
">",
"services",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"BrokerServiceAccessor",
"serviceAccessor",
":",
"serviceAccessors",
")",
"{",
"services",
".",
"add",
"(",
"serviceAccessor",
".",
"getServiceDescription",
"(",
")",
")",
";",
"}",
"return",
"new",
"Catalog",
"(",
"services",
")",
";",
"}"
] | Creates the catalog. | [
"Creates",
"the",
"catalog",
"."
] | 9d7d54f2b599f3e4f4706bc0c471e144065671fa | https://github.com/cloudfoundry-community/cf-java-component/blob/9d7d54f2b599f3e4f4706bc0c471e144065671fa/cf-spring/src/main/java/cf/spring/servicebroker/CatalogAccessor.java#L52-L60 | train |
cloudfoundry-community/cf-java-component | cf-spring/src/main/java/cf/spring/servicebroker/CatalogAccessor.java | CatalogAccessor.getServiceAccessor | public BrokerServiceAccessor getServiceAccessor(String serviceId) {
for (BrokerServiceAccessor serviceAccessor : serviceAccessors) {
if (serviceId.equals(serviceAccessor.getServiceDescription().getId())) {
return serviceAccessor;
}
}
throw new NotFoundException("Could not find service broker with service_id " + serviceId);
} | java | public BrokerServiceAccessor getServiceAccessor(String serviceId) {
for (BrokerServiceAccessor serviceAccessor : serviceAccessors) {
if (serviceId.equals(serviceAccessor.getServiceDescription().getId())) {
return serviceAccessor;
}
}
throw new NotFoundException("Could not find service broker with service_id " + serviceId);
} | [
"public",
"BrokerServiceAccessor",
"getServiceAccessor",
"(",
"String",
"serviceId",
")",
"{",
"for",
"(",
"BrokerServiceAccessor",
"serviceAccessor",
":",
"serviceAccessors",
")",
"{",
"if",
"(",
"serviceId",
".",
"equals",
"(",
"serviceAccessor",
".",
"getServiceDescription",
"(",
")",
".",
"getId",
"(",
")",
")",
")",
"{",
"return",
"serviceAccessor",
";",
"}",
"}",
"throw",
"new",
"NotFoundException",
"(",
"\"Could not find service broker with service_id \"",
"+",
"serviceId",
")",
";",
"}"
] | Returns the accessor associated to the specified service id. | [
"Returns",
"the",
"accessor",
"associated",
"to",
"the",
"specified",
"service",
"id",
"."
] | 9d7d54f2b599f3e4f4706bc0c471e144065671fa | https://github.com/cloudfoundry-community/cf-java-component/blob/9d7d54f2b599f3e4f4706bc0c471e144065671fa/cf-spring/src/main/java/cf/spring/servicebroker/CatalogAccessor.java#L65-L73 | train |
openengsb/openengsb | components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraphUtils.java | OrientModelGraphUtils.setIdFieldValue | public static void setIdFieldValue(ODocument document, String value) {
setFieldValue(document, OGraphDatabase.LABEL, value);
} | java | public static void setIdFieldValue(ODocument document, String value) {
setFieldValue(document, OGraphDatabase.LABEL, value);
} | [
"public",
"static",
"void",
"setIdFieldValue",
"(",
"ODocument",
"document",
",",
"String",
"value",
")",
"{",
"setFieldValue",
"(",
"document",
",",
"OGraphDatabase",
".",
"LABEL",
",",
"value",
")",
";",
"}"
] | Sets the value for the id field of a graph object. | [
"Sets",
"the",
"value",
"for",
"the",
"id",
"field",
"of",
"a",
"graph",
"object",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraphUtils.java#L50-L52 | train |
openengsb/openengsb | components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraphUtils.java | OrientModelGraphUtils.setActiveFieldValue | public static void setActiveFieldValue(ODocument document, Boolean active) {
setFieldValue(document, ACTIVE_FIELD, active.toString());
} | java | public static void setActiveFieldValue(ODocument document, Boolean active) {
setFieldValue(document, ACTIVE_FIELD, active.toString());
} | [
"public",
"static",
"void",
"setActiveFieldValue",
"(",
"ODocument",
"document",
",",
"Boolean",
"active",
")",
"{",
"setFieldValue",
"(",
"document",
",",
"ACTIVE_FIELD",
",",
"active",
".",
"toString",
"(",
")",
")",
";",
"}"
] | Sets the value for the active field of a graph object. | [
"Sets",
"the",
"value",
"for",
"the",
"active",
"field",
"of",
"a",
"graph",
"object",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraphUtils.java#L64-L66 | train |
openengsb/openengsb | components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraphUtils.java | OrientModelGraphUtils.getFieldValue | public static String getFieldValue(ODocument document, String fieldname) {
return (String) document.field(fieldname);
} | java | public static String getFieldValue(ODocument document, String fieldname) {
return (String) document.field(fieldname);
} | [
"public",
"static",
"String",
"getFieldValue",
"(",
"ODocument",
"document",
",",
"String",
"fieldname",
")",
"{",
"return",
"(",
"String",
")",
"document",
".",
"field",
"(",
"fieldname",
")",
";",
"}"
] | Gets the value for the given field of a graph object. | [
"Gets",
"the",
"value",
"for",
"the",
"given",
"field",
"of",
"a",
"graph",
"object",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraphUtils.java#L78-L80 | train |
openengsb/openengsb | components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraphUtils.java | OrientModelGraphUtils.setFieldValue | public static void setFieldValue(ODocument document, String fieldname, String value) {
document.field(fieldname, value);
} | java | public static void setFieldValue(ODocument document, String fieldname, String value) {
document.field(fieldname, value);
} | [
"public",
"static",
"void",
"setFieldValue",
"(",
"ODocument",
"document",
",",
"String",
"fieldname",
",",
"String",
"value",
")",
"{",
"document",
".",
"field",
"(",
"fieldname",
",",
"value",
")",
";",
"}"
] | Sets the value for the given field of an graph object. | [
"Sets",
"the",
"value",
"for",
"the",
"given",
"field",
"of",
"an",
"graph",
"object",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraphUtils.java#L85-L87 | train |
openengsb/openengsb | components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraphUtils.java | OrientModelGraphUtils.fillEdgeWithPropertyConnections | public static void fillEdgeWithPropertyConnections(ODocument edge, TransformationDescription description) {
Map<String, String> connections = convertPropertyConnectionsToSimpleForm(description.getPropertyConnections());
for (Map.Entry<String, String> entry : connections.entrySet()) {
edge.field(entry.getKey(), entry.getValue());
}
} | java | public static void fillEdgeWithPropertyConnections(ODocument edge, TransformationDescription description) {
Map<String, String> connections = convertPropertyConnectionsToSimpleForm(description.getPropertyConnections());
for (Map.Entry<String, String> entry : connections.entrySet()) {
edge.field(entry.getKey(), entry.getValue());
}
} | [
"public",
"static",
"void",
"fillEdgeWithPropertyConnections",
"(",
"ODocument",
"edge",
",",
"TransformationDescription",
"description",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"connections",
"=",
"convertPropertyConnectionsToSimpleForm",
"(",
"description",
".",
"getPropertyConnections",
"(",
")",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"connections",
".",
"entrySet",
"(",
")",
")",
"{",
"edge",
".",
"field",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}"
] | Adds to the given map the property connection information which result from the given transformation description. | [
"Adds",
"to",
"the",
"given",
"map",
"the",
"property",
"connection",
"information",
"which",
"result",
"from",
"the",
"given",
"transformation",
"description",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/graphdb-orient/src/main/java/org/openengsb/core/ekb/graph/orient/internal/OrientModelGraphUtils.java#L92-L97 | train |
FedericoPecora/meta-csp-framework | src/main/java/org/metacsp/utility/PermutationsWithRepetition.java | PermutationsWithRepetition.getVariations | public int[][] getVariations() {
int permutations = (int) Math.pow(n, r);
int[][] table = new int[permutations][r];
for (int x = 0; x < r; x++) {
int t2 = (int) Math.pow(n, x);
for (int p1 = 0; p1 < permutations;) {
for (int al = 0; al < n; al++) {
for (int p2 = 0; p2 < t2; p2++) {
table[p1][x] = al;
p1++;
}
}
}
}
return table;
} | java | public int[][] getVariations() {
int permutations = (int) Math.pow(n, r);
int[][] table = new int[permutations][r];
for (int x = 0; x < r; x++) {
int t2 = (int) Math.pow(n, x);
for (int p1 = 0; p1 < permutations;) {
for (int al = 0; al < n; al++) {
for (int p2 = 0; p2 < t2; p2++) {
table[p1][x] = al;
p1++;
}
}
}
}
return table;
} | [
"public",
"int",
"[",
"]",
"[",
"]",
"getVariations",
"(",
")",
"{",
"int",
"permutations",
"=",
"(",
"int",
")",
"Math",
".",
"pow",
"(",
"n",
",",
"r",
")",
";",
"int",
"[",
"]",
"[",
"]",
"table",
"=",
"new",
"int",
"[",
"permutations",
"]",
"[",
"r",
"]",
";",
"for",
"(",
"int",
"x",
"=",
"0",
";",
"x",
"<",
"r",
";",
"x",
"++",
")",
"{",
"int",
"t2",
"=",
"(",
"int",
")",
"Math",
".",
"pow",
"(",
"n",
",",
"x",
")",
";",
"for",
"(",
"int",
"p1",
"=",
"0",
";",
"p1",
"<",
"permutations",
";",
")",
"{",
"for",
"(",
"int",
"al",
"=",
"0",
";",
"al",
"<",
"n",
";",
"al",
"++",
")",
"{",
"for",
"(",
"int",
"p2",
"=",
"0",
";",
"p2",
"<",
"t2",
";",
"p2",
"++",
")",
"{",
"table",
"[",
"p1",
"]",
"[",
"x",
"]",
"=",
"al",
";",
"p1",
"++",
";",
"}",
"}",
"}",
"}",
"return",
"table",
";",
"}"
] | Get all r-permutations of n integers.
@return All r-permutations of n integers. | [
"Get",
"all",
"r",
"-",
"permutations",
"of",
"n",
"integers",
"."
] | 42aaef2e2b76d0f738427f0dd9653c4f62b40517 | https://github.com/FedericoPecora/meta-csp-framework/blob/42aaef2e2b76d0f738427f0dd9653c4f62b40517/src/main/java/org/metacsp/utility/PermutationsWithRepetition.java#L54-L71 | train |
openengsb/openengsb | components/edb/src/main/java/org/openengsb/core/edb/jpa/internal/CheckPreCommitHook.java | CheckPreCommitHook.checkInserts | private List<JPAObject> checkInserts(List<JPAObject> inserts) {
List<JPAObject> failedObjects = new ArrayList<JPAObject>();
for (JPAObject insert : inserts) {
String oid = insert.getOID();
if (checkIfActiveOidExisting(oid)) {
failedObjects.add(insert);
} else {
insert.addEntry(new JPAEntry(EDBConstants.MODEL_VERSION, "1", Integer.class.getName(), insert));
}
}
return failedObjects;
} | java | private List<JPAObject> checkInserts(List<JPAObject> inserts) {
List<JPAObject> failedObjects = new ArrayList<JPAObject>();
for (JPAObject insert : inserts) {
String oid = insert.getOID();
if (checkIfActiveOidExisting(oid)) {
failedObjects.add(insert);
} else {
insert.addEntry(new JPAEntry(EDBConstants.MODEL_VERSION, "1", Integer.class.getName(), insert));
}
}
return failedObjects;
} | [
"private",
"List",
"<",
"JPAObject",
">",
"checkInserts",
"(",
"List",
"<",
"JPAObject",
">",
"inserts",
")",
"{",
"List",
"<",
"JPAObject",
">",
"failedObjects",
"=",
"new",
"ArrayList",
"<",
"JPAObject",
">",
"(",
")",
";",
"for",
"(",
"JPAObject",
"insert",
":",
"inserts",
")",
"{",
"String",
"oid",
"=",
"insert",
".",
"getOID",
"(",
")",
";",
"if",
"(",
"checkIfActiveOidExisting",
"(",
"oid",
")",
")",
"{",
"failedObjects",
".",
"add",
"(",
"insert",
")",
";",
"}",
"else",
"{",
"insert",
".",
"addEntry",
"(",
"new",
"JPAEntry",
"(",
"EDBConstants",
".",
"MODEL_VERSION",
",",
"\"1\"",
",",
"Integer",
".",
"class",
".",
"getName",
"(",
")",
",",
"insert",
")",
")",
";",
"}",
"}",
"return",
"failedObjects",
";",
"}"
] | Checks if all oid's of the given JPAObjects are not existing yet. Returns a list of objects where the JPAObject
already exists. | [
"Checks",
"if",
"all",
"oid",
"s",
"of",
"the",
"given",
"JPAObjects",
"are",
"not",
"existing",
"yet",
".",
"Returns",
"a",
"list",
"of",
"objects",
"where",
"the",
"JPAObject",
"already",
"exists",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/edb/src/main/java/org/openengsb/core/edb/jpa/internal/CheckPreCommitHook.java#L98-L109 | train |
openengsb/openengsb | components/edb/src/main/java/org/openengsb/core/edb/jpa/internal/CheckPreCommitHook.java | CheckPreCommitHook.checkDeletions | private List<String> checkDeletions(List<String> deletes) {
List<String> failedObjects = new ArrayList<String>();
for (String delete : deletes) {
if (!checkIfActiveOidExisting(delete)) {
failedObjects.add(delete);
}
}
return failedObjects;
} | java | private List<String> checkDeletions(List<String> deletes) {
List<String> failedObjects = new ArrayList<String>();
for (String delete : deletes) {
if (!checkIfActiveOidExisting(delete)) {
failedObjects.add(delete);
}
}
return failedObjects;
} | [
"private",
"List",
"<",
"String",
">",
"checkDeletions",
"(",
"List",
"<",
"String",
">",
"deletes",
")",
"{",
"List",
"<",
"String",
">",
"failedObjects",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"String",
"delete",
":",
"deletes",
")",
"{",
"if",
"(",
"!",
"checkIfActiveOidExisting",
"(",
"delete",
")",
")",
"{",
"failedObjects",
".",
"add",
"(",
"delete",
")",
";",
"}",
"}",
"return",
"failedObjects",
";",
"}"
] | Checks if all oid's of the given JPAObjects are existing. Returns a list of objects where the JPAObject doesn't
exist. | [
"Checks",
"if",
"all",
"oid",
"s",
"of",
"the",
"given",
"JPAObjects",
"are",
"existing",
".",
"Returns",
"a",
"list",
"of",
"objects",
"where",
"the",
"JPAObject",
"doesn",
"t",
"exist",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/edb/src/main/java/org/openengsb/core/edb/jpa/internal/CheckPreCommitHook.java#L115-L123 | train |
openengsb/openengsb | components/edb/src/main/java/org/openengsb/core/edb/jpa/internal/CheckPreCommitHook.java | CheckPreCommitHook.checkUpdates | private List<JPAObject> checkUpdates(List<JPAObject> updates) throws EDBException {
List<JPAObject> failedObjects = new ArrayList<JPAObject>();
for (JPAObject update : updates) {
try {
Integer modelVersion = investigateVersionAndCheckForConflict(update);
modelVersion++;
update.removeEntry(EDBConstants.MODEL_VERSION);
update.addEntry(new JPAEntry(EDBConstants.MODEL_VERSION, modelVersion + "",
Integer.class.getName(), update));
} catch (EDBException e) {
failedObjects.add(update);
}
}
return failedObjects;
} | java | private List<JPAObject> checkUpdates(List<JPAObject> updates) throws EDBException {
List<JPAObject> failedObjects = new ArrayList<JPAObject>();
for (JPAObject update : updates) {
try {
Integer modelVersion = investigateVersionAndCheckForConflict(update);
modelVersion++;
update.removeEntry(EDBConstants.MODEL_VERSION);
update.addEntry(new JPAEntry(EDBConstants.MODEL_VERSION, modelVersion + "",
Integer.class.getName(), update));
} catch (EDBException e) {
failedObjects.add(update);
}
}
return failedObjects;
} | [
"private",
"List",
"<",
"JPAObject",
">",
"checkUpdates",
"(",
"List",
"<",
"JPAObject",
">",
"updates",
")",
"throws",
"EDBException",
"{",
"List",
"<",
"JPAObject",
">",
"failedObjects",
"=",
"new",
"ArrayList",
"<",
"JPAObject",
">",
"(",
")",
";",
"for",
"(",
"JPAObject",
"update",
":",
"updates",
")",
"{",
"try",
"{",
"Integer",
"modelVersion",
"=",
"investigateVersionAndCheckForConflict",
"(",
"update",
")",
";",
"modelVersion",
"++",
";",
"update",
".",
"removeEntry",
"(",
"EDBConstants",
".",
"MODEL_VERSION",
")",
";",
"update",
".",
"addEntry",
"(",
"new",
"JPAEntry",
"(",
"EDBConstants",
".",
"MODEL_VERSION",
",",
"modelVersion",
"+",
"\"\"",
",",
"Integer",
".",
"class",
".",
"getName",
"(",
")",
",",
"update",
")",
")",
";",
"}",
"catch",
"(",
"EDBException",
"e",
")",
"{",
"failedObjects",
".",
"add",
"(",
"update",
")",
";",
"}",
"}",
"return",
"failedObjects",
";",
"}"
] | Checks every update for a potential conflict. Returns a list of objects where a conflict has been found. | [
"Checks",
"every",
"update",
"for",
"a",
"potential",
"conflict",
".",
"Returns",
"a",
"list",
"of",
"objects",
"where",
"a",
"conflict",
"has",
"been",
"found",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/edb/src/main/java/org/openengsb/core/edb/jpa/internal/CheckPreCommitHook.java#L128-L142 | train |
openengsb/openengsb | components/edb/src/main/java/org/openengsb/core/edb/jpa/internal/CheckPreCommitHook.java | CheckPreCommitHook.investigateVersionAndCheckForConflict | private Integer investigateVersionAndCheckForConflict(JPAObject newObject) throws EDBException {
JPAEntry entry = newObject.getEntry(EDBConstants.MODEL_VERSION);
String oid = newObject.getOID();
Integer modelVersion = 0;
if (entry != null) {
modelVersion = Integer.parseInt(entry.getValue());
Integer currentVersion = dao.getVersionOfOid(oid);
if (!modelVersion.equals(currentVersion)) {
try {
checkForConflict(newObject);
} catch (EDBException e) {
LOGGER.info("conflict detected, user get informed");
throw new EDBException("conflict was detected. There is a newer version of the model with the oid "
+ oid + " saved.");
}
modelVersion = currentVersion;
}
} else {
modelVersion = dao.getVersionOfOid(oid);
}
return modelVersion;
} | java | private Integer investigateVersionAndCheckForConflict(JPAObject newObject) throws EDBException {
JPAEntry entry = newObject.getEntry(EDBConstants.MODEL_VERSION);
String oid = newObject.getOID();
Integer modelVersion = 0;
if (entry != null) {
modelVersion = Integer.parseInt(entry.getValue());
Integer currentVersion = dao.getVersionOfOid(oid);
if (!modelVersion.equals(currentVersion)) {
try {
checkForConflict(newObject);
} catch (EDBException e) {
LOGGER.info("conflict detected, user get informed");
throw new EDBException("conflict was detected. There is a newer version of the model with the oid "
+ oid + " saved.");
}
modelVersion = currentVersion;
}
} else {
modelVersion = dao.getVersionOfOid(oid);
}
return modelVersion;
} | [
"private",
"Integer",
"investigateVersionAndCheckForConflict",
"(",
"JPAObject",
"newObject",
")",
"throws",
"EDBException",
"{",
"JPAEntry",
"entry",
"=",
"newObject",
".",
"getEntry",
"(",
"EDBConstants",
".",
"MODEL_VERSION",
")",
";",
"String",
"oid",
"=",
"newObject",
".",
"getOID",
"(",
")",
";",
"Integer",
"modelVersion",
"=",
"0",
";",
"if",
"(",
"entry",
"!=",
"null",
")",
"{",
"modelVersion",
"=",
"Integer",
".",
"parseInt",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"Integer",
"currentVersion",
"=",
"dao",
".",
"getVersionOfOid",
"(",
"oid",
")",
";",
"if",
"(",
"!",
"modelVersion",
".",
"equals",
"(",
"currentVersion",
")",
")",
"{",
"try",
"{",
"checkForConflict",
"(",
"newObject",
")",
";",
"}",
"catch",
"(",
"EDBException",
"e",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"conflict detected, user get informed\"",
")",
";",
"throw",
"new",
"EDBException",
"(",
"\"conflict was detected. There is a newer version of the model with the oid \"",
"+",
"oid",
"+",
"\" saved.\"",
")",
";",
"}",
"modelVersion",
"=",
"currentVersion",
";",
"}",
"}",
"else",
"{",
"modelVersion",
"=",
"dao",
".",
"getVersionOfOid",
"(",
"oid",
")",
";",
"}",
"return",
"modelVersion",
";",
"}"
] | Investigates the version of an JPAObject and checks if a conflict can be found. | [
"Investigates",
"the",
"version",
"of",
"an",
"JPAObject",
"and",
"checks",
"if",
"a",
"conflict",
"can",
"be",
"found",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/edb/src/main/java/org/openengsb/core/edb/jpa/internal/CheckPreCommitHook.java#L147-L170 | train |
openengsb/openengsb | components/edb/src/main/java/org/openengsb/core/edb/jpa/internal/CheckPreCommitHook.java | CheckPreCommitHook.checkForConflict | private void checkForConflict(JPAObject newObject) throws EDBException {
String oid = newObject.getOID();
JPAObject object = dao.getJPAObject(oid);
for (JPAEntry entry : newObject.getEntries()) {
if (entry.getKey().equals(EDBConstants.MODEL_VERSION)) {
continue;
}
JPAEntry rival = object.getEntry(entry.getKey());
String value = rival != null ? rival.getValue() : null;
if (value == null || !value.equals(entry.getValue())) {
LOGGER.debug("Conflict detected at key {} when comparing {} with {}", new Object[]{ entry.getKey(),
entry.getValue(), value == null ? "null" : value });
throw new EDBException("Conflict detected. Failure when comparing the values of the key "
+ entry.getKey());
}
}
} | java | private void checkForConflict(JPAObject newObject) throws EDBException {
String oid = newObject.getOID();
JPAObject object = dao.getJPAObject(oid);
for (JPAEntry entry : newObject.getEntries()) {
if (entry.getKey().equals(EDBConstants.MODEL_VERSION)) {
continue;
}
JPAEntry rival = object.getEntry(entry.getKey());
String value = rival != null ? rival.getValue() : null;
if (value == null || !value.equals(entry.getValue())) {
LOGGER.debug("Conflict detected at key {} when comparing {} with {}", new Object[]{ entry.getKey(),
entry.getValue(), value == null ? "null" : value });
throw new EDBException("Conflict detected. Failure when comparing the values of the key "
+ entry.getKey());
}
}
} | [
"private",
"void",
"checkForConflict",
"(",
"JPAObject",
"newObject",
")",
"throws",
"EDBException",
"{",
"String",
"oid",
"=",
"newObject",
".",
"getOID",
"(",
")",
";",
"JPAObject",
"object",
"=",
"dao",
".",
"getJPAObject",
"(",
"oid",
")",
";",
"for",
"(",
"JPAEntry",
"entry",
":",
"newObject",
".",
"getEntries",
"(",
")",
")",
"{",
"if",
"(",
"entry",
".",
"getKey",
"(",
")",
".",
"equals",
"(",
"EDBConstants",
".",
"MODEL_VERSION",
")",
")",
"{",
"continue",
";",
"}",
"JPAEntry",
"rival",
"=",
"object",
".",
"getEntry",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"String",
"value",
"=",
"rival",
"!=",
"null",
"?",
"rival",
".",
"getValue",
"(",
")",
":",
"null",
";",
"if",
"(",
"value",
"==",
"null",
"||",
"!",
"value",
".",
"equals",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Conflict detected at key {} when comparing {} with {}\"",
",",
"new",
"Object",
"[",
"]",
"{",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
",",
"value",
"==",
"null",
"?",
"\"null\"",
":",
"value",
"}",
")",
";",
"throw",
"new",
"EDBException",
"(",
"\"Conflict detected. Failure when comparing the values of the key \"",
"+",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Simple check mechanism if there is a conflict between a model which should be saved and the existing model, based
on the values which are in the EDB. | [
"Simple",
"check",
"mechanism",
"if",
"there",
"is",
"a",
"conflict",
"between",
"a",
"model",
"which",
"should",
"be",
"saved",
"and",
"the",
"existing",
"model",
"based",
"on",
"the",
"values",
"which",
"are",
"in",
"the",
"EDB",
"."
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/edb/src/main/java/org/openengsb/core/edb/jpa/internal/CheckPreCommitHook.java#L176-L192 | train |
openengsb/openengsb | tooling/wsdl2dll/src/main/java/org/openengsb/loom/csharp/comon/wsdltodll/WsdlToDll.java | WsdlToDll.execute | @Override
public void execute() throws MojoExecutionException {
checkParameters();
windowsModus = isWindows();
if (windowsModus) {
setWindowsVariables();
} else {
setLinuxVariables();
}
createDllFromWsdl();
} | java | @Override
public void execute() throws MojoExecutionException {
checkParameters();
windowsModus = isWindows();
if (windowsModus) {
setWindowsVariables();
} else {
setLinuxVariables();
}
createDllFromWsdl();
} | [
"@",
"Override",
"public",
"void",
"execute",
"(",
")",
"throws",
"MojoExecutionException",
"{",
"checkParameters",
"(",
")",
";",
"windowsModus",
"=",
"isWindows",
"(",
")",
";",
"if",
"(",
"windowsModus",
")",
"{",
"setWindowsVariables",
"(",
")",
";",
"}",
"else",
"{",
"setLinuxVariables",
"(",
")",
";",
"}",
"createDllFromWsdl",
"(",
")",
";",
"}"
] | Find and executes the commands wsdl.exe and csc.exe | [
"Find",
"and",
"executes",
"the",
"commands",
"wsdl",
".",
"exe",
"and",
"csc",
".",
"exe"
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/tooling/wsdl2dll/src/main/java/org/openengsb/loom/csharp/comon/wsdltodll/WsdlToDll.java#L191-L201 | train |
openengsb/openengsb | tooling/wsdl2dll/src/main/java/org/openengsb/loom/csharp/comon/wsdltodll/WsdlToDll.java | WsdlToDll.createDllFromWsdl | private void createDllFromWsdl() throws MojoExecutionException {
getLog().info("Execute WSDl to cs command");
wsdlCommand();
getLog().info("Execute cs to dll command");
cscCommand();
if (generateNugetPackage) {
if (isLinux()) {
throw new MojoExecutionException(
"At this point, mono and nuget does not work so well together."
+ "Please execute the plugin with nuget under Windows");
}
nugetLib = nugetFolder + "lib";
getLog().info("Create Nuget folder structure");
createNugetStructure();
getLog().info("Copy the dlls to the nuget structure");
copyFilesToNuget();
getLog().info("Generate " + namespace + " .nuspec");
generateNugetPackedFile();
getLog().info("Pack .nuspec to a nuget package");
nugetPackCommand();
}
} | java | private void createDllFromWsdl() throws MojoExecutionException {
getLog().info("Execute WSDl to cs command");
wsdlCommand();
getLog().info("Execute cs to dll command");
cscCommand();
if (generateNugetPackage) {
if (isLinux()) {
throw new MojoExecutionException(
"At this point, mono and nuget does not work so well together."
+ "Please execute the plugin with nuget under Windows");
}
nugetLib = nugetFolder + "lib";
getLog().info("Create Nuget folder structure");
createNugetStructure();
getLog().info("Copy the dlls to the nuget structure");
copyFilesToNuget();
getLog().info("Generate " + namespace + " .nuspec");
generateNugetPackedFile();
getLog().info("Pack .nuspec to a nuget package");
nugetPackCommand();
}
} | [
"private",
"void",
"createDllFromWsdl",
"(",
")",
"throws",
"MojoExecutionException",
"{",
"getLog",
"(",
")",
".",
"info",
"(",
"\"Execute WSDl to cs command\"",
")",
";",
"wsdlCommand",
"(",
")",
";",
"getLog",
"(",
")",
".",
"info",
"(",
"\"Execute cs to dll command\"",
")",
";",
"cscCommand",
"(",
")",
";",
"if",
"(",
"generateNugetPackage",
")",
"{",
"if",
"(",
"isLinux",
"(",
")",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"\"At this point, mono and nuget does not work so well together.\"",
"+",
"\"Please execute the plugin with nuget under Windows\"",
")",
";",
"}",
"nugetLib",
"=",
"nugetFolder",
"+",
"\"lib\"",
";",
"getLog",
"(",
")",
".",
"info",
"(",
"\"Create Nuget folder structure\"",
")",
";",
"createNugetStructure",
"(",
")",
";",
"getLog",
"(",
")",
".",
"info",
"(",
"\"Copy the dlls to the nuget structure\"",
")",
";",
"copyFilesToNuget",
"(",
")",
";",
"getLog",
"(",
")",
".",
"info",
"(",
"\"Generate \"",
"+",
"namespace",
"+",
"\" .nuspec\"",
")",
";",
"generateNugetPackedFile",
"(",
")",
";",
"getLog",
"(",
")",
".",
"info",
"(",
"\"Pack .nuspec to a nuget package\"",
")",
";",
"nugetPackCommand",
"(",
")",
";",
"}",
"}"
] | Windows mode for maven execution
@throws MojoExecutionException | [
"Windows",
"mode",
"for",
"maven",
"execution"
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/tooling/wsdl2dll/src/main/java/org/openengsb/loom/csharp/comon/wsdltodll/WsdlToDll.java#L237-L258 | train |
openengsb/openengsb | tooling/wsdl2dll/src/main/java/org/openengsb/loom/csharp/comon/wsdltodll/WsdlToDll.java | WsdlToDll.wsdlCommand | private void wsdlCommand() throws MojoExecutionException {
String cmd = findWsdlCommand();
int i = 0;
for (String location : wsdlLocations) {
String outputFilename = new File(outputDirectory, namespace + (i++)
+ ".cs").getAbsolutePath();
String[] command = new String[]{ cmd, serverParameter,
"/n:" + namespace, location, "/out:" + outputFilename };
ProcessBuilder builder = new ProcessBuilder();
builder.redirectErrorStream(true);
builder.command(command);
try {
executeACommand(builder.start());
} catch (IOException | InterruptedException e) {
throw new MojoExecutionException(
"Error, while executing command: "
+ Arrays.toString(command) + "\n", e);
}
cspath.add(outputFilename);
}
try {
FileComparer.removeSimilaritiesAndSaveFiles(cspath, getLog(),
windowsModus);
} catch (IOException e) {
throw new MojoExecutionException(
"It was not possible, to remove similarities form the files",
e);
}
} | java | private void wsdlCommand() throws MojoExecutionException {
String cmd = findWsdlCommand();
int i = 0;
for (String location : wsdlLocations) {
String outputFilename = new File(outputDirectory, namespace + (i++)
+ ".cs").getAbsolutePath();
String[] command = new String[]{ cmd, serverParameter,
"/n:" + namespace, location, "/out:" + outputFilename };
ProcessBuilder builder = new ProcessBuilder();
builder.redirectErrorStream(true);
builder.command(command);
try {
executeACommand(builder.start());
} catch (IOException | InterruptedException e) {
throw new MojoExecutionException(
"Error, while executing command: "
+ Arrays.toString(command) + "\n", e);
}
cspath.add(outputFilename);
}
try {
FileComparer.removeSimilaritiesAndSaveFiles(cspath, getLog(),
windowsModus);
} catch (IOException e) {
throw new MojoExecutionException(
"It was not possible, to remove similarities form the files",
e);
}
} | [
"private",
"void",
"wsdlCommand",
"(",
")",
"throws",
"MojoExecutionException",
"{",
"String",
"cmd",
"=",
"findWsdlCommand",
"(",
")",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"String",
"location",
":",
"wsdlLocations",
")",
"{",
"String",
"outputFilename",
"=",
"new",
"File",
"(",
"outputDirectory",
",",
"namespace",
"+",
"(",
"i",
"++",
")",
"+",
"\".cs\"",
")",
".",
"getAbsolutePath",
"(",
")",
";",
"String",
"[",
"]",
"command",
"=",
"new",
"String",
"[",
"]",
"{",
"cmd",
",",
"serverParameter",
",",
"\"/n:\"",
"+",
"namespace",
",",
"location",
",",
"\"/out:\"",
"+",
"outputFilename",
"}",
";",
"ProcessBuilder",
"builder",
"=",
"new",
"ProcessBuilder",
"(",
")",
";",
"builder",
".",
"redirectErrorStream",
"(",
"true",
")",
";",
"builder",
".",
"command",
"(",
"command",
")",
";",
"try",
"{",
"executeACommand",
"(",
"builder",
".",
"start",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"|",
"InterruptedException",
"e",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"\"Error, while executing command: \"",
"+",
"Arrays",
".",
"toString",
"(",
"command",
")",
"+",
"\"\\n\"",
",",
"e",
")",
";",
"}",
"cspath",
".",
"add",
"(",
"outputFilename",
")",
";",
"}",
"try",
"{",
"FileComparer",
".",
"removeSimilaritiesAndSaveFiles",
"(",
"cspath",
",",
"getLog",
"(",
")",
",",
"windowsModus",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"\"It was not possible, to remove similarities form the files\"",
",",
"e",
")",
";",
"}",
"}"
] | Search for the wsdl command and execute it when it is found | [
"Search",
"for",
"the",
"wsdl",
"command",
"and",
"execute",
"it",
"when",
"it",
"is",
"found"
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/tooling/wsdl2dll/src/main/java/org/openengsb/loom/csharp/comon/wsdltodll/WsdlToDll.java#L372-L402 | train |
openengsb/openengsb | tooling/wsdl2dll/src/main/java/org/openengsb/loom/csharp/comon/wsdltodll/WsdlToDll.java | WsdlToDll.cscCommand | private void cscCommand() throws MojoExecutionException {
generateAssemblyInfo();
String cscPath = findCscCommand();
List<String> commandList = new LinkedList<String>(cspath);
commandList.add(0, cscPath);
commandList.add(1, "/target:library");
commandList.add(2, "/out:" + namespace + ".dll");
if (isLinux()) {
commandList.add(3, "/reference:System.Web.Services");
}
String[] command = commandList.toArray(new String[commandList.size()]);
ProcessBuilder builder = new ProcessBuilder();
builder.redirectErrorStream(true);
builder.directory(outputDirectory);
builder.command(command);
try {
executeACommand(builder.start());
} catch (InterruptedException | IOException e) {
throw new MojoExecutionException("Error, while executing command: "
+ Arrays.toString(command) + "\n", e);
}
} | java | private void cscCommand() throws MojoExecutionException {
generateAssemblyInfo();
String cscPath = findCscCommand();
List<String> commandList = new LinkedList<String>(cspath);
commandList.add(0, cscPath);
commandList.add(1, "/target:library");
commandList.add(2, "/out:" + namespace + ".dll");
if (isLinux()) {
commandList.add(3, "/reference:System.Web.Services");
}
String[] command = commandList.toArray(new String[commandList.size()]);
ProcessBuilder builder = new ProcessBuilder();
builder.redirectErrorStream(true);
builder.directory(outputDirectory);
builder.command(command);
try {
executeACommand(builder.start());
} catch (InterruptedException | IOException e) {
throw new MojoExecutionException("Error, while executing command: "
+ Arrays.toString(command) + "\n", e);
}
} | [
"private",
"void",
"cscCommand",
"(",
")",
"throws",
"MojoExecutionException",
"{",
"generateAssemblyInfo",
"(",
")",
";",
"String",
"cscPath",
"=",
"findCscCommand",
"(",
")",
";",
"List",
"<",
"String",
">",
"commandList",
"=",
"new",
"LinkedList",
"<",
"String",
">",
"(",
"cspath",
")",
";",
"commandList",
".",
"add",
"(",
"0",
",",
"cscPath",
")",
";",
"commandList",
".",
"add",
"(",
"1",
",",
"\"/target:library\"",
")",
";",
"commandList",
".",
"add",
"(",
"2",
",",
"\"/out:\"",
"+",
"namespace",
"+",
"\".dll\"",
")",
";",
"if",
"(",
"isLinux",
"(",
")",
")",
"{",
"commandList",
".",
"add",
"(",
"3",
",",
"\"/reference:System.Web.Services\"",
")",
";",
"}",
"String",
"[",
"]",
"command",
"=",
"commandList",
".",
"toArray",
"(",
"new",
"String",
"[",
"commandList",
".",
"size",
"(",
")",
"]",
")",
";",
"ProcessBuilder",
"builder",
"=",
"new",
"ProcessBuilder",
"(",
")",
";",
"builder",
".",
"redirectErrorStream",
"(",
"true",
")",
";",
"builder",
".",
"directory",
"(",
"outputDirectory",
")",
";",
"builder",
".",
"command",
"(",
"command",
")",
";",
"try",
"{",
"executeACommand",
"(",
"builder",
".",
"start",
"(",
")",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"|",
"IOException",
"e",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"\"Error, while executing command: \"",
"+",
"Arrays",
".",
"toString",
"(",
"command",
")",
"+",
"\"\\n\"",
",",
"e",
")",
";",
"}",
"}"
] | Search for the csc command and execute it when it is found | [
"Search",
"for",
"the",
"csc",
"command",
"and",
"execute",
"it",
"when",
"it",
"is",
"found"
] | d39058000707f617cd405629f9bc7f17da7b414a | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/tooling/wsdl2dll/src/main/java/org/openengsb/loom/csharp/comon/wsdltodll/WsdlToDll.java#L407-L428 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.