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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
libgdx/box2dlights | src/box2dLight/Light.java | Light.remove | public void remove(boolean doDispose) {
if (active) {
rayHandler.lightList.removeValue(this, false);
} else {
rayHandler.disabledLights.removeValue(this, false);
}
rayHandler = null;
if (doDispose) dispose();
} | java | public void remove(boolean doDispose) {
if (active) {
rayHandler.lightList.removeValue(this, false);
} else {
rayHandler.disabledLights.removeValue(this, false);
}
rayHandler = null;
if (doDispose) dispose();
} | [
"public",
"void",
"remove",
"(",
"boolean",
"doDispose",
")",
"{",
"if",
"(",
"active",
")",
"{",
"rayHandler",
".",
"lightList",
".",
"removeValue",
"(",
"this",
",",
"false",
")",
";",
"}",
"else",
"{",
"rayHandler",
".",
"disabledLights",
".",
"remove... | Removes light from specified RayHandler and disposes it if requested | [
"Removes",
"light",
"from",
"specified",
"RayHandler",
"and",
"disposes",
"it",
"if",
"requested"
] | 08cf93a41464f71d32475aaa2fe280dc6af78ff3 | https://github.com/libgdx/box2dlights/blob/08cf93a41464f71d32475aaa2fe280dc6af78ff3/src/box2dLight/Light.java#L219-L227 | train |
libgdx/box2dlights | src/box2dLight/Light.java | Light.setRayNum | void setRayNum(int rays) {
if (rays < MIN_RAYS)
rays = MIN_RAYS;
rayNum = rays;
vertexNum = rays + 1;
segments = new float[vertexNum * 8];
mx = new float[vertexNum];
my = new float[vertexNum];
f = new float[vertexNum];
} | java | void setRayNum(int rays) {
if (rays < MIN_RAYS)
rays = MIN_RAYS;
rayNum = rays;
vertexNum = rays + 1;
segments = new float[vertexNum * 8];
mx = new float[vertexNum];
my = new float[vertexNum];
f = new float[vertexNum];
} | [
"void",
"setRayNum",
"(",
"int",
"rays",
")",
"{",
"if",
"(",
"rays",
"<",
"MIN_RAYS",
")",
"rays",
"=",
"MIN_RAYS",
";",
"rayNum",
"=",
"rays",
";",
"vertexNum",
"=",
"rays",
"+",
"1",
";",
"segments",
"=",
"new",
"float",
"[",
"vertexNum",
"*",
"... | Internal method for mesh update depending on ray number | [
"Internal",
"method",
"for",
"mesh",
"update",
"depending",
"on",
"ray",
"number"
] | 08cf93a41464f71d32475aaa2fe280dc6af78ff3 | https://github.com/libgdx/box2dlights/blob/08cf93a41464f71d32475aaa2fe280dc6af78ff3/src/box2dLight/Light.java#L395-L406 | train |
libgdx/box2dlights | src/box2dLight/Light.java | Light.setContactFilter | public void setContactFilter(short categoryBits, short groupIndex,
short maskBits) {
filterA = new Filter();
filterA.categoryBits = categoryBits;
filterA.groupIndex = groupIndex;
filterA.maskBits = maskBits;
} | java | public void setContactFilter(short categoryBits, short groupIndex,
short maskBits) {
filterA = new Filter();
filterA.categoryBits = categoryBits;
filterA.groupIndex = groupIndex;
filterA.maskBits = maskBits;
} | [
"public",
"void",
"setContactFilter",
"(",
"short",
"categoryBits",
",",
"short",
"groupIndex",
",",
"short",
"maskBits",
")",
"{",
"filterA",
"=",
"new",
"Filter",
"(",
")",
";",
"filterA",
".",
"categoryBits",
"=",
"categoryBits",
";",
"filterA",
".",
"gro... | Creates new contact filter for this light with given parameters
@param categoryBits - see {@link Filter#categoryBits}
@param groupIndex - see {@link Filter#groupIndex}
@param maskBits - see {@link Filter#maskBits} | [
"Creates",
"new",
"contact",
"filter",
"for",
"this",
"light",
"with",
"given",
"parameters"
] | 08cf93a41464f71d32475aaa2fe280dc6af78ff3 | https://github.com/libgdx/box2dlights/blob/08cf93a41464f71d32475aaa2fe280dc6af78ff3/src/box2dLight/Light.java#L470-L476 | train |
libgdx/box2dlights | src/box2dLight/Light.java | Light.setGlobalContactFilter | static public void setGlobalContactFilter(short categoryBits, short groupIndex,
short maskBits) {
globalFilterA = new Filter();
globalFilterA.categoryBits = categoryBits;
globalFilterA.groupIndex = groupIndex;
globalFilterA.maskBits = maskBits;
} | java | static public void setGlobalContactFilter(short categoryBits, short groupIndex,
short maskBits) {
globalFilterA = new Filter();
globalFilterA.categoryBits = categoryBits;
globalFilterA.groupIndex = groupIndex;
globalFilterA.maskBits = maskBits;
} | [
"static",
"public",
"void",
"setGlobalContactFilter",
"(",
"short",
"categoryBits",
",",
"short",
"groupIndex",
",",
"short",
"maskBits",
")",
"{",
"globalFilterA",
"=",
"new",
"Filter",
"(",
")",
";",
"globalFilterA",
".",
"categoryBits",
"=",
"categoryBits",
"... | Creates new contact filter for ALL LIGHTS with give parameters
@param categoryBits - see {@link Filter#categoryBits}
@param groupIndex - see {@link Filter#groupIndex}
@param maskBits - see {@link Filter#maskBits} | [
"Creates",
"new",
"contact",
"filter",
"for",
"ALL",
"LIGHTS",
"with",
"give",
"parameters"
] | 08cf93a41464f71d32475aaa2fe280dc6af78ff3 | https://github.com/libgdx/box2dlights/blob/08cf93a41464f71d32475aaa2fe280dc6af78ff3/src/box2dLight/Light.java#L503-L509 | train |
libgdx/box2dlights | src/box2dLight/ChainLight.java | ChainLight.debugRender | public void debugRender(ShapeRenderer shapeRenderer) {
shapeRenderer.setColor(Color.YELLOW);
FloatArray vertices = Pools.obtain(FloatArray.class);
vertices.clear();
for (int i = 0; i < rayNum; i++) {
vertices.addAll(mx[i], my[i]);
}
for (int i = rayNum - 1; i > -1; i--) {
vertices.addAll(startX[i], startY[i]);
}
shapeRenderer.polygon(vertices.shrink());
Pools.free(vertices);
} | java | public void debugRender(ShapeRenderer shapeRenderer) {
shapeRenderer.setColor(Color.YELLOW);
FloatArray vertices = Pools.obtain(FloatArray.class);
vertices.clear();
for (int i = 0; i < rayNum; i++) {
vertices.addAll(mx[i], my[i]);
}
for (int i = rayNum - 1; i > -1; i--) {
vertices.addAll(startX[i], startY[i]);
}
shapeRenderer.polygon(vertices.shrink());
Pools.free(vertices);
} | [
"public",
"void",
"debugRender",
"(",
"ShapeRenderer",
"shapeRenderer",
")",
"{",
"shapeRenderer",
".",
"setColor",
"(",
"Color",
".",
"YELLOW",
")",
";",
"FloatArray",
"vertices",
"=",
"Pools",
".",
"obtain",
"(",
"FloatArray",
".",
"class",
")",
";",
"vert... | Draws a polygon, using ray start and end points as vertices | [
"Draws",
"a",
"polygon",
"using",
"ray",
"start",
"and",
"end",
"points",
"as",
"vertices"
] | 08cf93a41464f71d32475aaa2fe280dc6af78ff3 | https://github.com/libgdx/box2dlights/blob/08cf93a41464f71d32475aaa2fe280dc6af78ff3/src/box2dLight/ChainLight.java#L165-L177 | train |
libgdx/box2dlights | src/box2dLight/ChainLight.java | ChainLight.attachToBody | public void attachToBody(Body body, float degrees) {
this.body = body;
this.bodyPosition.set(body.getPosition());
bodyAngleOffset = MathUtils.degreesToRadians * degrees;
bodyAngle = body.getAngle();
applyAttachment();
if (staticLight) dirty = true;
} | java | public void attachToBody(Body body, float degrees) {
this.body = body;
this.bodyPosition.set(body.getPosition());
bodyAngleOffset = MathUtils.degreesToRadians * degrees;
bodyAngle = body.getAngle();
applyAttachment();
if (staticLight) dirty = true;
} | [
"public",
"void",
"attachToBody",
"(",
"Body",
"body",
",",
"float",
"degrees",
")",
"{",
"this",
".",
"body",
"=",
"body",
";",
"this",
".",
"bodyPosition",
".",
"set",
"(",
"body",
".",
"getPosition",
"(",
")",
")",
";",
"bodyAngleOffset",
"=",
"Math... | Attaches light to specified body with relative direction offset
@param body
that will be automatically followed, note that the body
rotation angle is taken into account for the light offset
and direction calculations
@param degrees
directional relative offset in degrees | [
"Attaches",
"light",
"to",
"specified",
"body",
"with",
"relative",
"direction",
"offset"
] | 08cf93a41464f71d32475aaa2fe280dc6af78ff3 | https://github.com/libgdx/box2dlights/blob/08cf93a41464f71d32475aaa2fe280dc6af78ff3/src/box2dLight/ChainLight.java#L194-L201 | train |
libgdx/box2dlights | src/box2dLight/ChainLight.java | ChainLight.applyAttachment | void applyAttachment() {
if (body == null || staticLight) return;
restorePosition.setToTranslation(bodyPosition);
rotateAroundZero.setToRotationRad(bodyAngle + bodyAngleOffset);
for (int i = 0; i < rayNum; i++) {
tmpVec.set(startX[i], startY[i]).mul(rotateAroundZero).mul(restorePosition);
startX[i] = tmpVec.x;
startY[i] = tmpVec.y;
tmpVec.set(endX[i], endY[i]).mul(rotateAroundZero).mul(restorePosition);
endX[i] = tmpVec.x;
endY[i] = tmpVec.y;
}
} | java | void applyAttachment() {
if (body == null || staticLight) return;
restorePosition.setToTranslation(bodyPosition);
rotateAroundZero.setToRotationRad(bodyAngle + bodyAngleOffset);
for (int i = 0; i < rayNum; i++) {
tmpVec.set(startX[i], startY[i]).mul(rotateAroundZero).mul(restorePosition);
startX[i] = tmpVec.x;
startY[i] = tmpVec.y;
tmpVec.set(endX[i], endY[i]).mul(rotateAroundZero).mul(restorePosition);
endX[i] = tmpVec.x;
endY[i] = tmpVec.y;
}
} | [
"void",
"applyAttachment",
"(",
")",
"{",
"if",
"(",
"body",
"==",
"null",
"||",
"staticLight",
")",
"return",
";",
"restorePosition",
".",
"setToTranslation",
"(",
"bodyPosition",
")",
";",
"rotateAroundZero",
".",
"setToRotationRad",
"(",
"bodyAngle",
"+",
"... | Applies attached body initial transform to all lights rays | [
"Applies",
"attached",
"body",
"initial",
"transform",
"to",
"all",
"lights",
"rays"
] | 08cf93a41464f71d32475aaa2fe280dc6af78ff3 | https://github.com/libgdx/box2dlights/blob/08cf93a41464f71d32475aaa2fe280dc6af78ff3/src/box2dLight/ChainLight.java#L390-L403 | train |
libgdx/box2dlights | src/box2dLight/PositionalLight.java | PositionalLight.attachToBody | public void attachToBody(Body body, float offsetX, float offSetY, float degrees) {
this.body = body;
bodyOffsetX = offsetX;
bodyOffsetY = offSetY;
bodyAngleOffset = degrees;
if (staticLight) dirty = true;
} | java | public void attachToBody(Body body, float offsetX, float offSetY, float degrees) {
this.body = body;
bodyOffsetX = offsetX;
bodyOffsetY = offSetY;
bodyAngleOffset = degrees;
if (staticLight) dirty = true;
} | [
"public",
"void",
"attachToBody",
"(",
"Body",
"body",
",",
"float",
"offsetX",
",",
"float",
"offSetY",
",",
"float",
"degrees",
")",
"{",
"this",
".",
"body",
"=",
"body",
";",
"bodyOffsetX",
"=",
"offsetX",
";",
"bodyOffsetY",
"=",
"offSetY",
";",
"bo... | Attaches light to specified body with relative offset and direction
@param body
that will be automatically followed, note that the body
rotation angle is taken into account for the light offset
and direction calculations
@param offsetX
horizontal relative offset in world coordinates
@param offsetY
vertical relative offset in world coordinates
@param degrees
directional relative offset in degrees | [
"Attaches",
"light",
"to",
"specified",
"body",
"with",
"relative",
"offset",
"and",
"direction"
] | 08cf93a41464f71d32475aaa2fe280dc6af78ff3 | https://github.com/libgdx/box2dlights/blob/08cf93a41464f71d32475aaa2fe280dc6af78ff3/src/box2dLight/PositionalLight.java#L135-L141 | train |
bit3/jsass | src/main/java/io/bit3/jsass/type/SassString.java | SassString.escape | public static String escape(String value, char quote) {
Map<CharSequence, CharSequence> lookupMap = new HashMap<>();
lookupMap.put(Character.toString(quote), "\\" + quote);
lookupMap.put("\\", "\\\\");
final CharSequenceTranslator escape =
new LookupTranslator(lookupMap)
.with(new LookupTranslator(EntityArrays.JAVA_CTRL_CHARS_ESCAPE))
.with(JavaUnicodeEscaper.outsideOf(32, 0x7f));
return quote + escape.translate(value) + quote;
} | java | public static String escape(String value, char quote) {
Map<CharSequence, CharSequence> lookupMap = new HashMap<>();
lookupMap.put(Character.toString(quote), "\\" + quote);
lookupMap.put("\\", "\\\\");
final CharSequenceTranslator escape =
new LookupTranslator(lookupMap)
.with(new LookupTranslator(EntityArrays.JAVA_CTRL_CHARS_ESCAPE))
.with(JavaUnicodeEscaper.outsideOf(32, 0x7f));
return quote + escape.translate(value) + quote;
} | [
"public",
"static",
"String",
"escape",
"(",
"String",
"value",
",",
"char",
"quote",
")",
"{",
"Map",
"<",
"CharSequence",
",",
"CharSequence",
">",
"lookupMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"lookupMap",
".",
"put",
"(",
"Character",
".",... | Escape the string with given quote character. | [
"Escape",
"the",
"string",
"with",
"given",
"quote",
"character",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/type/SassString.java#L136-L147 | train |
bit3/jsass | src/main/java/io/bit3/jsass/function/FunctionWrapperFactory.java | FunctionWrapperFactory.compileFunctions | public List<FunctionWrapper> compileFunctions(
ImportStack importStack, Context context, List<?> objects
) {
List<FunctionWrapper> callbacks = new LinkedList<>();
for (Object object : objects) {
List<FunctionWrapper> objectCallbacks = compileFunctions(importStack, context, object);
callbacks.addAll(objectCallbacks);
}
return callbacks;
} | java | public List<FunctionWrapper> compileFunctions(
ImportStack importStack, Context context, List<?> objects
) {
List<FunctionWrapper> callbacks = new LinkedList<>();
for (Object object : objects) {
List<FunctionWrapper> objectCallbacks = compileFunctions(importStack, context, object);
callbacks.addAll(objectCallbacks);
}
return callbacks;
} | [
"public",
"List",
"<",
"FunctionWrapper",
">",
"compileFunctions",
"(",
"ImportStack",
"importStack",
",",
"Context",
"context",
",",
"List",
"<",
"?",
">",
"objects",
")",
"{",
"List",
"<",
"FunctionWrapper",
">",
"callbacks",
"=",
"new",
"LinkedList",
"<>",
... | Compile methods from all objects into libsass functions.
@param importStack The import stack.
@param objects A list of "function provider" objects.
@return The newly created list of libsass callbacks. | [
"Compile",
"methods",
"from",
"all",
"objects",
"into",
"libsass",
"functions",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/function/FunctionWrapperFactory.java#L73-L85 | train |
bit3/jsass | src/main/java/io/bit3/jsass/function/FunctionWrapperFactory.java | FunctionWrapperFactory.compileFunctions | public List<FunctionWrapper> compileFunctions(
ImportStack importStack, Context context, Object object
) {
Class<?> functionClass = object.getClass();
Method[] methods = functionClass.getDeclaredMethods();
List<FunctionDeclaration> declarations = new LinkedList<>();
for (Method method : methods) {
int modifiers = method.getModifiers();
if (!Modifier.isPublic(modifiers)) {
continue;
}
FunctionDeclaration declaration = createDeclaration(importStack, context, object, method);
declarations.add(declaration);
}
return declarations.stream().map(FunctionWrapper::new).collect(Collectors.toList());
} | java | public List<FunctionWrapper> compileFunctions(
ImportStack importStack, Context context, Object object
) {
Class<?> functionClass = object.getClass();
Method[] methods = functionClass.getDeclaredMethods();
List<FunctionDeclaration> declarations = new LinkedList<>();
for (Method method : methods) {
int modifiers = method.getModifiers();
if (!Modifier.isPublic(modifiers)) {
continue;
}
FunctionDeclaration declaration = createDeclaration(importStack, context, object, method);
declarations.add(declaration);
}
return declarations.stream().map(FunctionWrapper::new).collect(Collectors.toList());
} | [
"public",
"List",
"<",
"FunctionWrapper",
">",
"compileFunctions",
"(",
"ImportStack",
"importStack",
",",
"Context",
"context",
",",
"Object",
"object",
")",
"{",
"Class",
"<",
"?",
">",
"functionClass",
"=",
"object",
".",
"getClass",
"(",
")",
";",
"Metho... | Compile methods from an object into libsass functions.
@param importStack The import stack.
@param object The "function provider" object.
@return The newly created list of libsass callbacks. | [
"Compile",
"methods",
"from",
"an",
"object",
"into",
"libsass",
"functions",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/function/FunctionWrapperFactory.java#L94-L113 | train |
bit3/jsass | src/main/java/io/bit3/jsass/function/FunctionWrapperFactory.java | FunctionWrapperFactory.createDeclaration | public FunctionDeclaration createDeclaration(
ImportStack importStack, Context context, Object object, Method method
) {
StringBuilder signature = new StringBuilder();
Parameter[] parameters = method.getParameters();
List<ArgumentConverter> argumentConverters = new ArrayList<>(method.getParameterCount());
signature.append(method.getName()).append("(");
int parameterCount = 0;
for (Parameter parameter : parameters) {
ArgumentConverter argumentConverter = createArgumentConverter(object, method, parameter);
argumentConverters.add(argumentConverter);
List<FunctionArgumentSignature> list = argumentConverter.argumentSignatures(
object,
method,
parameter,
functionArgumentSignatureFactory
);
for (FunctionArgumentSignature functionArgumentSignature : list) {
String name = functionArgumentSignature.getName();
Object defaultValue = functionArgumentSignature.getDefaultValue();
if (parameterCount > 0) {
signature.append(", ");
}
signature.append("$").append(name);
if (null != defaultValue) {
signature.append(": ").append(formatDefaultValue(defaultValue));
}
parameterCount++;
}
}
signature.append(")");
// Overwrite signature with special ones
if (method.isAnnotationPresent(WarnFunction.class)) {
signature.setLength(0);
signature.append("@warn");
} else if (method.isAnnotationPresent(ErrorFunction.class)) {
signature.setLength(0);
signature.append("@error");
} else if (method.isAnnotationPresent(DebugFunction.class)) {
signature.setLength(0);
signature.append("@debug");
}
return new FunctionDeclaration(
importStack,
context,
signature.toString(),
object,
method,
argumentConverters
);
} | java | public FunctionDeclaration createDeclaration(
ImportStack importStack, Context context, Object object, Method method
) {
StringBuilder signature = new StringBuilder();
Parameter[] parameters = method.getParameters();
List<ArgumentConverter> argumentConverters = new ArrayList<>(method.getParameterCount());
signature.append(method.getName()).append("(");
int parameterCount = 0;
for (Parameter parameter : parameters) {
ArgumentConverter argumentConverter = createArgumentConverter(object, method, parameter);
argumentConverters.add(argumentConverter);
List<FunctionArgumentSignature> list = argumentConverter.argumentSignatures(
object,
method,
parameter,
functionArgumentSignatureFactory
);
for (FunctionArgumentSignature functionArgumentSignature : list) {
String name = functionArgumentSignature.getName();
Object defaultValue = functionArgumentSignature.getDefaultValue();
if (parameterCount > 0) {
signature.append(", ");
}
signature.append("$").append(name);
if (null != defaultValue) {
signature.append(": ").append(formatDefaultValue(defaultValue));
}
parameterCount++;
}
}
signature.append(")");
// Overwrite signature with special ones
if (method.isAnnotationPresent(WarnFunction.class)) {
signature.setLength(0);
signature.append("@warn");
} else if (method.isAnnotationPresent(ErrorFunction.class)) {
signature.setLength(0);
signature.append("@error");
} else if (method.isAnnotationPresent(DebugFunction.class)) {
signature.setLength(0);
signature.append("@debug");
}
return new FunctionDeclaration(
importStack,
context,
signature.toString(),
object,
method,
argumentConverters
);
} | [
"public",
"FunctionDeclaration",
"createDeclaration",
"(",
"ImportStack",
"importStack",
",",
"Context",
"context",
",",
"Object",
"object",
",",
"Method",
"method",
")",
"{",
"StringBuilder",
"signature",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"Parameter",
"... | Create a function declaration from an object method.
@param importStack The import stack.
@param object The object.
@param method The method.
@return The newly created function declaration. | [
"Create",
"a",
"function",
"declaration",
"from",
"an",
"object",
"method",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/function/FunctionWrapperFactory.java#L123-L185 | train |
bit3/jsass | src/main/java/io/bit3/jsass/function/FunctionWrapperFactory.java | FunctionWrapperFactory.formatDefaultValue | private String formatDefaultValue(Object value) {
if (value instanceof Boolean) {
return ((Boolean) value) ? "true" : "false";
}
if (value instanceof Number) {
return value.toString();
}
if (value instanceof Collection) {
return formatCollectionValue((Collection) value);
}
String string = value.toString();
if (string.startsWith("$")) {
return string;
}
return SassString.escape(string);
} | java | private String formatDefaultValue(Object value) {
if (value instanceof Boolean) {
return ((Boolean) value) ? "true" : "false";
}
if (value instanceof Number) {
return value.toString();
}
if (value instanceof Collection) {
return formatCollectionValue((Collection) value);
}
String string = value.toString();
if (string.startsWith("$")) {
return string;
}
return SassString.escape(string);
} | [
"private",
"String",
"formatDefaultValue",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"instanceof",
"Boolean",
")",
"{",
"return",
"(",
"(",
"Boolean",
")",
"value",
")",
"?",
"\"true\"",
":",
"\"false\"",
";",
"}",
"if",
"(",
"value",
"instan... | Format a default value for libsass function signature.
@param value The default value.
@return The formated default value. | [
"Format",
"a",
"default",
"value",
"for",
"libsass",
"function",
"signature",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/function/FunctionWrapperFactory.java#L193-L213 | train |
bit3/jsass | src/main/java/io/bit3/jsass/function/FunctionDeclaration.java | FunctionDeclaration.invoke | public SassValue invoke(List<?> arguments) {
try {
ArrayList<Object> values = new ArrayList<>(argumentConverters.size());
for (ArgumentConverter argumentConverter : argumentConverters) {
Object value = argumentConverter.convert(arguments, importStack, context);
values.add(value);
}
Object result = method.invoke(object, values.toArray());
return TypeUtils.convertToSassValue(result);
} catch (Throwable throwable) {
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
String message = throwable.getMessage();
if (StringUtils.isNotEmpty(message)) {
printWriter.append(message).append(System.lineSeparator());
}
throwable.printStackTrace(printWriter);
return new SassError(stringWriter.toString());
}
} | java | public SassValue invoke(List<?> arguments) {
try {
ArrayList<Object> values = new ArrayList<>(argumentConverters.size());
for (ArgumentConverter argumentConverter : argumentConverters) {
Object value = argumentConverter.convert(arguments, importStack, context);
values.add(value);
}
Object result = method.invoke(object, values.toArray());
return TypeUtils.convertToSassValue(result);
} catch (Throwable throwable) {
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
String message = throwable.getMessage();
if (StringUtils.isNotEmpty(message)) {
printWriter.append(message).append(System.lineSeparator());
}
throwable.printStackTrace(printWriter);
return new SassError(stringWriter.toString());
}
} | [
"public",
"SassValue",
"invoke",
"(",
"List",
"<",
"?",
">",
"arguments",
")",
"{",
"try",
"{",
"ArrayList",
"<",
"Object",
">",
"values",
"=",
"new",
"ArrayList",
"<>",
"(",
"argumentConverters",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"ArgumentC... | Invoke the method with the given list of arguments.
<p>This will convert the libsass arguments into java value.</p>
@param arguments List of libsass arguments.
@return The method result. | [
"Invoke",
"the",
"method",
"with",
"the",
"given",
"list",
"of",
"arguments",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/function/FunctionDeclaration.java#L115-L139 | train |
bit3/jsass | src/main/java/io/bit3/jsass/Compiler.java | Compiler.compileFile | public Output compileFile(URI inputPath, URI outputPath, Options options)
throws CompilationException {
FileContext context = new FileContext(inputPath, outputPath, options);
return compile(context);
} | java | public Output compileFile(URI inputPath, URI outputPath, Options options)
throws CompilationException {
FileContext context = new FileContext(inputPath, outputPath, options);
return compile(context);
} | [
"public",
"Output",
"compileFile",
"(",
"URI",
"inputPath",
",",
"URI",
"outputPath",
",",
"Options",
"options",
")",
"throws",
"CompilationException",
"{",
"FileContext",
"context",
"=",
"new",
"FileContext",
"(",
"inputPath",
",",
"outputPath",
",",
"options",
... | Compile file.
@param inputPath The input path.
@param outputPath The output path.
@param options The compile options.
@return The compilation output.
@throws CompilationException If the compilation failed. | [
"Compile",
"file",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/Compiler.java#L76-L80 | train |
bit3/jsass | src/main/java/io/bit3/jsass/Compiler.java | Compiler.compile | public Output compile(Context context) throws CompilationException {
Objects.requireNonNull(context, "Parameter context must not be null");
if (context instanceof FileContext) {
return compile((FileContext) context);
}
if (context instanceof StringContext) {
return compile((StringContext) context);
}
throw new UnsupportedContextException(context);
} | java | public Output compile(Context context) throws CompilationException {
Objects.requireNonNull(context, "Parameter context must not be null");
if (context instanceof FileContext) {
return compile((FileContext) context);
}
if (context instanceof StringContext) {
return compile((StringContext) context);
}
throw new UnsupportedContextException(context);
} | [
"public",
"Output",
"compile",
"(",
"Context",
"context",
")",
"throws",
"CompilationException",
"{",
"Objects",
".",
"requireNonNull",
"(",
"context",
",",
"\"Parameter context must not be null\"",
")",
";",
"if",
"(",
"context",
"instanceof",
"FileContext",
")",
"... | Compile context.
@param context The context.
@return The compilation output.
@throws UnsupportedContextException If the given context is not supported.
@throws CompilationException If the compilation failed. | [
"Compile",
"context",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/Compiler.java#L90-L102 | train |
bit3/jsass | src/main/java/io/bit3/jsass/function/FunctionArgumentSignatureFactory.java | FunctionArgumentSignatureFactory.createDefaultArgumentSignature | public List<FunctionArgumentSignature> createDefaultArgumentSignature(Parameter parameter) {
List<FunctionArgumentSignature> list = new LinkedList<>();
String name = getParameterName(parameter);
Object defaultValue = getDefaultValue(parameter);
list.add(new FunctionArgumentSignature(name, defaultValue));
return list;
} | java | public List<FunctionArgumentSignature> createDefaultArgumentSignature(Parameter parameter) {
List<FunctionArgumentSignature> list = new LinkedList<>();
String name = getParameterName(parameter);
Object defaultValue = getDefaultValue(parameter);
list.add(new FunctionArgumentSignature(name, defaultValue));
return list;
} | [
"public",
"List",
"<",
"FunctionArgumentSignature",
">",
"createDefaultArgumentSignature",
"(",
"Parameter",
"parameter",
")",
"{",
"List",
"<",
"FunctionArgumentSignature",
">",
"list",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"String",
"name",
"=",
"getPar... | Create a new factory. | [
"Create",
"a",
"new",
"factory",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/function/FunctionArgumentSignatureFactory.java#L24-L32 | train |
bit3/jsass | src/main/java/io/bit3/jsass/function/FunctionArgumentSignatureFactory.java | FunctionArgumentSignatureFactory.getParameterName | public String getParameterName(Parameter parameter) {
Name annotation = parameter.getAnnotation(Name.class);
if (null == annotation) {
return parameter.getName();
}
return annotation.value();
} | java | public String getParameterName(Parameter parameter) {
Name annotation = parameter.getAnnotation(Name.class);
if (null == annotation) {
return parameter.getName();
}
return annotation.value();
} | [
"public",
"String",
"getParameterName",
"(",
"Parameter",
"parameter",
")",
"{",
"Name",
"annotation",
"=",
"parameter",
".",
"getAnnotation",
"(",
"Name",
".",
"class",
")",
";",
"if",
"(",
"null",
"==",
"annotation",
")",
"{",
"return",
"parameter",
".",
... | Determine annotated name of a method parameter.
@param parameter The method parameter.
@return The parameters name. | [
"Determine",
"annotated",
"name",
"of",
"a",
"method",
"parameter",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/function/FunctionArgumentSignatureFactory.java#L40-L48 | train |
bit3/jsass | src/main/java/io/bit3/jsass/function/FunctionArgumentSignatureFactory.java | FunctionArgumentSignatureFactory.getDefaultValue | public Object getDefaultValue(Parameter parameter) {
Class<?> type = parameter.getType();
if (TypeUtils.isaString(type)) {
return getStringDefaultValue(parameter);
}
if (TypeUtils.isaByte(type)) {
return getByteDefaultValue(parameter);
}
if (TypeUtils.isaShort(type)) {
return getShortDefaultValue(parameter);
}
if (TypeUtils.isaInteger(type)) {
return getIntegerDefaultValue(parameter);
}
if (TypeUtils.isaLong(type)) {
return getLongDefaultValue(parameter);
}
if (TypeUtils.isaFloat(type)) {
return getFloatDefaultValue(parameter);
}
if (TypeUtils.isaDouble(type)) {
return getDoubleDefaultValue(parameter);
}
if (TypeUtils.isaCharacter(type)) {
return getCharacterDefaultValue(parameter);
}
if (TypeUtils.isaBoolean(type)) {
return getBooleanDefaultValue(parameter);
}
return null;
} | java | public Object getDefaultValue(Parameter parameter) {
Class<?> type = parameter.getType();
if (TypeUtils.isaString(type)) {
return getStringDefaultValue(parameter);
}
if (TypeUtils.isaByte(type)) {
return getByteDefaultValue(parameter);
}
if (TypeUtils.isaShort(type)) {
return getShortDefaultValue(parameter);
}
if (TypeUtils.isaInteger(type)) {
return getIntegerDefaultValue(parameter);
}
if (TypeUtils.isaLong(type)) {
return getLongDefaultValue(parameter);
}
if (TypeUtils.isaFloat(type)) {
return getFloatDefaultValue(parameter);
}
if (TypeUtils.isaDouble(type)) {
return getDoubleDefaultValue(parameter);
}
if (TypeUtils.isaCharacter(type)) {
return getCharacterDefaultValue(parameter);
}
if (TypeUtils.isaBoolean(type)) {
return getBooleanDefaultValue(parameter);
}
return null;
} | [
"public",
"Object",
"getDefaultValue",
"(",
"Parameter",
"parameter",
")",
"{",
"Class",
"<",
"?",
">",
"type",
"=",
"parameter",
".",
"getType",
"(",
")",
";",
"if",
"(",
"TypeUtils",
".",
"isaString",
"(",
"type",
")",
")",
"{",
"return",
"getStringDef... | Determine annotated default parameter value.
@param parameter The method parameter.
@return The parameters default value. | [
"Determine",
"annotated",
"default",
"parameter",
"value",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/function/FunctionArgumentSignatureFactory.java#L56-L96 | train |
bit3/jsass | src/main/java/io/bit3/jsass/context/ImportStack.java | ImportStack.register | public int register(Import importSource) {
int id = registry.size() + 1;
registry.put(id, importSource);
return id;
} | java | public int register(Import importSource) {
int id = registry.size() + 1;
registry.put(id, importSource);
return id;
} | [
"public",
"int",
"register",
"(",
"Import",
"importSource",
")",
"{",
"int",
"id",
"=",
"registry",
".",
"size",
"(",
")",
"+",
"1",
";",
"registry",
".",
"put",
"(",
"id",
",",
"importSource",
")",
";",
"return",
"id",
";",
"}"
] | Register a new import, return the registration ID. | [
"Register",
"a",
"new",
"import",
"return",
"the",
"registration",
"ID",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/context/ImportStack.java#L28-L32 | train |
bit3/jsass | src/main/java/io/bit3/jsass/type/TypeUtils.java | TypeUtils.convertToSassValue | public static SassValue convertToSassValue(Object value) {
if (null == value) {
return SassNull.SINGLETON;
}
if (value instanceof SassValue) {
return (SassValue) value;
}
Class cls = value.getClass();
if (isaBoolean(cls)) {
return new SassBoolean((Boolean) value);
}
if (isaNumber(cls)) {
return new SassNumber(((Number) value).doubleValue(), "");
}
if (isaString(cls) || isaCharacter(cls)) {
return new SassString(value.toString());
}
if (value instanceof Collection) {
return new SassList(
((Collection<?>) value)
.stream()
.map(TypeUtils::convertToSassValue)
.collect(Collectors.toList())
);
}
if (value instanceof Map) {
return ((Map<?, ?>) value).entrySet()
.stream()
.collect(Collectors.toMap(
entry -> entry.getKey().toString(),
entry -> TypeUtils.convertToSassValue(entry.getValue()),
(origin, duplicate) -> origin,
SassMap::new
));
}
if (value instanceof Throwable) {
Throwable throwable = (Throwable) value;
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
String message = throwable.getMessage();
if (StringUtils.isNotEmpty(message)) {
printWriter.append(message).append(System.lineSeparator());
}
throwable.printStackTrace(printWriter);
return new SassError(stringWriter.toString());
}
return new SassError(
String.format(
"Could not convert object of type %s into a sass value",
value.getClass().toString()
)
);
} | java | public static SassValue convertToSassValue(Object value) {
if (null == value) {
return SassNull.SINGLETON;
}
if (value instanceof SassValue) {
return (SassValue) value;
}
Class cls = value.getClass();
if (isaBoolean(cls)) {
return new SassBoolean((Boolean) value);
}
if (isaNumber(cls)) {
return new SassNumber(((Number) value).doubleValue(), "");
}
if (isaString(cls) || isaCharacter(cls)) {
return new SassString(value.toString());
}
if (value instanceof Collection) {
return new SassList(
((Collection<?>) value)
.stream()
.map(TypeUtils::convertToSassValue)
.collect(Collectors.toList())
);
}
if (value instanceof Map) {
return ((Map<?, ?>) value).entrySet()
.stream()
.collect(Collectors.toMap(
entry -> entry.getKey().toString(),
entry -> TypeUtils.convertToSassValue(entry.getValue()),
(origin, duplicate) -> origin,
SassMap::new
));
}
if (value instanceof Throwable) {
Throwable throwable = (Throwable) value;
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
String message = throwable.getMessage();
if (StringUtils.isNotEmpty(message)) {
printWriter.append(message).append(System.lineSeparator());
}
throwable.printStackTrace(printWriter);
return new SassError(stringWriter.toString());
}
return new SassError(
String.format(
"Could not convert object of type %s into a sass value",
value.getClass().toString()
)
);
} | [
"public",
"static",
"SassValue",
"convertToSassValue",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"null",
"==",
"value",
")",
"{",
"return",
"SassNull",
".",
"SINGLETON",
";",
"}",
"if",
"(",
"value",
"instanceof",
"SassValue",
")",
"{",
"return",
"(",
... | Try to convert "any" java object into a responsible sass value. | [
"Try",
"to",
"convert",
"any",
"java",
"object",
"into",
"a",
"responsible",
"sass",
"value",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/type/TypeUtils.java#L21-L84 | train |
bit3/jsass | example/webapp/src/main/java/io/bit3/jsass/example/webapp/JsassServlet.java | JsassServlet.resolveImport | private Collection<Import> resolveImport(Path path) throws IOException, URISyntaxException {
URL resource = resolveResource(path);
if (null == resource) {
return null;
}
// calculate a webapp absolute URI
final URI uri = new URI(
Paths.get("/").resolve(
Paths.get(getServletContext().getResource("/").toURI()).relativize(Paths.get(resource.toURI()))
).toString()
);
final String source = IOUtils.toString(resource, StandardCharsets.UTF_8);
final Import scssImport = new Import(uri, uri, source);
return Collections.singleton(scssImport);
} | java | private Collection<Import> resolveImport(Path path) throws IOException, URISyntaxException {
URL resource = resolveResource(path);
if (null == resource) {
return null;
}
// calculate a webapp absolute URI
final URI uri = new URI(
Paths.get("/").resolve(
Paths.get(getServletContext().getResource("/").toURI()).relativize(Paths.get(resource.toURI()))
).toString()
);
final String source = IOUtils.toString(resource, StandardCharsets.UTF_8);
final Import scssImport = new Import(uri, uri, source);
return Collections.singleton(scssImport);
} | [
"private",
"Collection",
"<",
"Import",
">",
"resolveImport",
"(",
"Path",
"path",
")",
"throws",
"IOException",
",",
"URISyntaxException",
"{",
"URL",
"resource",
"=",
"resolveResource",
"(",
"path",
")",
";",
"if",
"(",
"null",
"==",
"resource",
")",
"{",
... | Try to determine the import object for a given path.
@param path The path to resolve.
@return The import object or {@code null} if the file was not found. | [
"Try",
"to",
"determine",
"the",
"import",
"object",
"for",
"a",
"given",
"path",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/example/webapp/src/main/java/io/bit3/jsass/example/webapp/JsassServlet.java#L139-L156 | train |
bit3/jsass | example/webapp/src/main/java/io/bit3/jsass/example/webapp/JsassServlet.java | JsassServlet.resolveResource | private URL resolveResource(Path path) throws MalformedURLException {
final Path dir = path.getParent();
final String basename = path.getFileName().toString();
for (String prefix : new String[]{"_", ""}) {
for (String suffix : new String[]{".scss", ".css", ""}) {
final Path target = dir.resolve(prefix + basename + suffix);
final URL resource = getServletContext().getResource(target.toString());
if (null != resource) {
return resource;
}
}
}
return null;
} | java | private URL resolveResource(Path path) throws MalformedURLException {
final Path dir = path.getParent();
final String basename = path.getFileName().toString();
for (String prefix : new String[]{"_", ""}) {
for (String suffix : new String[]{".scss", ".css", ""}) {
final Path target = dir.resolve(prefix + basename + suffix);
final URL resource = getServletContext().getResource(target.toString());
if (null != resource) {
return resource;
}
}
}
return null;
} | [
"private",
"URL",
"resolveResource",
"(",
"Path",
"path",
")",
"throws",
"MalformedURLException",
"{",
"final",
"Path",
"dir",
"=",
"path",
".",
"getParent",
"(",
")",
";",
"final",
"String",
"basename",
"=",
"path",
".",
"getFileName",
"(",
")",
".",
"toS... | Try to find a resource for this path.
<p>A sass import like {@code @import "foo"} does not contain the partial prefix (underscore) or file extension.
This method will try the following namings to find the import file {@code foo}:</p>
<ul>
<li>_foo.scss</li>
<li>_foo.css</li>
<li>_foo</li>
<li>foo.scss</li>
<li>foo.css</li>
<li>foo</li>
</ul>
@param path The path to resolve.
@return The resource URL of the resolved file or {@code null} if the file was not found. | [
"Try",
"to",
"find",
"a",
"resource",
"for",
"this",
"path",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/example/webapp/src/main/java/io/bit3/jsass/example/webapp/JsassServlet.java#L176-L192 | train |
bit3/jsass | src/main/java/io/bit3/jsass/function/FunctionWrapper.java | FunctionWrapper.apply | public SassValue apply(SassValue value) {
SassList sassList;
if (value instanceof SassList) {
sassList = (SassList) value;
} else {
sassList = new SassList();
sassList.add(value);
}
return declaration.invoke(sassList);
} | java | public SassValue apply(SassValue value) {
SassList sassList;
if (value instanceof SassList) {
sassList = (SassList) value;
} else {
sassList = new SassList();
sassList.add(value);
}
return declaration.invoke(sassList);
} | [
"public",
"SassValue",
"apply",
"(",
"SassValue",
"value",
")",
"{",
"SassList",
"sassList",
";",
"if",
"(",
"value",
"instanceof",
"SassList",
")",
"{",
"sassList",
"=",
"(",
"SassList",
")",
"value",
";",
"}",
"else",
"{",
"sassList",
"=",
"new",
"Sass... | Call the function. | [
"Call",
"the",
"function",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/function/FunctionWrapper.java#L32-L43 | train |
bit3/jsass | src/main/java/io/bit3/jsass/adapter/NativeLoader.java | NativeLoader.loadLibrary | static void loadLibrary() {
try {
File dir = Files.createTempDirectory("libjsass-").toFile();
dir.deleteOnExit();
if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
System.load(saveLibrary(dir, "sass"));
}
System.load(saveLibrary(dir, "jsass"));
} catch (Exception exception) {
LOG.warn(exception.getMessage(), exception);
throw new LoaderException(exception);
}
} | java | static void loadLibrary() {
try {
File dir = Files.createTempDirectory("libjsass-").toFile();
dir.deleteOnExit();
if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
System.load(saveLibrary(dir, "sass"));
}
System.load(saveLibrary(dir, "jsass"));
} catch (Exception exception) {
LOG.warn(exception.getMessage(), exception);
throw new LoaderException(exception);
}
} | [
"static",
"void",
"loadLibrary",
"(",
")",
"{",
"try",
"{",
"File",
"dir",
"=",
"Files",
".",
"createTempDirectory",
"(",
"\"libjsass-\"",
")",
".",
"toFile",
"(",
")",
";",
"dir",
".",
"deleteOnExit",
"(",
")",
";",
"if",
"(",
"System",
".",
"getPrope... | Load the shared libraries. | [
"Load",
"the",
"shared",
"libraries",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/adapter/NativeLoader.java#L39-L53 | train |
bit3/jsass | src/main/java/io/bit3/jsass/adapter/NativeLoader.java | NativeLoader.findLibraryResource | private static URL findLibraryResource(final String libraryFileName) {
String osName = System.getProperty("os.name").toLowerCase();
String osArch = System.getProperty("os.arch").toLowerCase();
String resourceName = null;
LOG.trace("Load library \"{}\" for os {}:{}", libraryFileName, osName, osArch);
if (osName.startsWith(OS_WIN)) {
resourceName = determineWindowsLibrary(libraryFileName, osName, osArch);
} else if (osName.startsWith(OS_LINUX)) {
resourceName = determineLinuxLibrary(libraryFileName, osName, osArch);
} else if (osName.startsWith(OS_FREEBSD)) {
resourceName = determineFreebsdLibrary(libraryFileName, osName, osArch);
} else if (osName.startsWith(OS_MAC)) {
resourceName = determineMacLibrary(libraryFileName);
} else {
unsupportedPlatform(osName, osArch);
}
URL resource = NativeLoader.class.getResource(resourceName);
if (null == resource) {
unsupportedPlatform(osName, osArch, resourceName);
}
return resource;
} | java | private static URL findLibraryResource(final String libraryFileName) {
String osName = System.getProperty("os.name").toLowerCase();
String osArch = System.getProperty("os.arch").toLowerCase();
String resourceName = null;
LOG.trace("Load library \"{}\" for os {}:{}", libraryFileName, osName, osArch);
if (osName.startsWith(OS_WIN)) {
resourceName = determineWindowsLibrary(libraryFileName, osName, osArch);
} else if (osName.startsWith(OS_LINUX)) {
resourceName = determineLinuxLibrary(libraryFileName, osName, osArch);
} else if (osName.startsWith(OS_FREEBSD)) {
resourceName = determineFreebsdLibrary(libraryFileName, osName, osArch);
} else if (osName.startsWith(OS_MAC)) {
resourceName = determineMacLibrary(libraryFileName);
} else {
unsupportedPlatform(osName, osArch);
}
URL resource = NativeLoader.class.getResource(resourceName);
if (null == resource) {
unsupportedPlatform(osName, osArch, resourceName);
}
return resource;
} | [
"private",
"static",
"URL",
"findLibraryResource",
"(",
"final",
"String",
"libraryFileName",
")",
"{",
"String",
"osName",
"=",
"System",
".",
"getProperty",
"(",
"\"os.name\"",
")",
".",
"toLowerCase",
"(",
")",
";",
"String",
"osArch",
"=",
"System",
".",
... | Find the right shared library, depending on the operating system and architecture.
@throws UnsupportedOperationException Throw an exception if no native library for this platform
was found. | [
"Find",
"the",
"right",
"shared",
"library",
"depending",
"on",
"the",
"operating",
"system",
"and",
"architecture",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/adapter/NativeLoader.java#L61-L87 | train |
bit3/jsass | src/main/java/io/bit3/jsass/adapter/NativeLoader.java | NativeLoader.determineWindowsLibrary | private static String determineWindowsLibrary(
final String library,
final String osName,
final String osArch
) {
String resourceName;
String platform;
String fileExtension = "dll";
switch (osArch) {
case ARCH_AMD64:
case ARCH_X86_64:
platform = "windows-x64";
break;
default:
throw new UnsupportedOperationException(
"Platform " + osName + ":" + osArch + " not supported"
);
}
resourceName = "/" + platform + "/" + library + "." + fileExtension;
return resourceName;
} | java | private static String determineWindowsLibrary(
final String library,
final String osName,
final String osArch
) {
String resourceName;
String platform;
String fileExtension = "dll";
switch (osArch) {
case ARCH_AMD64:
case ARCH_X86_64:
platform = "windows-x64";
break;
default:
throw new UnsupportedOperationException(
"Platform " + osName + ":" + osArch + " not supported"
);
}
resourceName = "/" + platform + "/" + library + "." + fileExtension;
return resourceName;
} | [
"private",
"static",
"String",
"determineWindowsLibrary",
"(",
"final",
"String",
"library",
",",
"final",
"String",
"osName",
",",
"final",
"String",
"osArch",
")",
"{",
"String",
"resourceName",
";",
"String",
"platform",
";",
"String",
"fileExtension",
"=",
"... | Determine the right windows library depending on the architecture.
@param library The library name.
@param osName The operating system name.
@param osArch The system architecture.
@return The library resource.
@throws UnsupportedOperationException Throw an exception if no native library for this platform
was found. | [
"Determine",
"the",
"right",
"windows",
"library",
"depending",
"on",
"the",
"architecture",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/adapter/NativeLoader.java#L99-L122 | train |
bit3/jsass | src/main/java/io/bit3/jsass/adapter/NativeLoader.java | NativeLoader.determineLinuxLibrary | private static String determineLinuxLibrary(
final String library,
final String osName,
final String osArch
) {
String resourceName;
String platform = null;
String fileExtension = "so";
switch (osArch) {
case ARCH_AMD64:
case ARCH_X86_64:
platform = "linux-x64";
break;
case ARCH_ARM:
platform = "linux-armhf32";
break;
case ARCH_AARCH64:
platform = "linux-aarch64";
break;
default:
unsupportedPlatform(osName, osArch);
}
resourceName = "/" + platform + "/" + library + "." + fileExtension;
return resourceName;
} | java | private static String determineLinuxLibrary(
final String library,
final String osName,
final String osArch
) {
String resourceName;
String platform = null;
String fileExtension = "so";
switch (osArch) {
case ARCH_AMD64:
case ARCH_X86_64:
platform = "linux-x64";
break;
case ARCH_ARM:
platform = "linux-armhf32";
break;
case ARCH_AARCH64:
platform = "linux-aarch64";
break;
default:
unsupportedPlatform(osName, osArch);
}
resourceName = "/" + platform + "/" + library + "." + fileExtension;
return resourceName;
} | [
"private",
"static",
"String",
"determineLinuxLibrary",
"(",
"final",
"String",
"library",
",",
"final",
"String",
"osName",
",",
"final",
"String",
"osArch",
")",
"{",
"String",
"resourceName",
";",
"String",
"platform",
"=",
"null",
";",
"String",
"fileExtensi... | Determine the right linux library depending on the architecture.
@param library The library name.
@param osName The operating system name.
@param osArch The system architecture.
@return The library resource.
@throws UnsupportedOperationException Throw an exception if no native library for this platform
was found. | [
"Determine",
"the",
"right",
"linux",
"library",
"depending",
"on",
"the",
"architecture",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/adapter/NativeLoader.java#L134-L163 | train |
bit3/jsass | src/main/java/io/bit3/jsass/adapter/NativeLoader.java | NativeLoader.determineFreebsdLibrary | private static String determineFreebsdLibrary(
final String library,
final String osName,
final String osArch
) {
String resourceName;
String platform = null;
String fileExtension = "so";
switch (osArch) {
case ARCH_AMD64:
case ARCH_X86_64:
platform = "freebsd-x64";
break;
default:
unsupportedPlatform(osName, osArch);
}
resourceName = "/" + platform + "/" + library + "." + fileExtension;
return resourceName;
} | java | private static String determineFreebsdLibrary(
final String library,
final String osName,
final String osArch
) {
String resourceName;
String platform = null;
String fileExtension = "so";
switch (osArch) {
case ARCH_AMD64:
case ARCH_X86_64:
platform = "freebsd-x64";
break;
default:
unsupportedPlatform(osName, osArch);
}
resourceName = "/" + platform + "/" + library + "." + fileExtension;
return resourceName;
} | [
"private",
"static",
"String",
"determineFreebsdLibrary",
"(",
"final",
"String",
"library",
",",
"final",
"String",
"osName",
",",
"final",
"String",
"osArch",
")",
"{",
"String",
"resourceName",
";",
"String",
"platform",
"=",
"null",
";",
"String",
"fileExten... | Determine the right FreeBSD library depending on the architecture.
@param library The library name.
@param osName The operating system name.
@param osArch The system architecture.
@return The library resource.
@throws UnsupportedOperationException Throw an exception if no native library for this platform
was found. | [
"Determine",
"the",
"right",
"FreeBSD",
"library",
"depending",
"on",
"the",
"architecture",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/adapter/NativeLoader.java#L175-L196 | train |
bit3/jsass | src/main/java/io/bit3/jsass/adapter/NativeLoader.java | NativeLoader.determineMacLibrary | private static String determineMacLibrary(final String library) {
String resourceName;
String platform = "darwin";
String fileExtension = "dylib";
resourceName = "/" + platform + "/" + library + "." + fileExtension;
return resourceName;
} | java | private static String determineMacLibrary(final String library) {
String resourceName;
String platform = "darwin";
String fileExtension = "dylib";
resourceName = "/" + platform + "/" + library + "." + fileExtension;
return resourceName;
} | [
"private",
"static",
"String",
"determineMacLibrary",
"(",
"final",
"String",
"library",
")",
"{",
"String",
"resourceName",
";",
"String",
"platform",
"=",
"\"darwin\"",
";",
"String",
"fileExtension",
"=",
"\"dylib\"",
";",
"resourceName",
"=",
"\"/\"",
"+",
"... | Determine the right mac library depending on the architecture.
@param library The library name.
@return The library resource. | [
"Determine",
"the",
"right",
"mac",
"library",
"depending",
"on",
"the",
"architecture",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/adapter/NativeLoader.java#L204-L210 | train |
bit3/jsass | src/main/java/io/bit3/jsass/adapter/NativeLoader.java | NativeLoader.saveLibrary | static String saveLibrary(final File dir, final String libraryName) throws IOException {
String libraryFileName = "lib" + libraryName;
URL libraryResource = findLibraryResource(libraryFileName);
String basename = FilenameUtils.getName(libraryResource.getPath());
File file = new File(dir, basename);
file.deleteOnExit();
try (
InputStream in = libraryResource.openStream();
OutputStream out = new FileOutputStream(file)
) {
IOUtils.copy(in, out);
}
LOG.trace("Library \"{}\" copied to \"{}\"", libraryName, file.getAbsolutePath());
return file.getAbsolutePath();
} | java | static String saveLibrary(final File dir, final String libraryName) throws IOException {
String libraryFileName = "lib" + libraryName;
URL libraryResource = findLibraryResource(libraryFileName);
String basename = FilenameUtils.getName(libraryResource.getPath());
File file = new File(dir, basename);
file.deleteOnExit();
try (
InputStream in = libraryResource.openStream();
OutputStream out = new FileOutputStream(file)
) {
IOUtils.copy(in, out);
}
LOG.trace("Library \"{}\" copied to \"{}\"", libraryName, file.getAbsolutePath());
return file.getAbsolutePath();
} | [
"static",
"String",
"saveLibrary",
"(",
"final",
"File",
"dir",
",",
"final",
"String",
"libraryName",
")",
"throws",
"IOException",
"{",
"String",
"libraryFileName",
"=",
"\"lib\"",
"+",
"libraryName",
";",
"URL",
"libraryResource",
"=",
"findLibraryResource",
"(... | Save the shared library in the given temporary directory. | [
"Save",
"the",
"shared",
"library",
"in",
"the",
"given",
"temporary",
"directory",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/adapter/NativeLoader.java#L215-L234 | train |
bit3/jsass | src/main/java/io/bit3/jsass/adapter/NativeAdapter.java | NativeAdapter.compile | public Output compile(FileContext context, ImportStack importStack) throws CompilationException {
NativeFileContext nativeContext = convertToNativeContext(context, importStack);
return compileFile(nativeContext);
} | java | public Output compile(FileContext context, ImportStack importStack) throws CompilationException {
NativeFileContext nativeContext = convertToNativeContext(context, importStack);
return compileFile(nativeContext);
} | [
"public",
"Output",
"compile",
"(",
"FileContext",
"context",
",",
"ImportStack",
"importStack",
")",
"throws",
"CompilationException",
"{",
"NativeFileContext",
"nativeContext",
"=",
"convertToNativeContext",
"(",
"context",
",",
"importStack",
")",
";",
"return",
"c... | Compile a file context.
@return The compiled result. | [
"Compile",
"a",
"file",
"context",
"."
] | fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef | https://github.com/bit3/jsass/blob/fba91d5cb1eb507c7cfde5a261e04b1d328cb1ef/src/main/java/io/bit3/jsass/adapter/NativeAdapter.java#L42-L45 | train |
CenturyLinkCloud/mdw | mdw-workflow/src/com/centurylink/mdw/workflow/activity/sync/SynchronizationActivity.java | SynchronizationActivity.execute | public void execute() throws ActivityException{
isSynchronized = checkIfSynchronized();
if (!isSynchronized) {
EventWaitInstance received = registerWaitEvents(false, true);
if (received!=null)
resume(getExternalEventInstanceDetails(received.getMessageDocumentId()), received.getCompletionCode());
}
} | java | public void execute() throws ActivityException{
isSynchronized = checkIfSynchronized();
if (!isSynchronized) {
EventWaitInstance received = registerWaitEvents(false, true);
if (received!=null)
resume(getExternalEventInstanceDetails(received.getMessageDocumentId()), received.getCompletionCode());
}
} | [
"public",
"void",
"execute",
"(",
")",
"throws",
"ActivityException",
"{",
"isSynchronized",
"=",
"checkIfSynchronized",
"(",
")",
";",
"if",
"(",
"!",
"isSynchronized",
")",
"{",
"EventWaitInstance",
"received",
"=",
"registerWaitEvents",
"(",
"false",
",",
"tr... | Executes the controlled activity
@throws ActivityException | [
"Executes",
"the",
"controlled",
"activity"
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-workflow/src/com/centurylink/mdw/workflow/activity/sync/SynchronizationActivity.java#L58-L65 | train |
CenturyLinkCloud/mdw | mdw-workflow/src/com/centurylink/mdw/workflow/activity/sync/SynchronizationActivity.java | SynchronizationActivity.escape | private String escape(String rawActivityName) {
boolean lastIsUnderScore = false;
StringBuffer sb = new StringBuffer();
for (int i=0; i<rawActivityName.length(); i++) {
char ch = rawActivityName.charAt(i);
if (Character.isLetterOrDigit(ch)) {
sb.append(ch);
lastIsUnderScore = false;
} else if (!lastIsUnderScore) {
sb.append(UNDERSCORE);
lastIsUnderScore = true;
}
}
return sb.toString();
} | java | private String escape(String rawActivityName) {
boolean lastIsUnderScore = false;
StringBuffer sb = new StringBuffer();
for (int i=0; i<rawActivityName.length(); i++) {
char ch = rawActivityName.charAt(i);
if (Character.isLetterOrDigit(ch)) {
sb.append(ch);
lastIsUnderScore = false;
} else if (!lastIsUnderScore) {
sb.append(UNDERSCORE);
lastIsUnderScore = true;
}
}
return sb.toString();
} | [
"private",
"String",
"escape",
"(",
"String",
"rawActivityName",
")",
"{",
"boolean",
"lastIsUnderScore",
"=",
"false",
";",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"rawActivityName"... | Replaces space characters in the activity name with underscores.
@param rawActivityName
@return the escaped activity name | [
"Replaces",
"space",
"characters",
"in",
"the",
"activity",
"name",
"with",
"underscores",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-workflow/src/com/centurylink/mdw/workflow/activity/sync/SynchronizationActivity.java#L110-L124 | train |
CenturyLinkCloud/mdw | mdw-workflow/src/com/centurylink/mdw/workflow/activity/sync/SynchronizationActivity.java | SynchronizationActivity.getIncomingTransitions | private List<Transition> getIncomingTransitions(Process procdef, Long activityId,
Map<String,String> idToEscapedName) {
List<Transition> incomingTransitions = new ArrayList<Transition>();
for (Transition trans : procdef.getTransitions()) {
if (trans.getToId().equals(activityId)) {
Transition sync = new Transition();
sync.setId(trans.getId());
Activity act = procdef.getActivityVO(trans.getFromId());
String logicalId = act.getLogicalId();
// id to escaped name map is for backward compatibility
idToEscapedName.put(logicalId, escape(act.getName()));
sync.setCompletionCode(logicalId);
incomingTransitions.add(sync);
}
}
return incomingTransitions;
} | java | private List<Transition> getIncomingTransitions(Process procdef, Long activityId,
Map<String,String> idToEscapedName) {
List<Transition> incomingTransitions = new ArrayList<Transition>();
for (Transition trans : procdef.getTransitions()) {
if (trans.getToId().equals(activityId)) {
Transition sync = new Transition();
sync.setId(trans.getId());
Activity act = procdef.getActivityVO(trans.getFromId());
String logicalId = act.getLogicalId();
// id to escaped name map is for backward compatibility
idToEscapedName.put(logicalId, escape(act.getName()));
sync.setCompletionCode(logicalId);
incomingTransitions.add(sync);
}
}
return incomingTransitions;
} | [
"private",
"List",
"<",
"Transition",
">",
"getIncomingTransitions",
"(",
"Process",
"procdef",
",",
"Long",
"activityId",
",",
"Map",
"<",
"String",
",",
"String",
">",
"idToEscapedName",
")",
"{",
"List",
"<",
"Transition",
">",
"incomingTransitions",
"=",
"... | reuse WorkTransitionVO for sync info | [
"reuse",
"WorkTransitionVO",
"for",
"sync",
"info"
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-workflow/src/com/centurylink/mdw/workflow/activity/sync/SynchronizationActivity.java#L129-L145 | train |
CenturyLinkCloud/mdw | mdw-workflow/src/com/centurylink/mdw/workflow/adapter/soap/MdwRpcWebServiceAdapter.java | MdwRpcWebServiceAdapter.createSoapRequest | protected SOAPMessage createSoapRequest(Object requestObj) throws ActivityException {
try {
MessageFactory messageFactory = getSoapMessageFactory();
SOAPMessage soapMessage = messageFactory.createMessage();
Map<Name,String> soapReqHeaders = getSoapRequestHeaders();
if (soapReqHeaders != null) {
SOAPHeader header = soapMessage.getSOAPHeader();
for (Name name : soapReqHeaders.keySet()) {
header.addHeaderElement(name).setTextContent(soapReqHeaders.get(name));
}
}
SOAPBody soapBody = soapMessage.getSOAPBody();
Document requestDoc = null;
if (requestObj instanceof String) {
requestDoc = DomHelper.toDomDocument((String)requestObj);
}
else {
Variable reqVar = getProcessDefinition().getVariable(getAttributeValue(REQUEST_VARIABLE));
XmlDocumentTranslator docRefTrans = (XmlDocumentTranslator)VariableTranslator.getTranslator(getPackage(), reqVar.getType());
requestDoc = docRefTrans.toDomDocument(requestObj);
}
SOAPBodyElement bodyElem = soapBody.addBodyElement(getOperation());
String requestLabel = getRequestLabelPartName();
if (requestLabel != null) {
SOAPElement serviceNameElem = bodyElem.addChildElement(requestLabel);
serviceNameElem.addTextNode(getRequestLabel());
}
SOAPElement requestDetailsElem = bodyElem.addChildElement(getRequestPartName());
requestDetailsElem.addTextNode("<![CDATA[" + DomHelper.toXml(requestDoc) + "]]>");
return soapMessage;
}
catch (Exception ex) {
throw new ActivityException(ex.getMessage(), ex);
}
} | java | protected SOAPMessage createSoapRequest(Object requestObj) throws ActivityException {
try {
MessageFactory messageFactory = getSoapMessageFactory();
SOAPMessage soapMessage = messageFactory.createMessage();
Map<Name,String> soapReqHeaders = getSoapRequestHeaders();
if (soapReqHeaders != null) {
SOAPHeader header = soapMessage.getSOAPHeader();
for (Name name : soapReqHeaders.keySet()) {
header.addHeaderElement(name).setTextContent(soapReqHeaders.get(name));
}
}
SOAPBody soapBody = soapMessage.getSOAPBody();
Document requestDoc = null;
if (requestObj instanceof String) {
requestDoc = DomHelper.toDomDocument((String)requestObj);
}
else {
Variable reqVar = getProcessDefinition().getVariable(getAttributeValue(REQUEST_VARIABLE));
XmlDocumentTranslator docRefTrans = (XmlDocumentTranslator)VariableTranslator.getTranslator(getPackage(), reqVar.getType());
requestDoc = docRefTrans.toDomDocument(requestObj);
}
SOAPBodyElement bodyElem = soapBody.addBodyElement(getOperation());
String requestLabel = getRequestLabelPartName();
if (requestLabel != null) {
SOAPElement serviceNameElem = bodyElem.addChildElement(requestLabel);
serviceNameElem.addTextNode(getRequestLabel());
}
SOAPElement requestDetailsElem = bodyElem.addChildElement(getRequestPartName());
requestDetailsElem.addTextNode("<![CDATA[" + DomHelper.toXml(requestDoc) + "]]>");
return soapMessage;
}
catch (Exception ex) {
throw new ActivityException(ex.getMessage(), ex);
}
} | [
"protected",
"SOAPMessage",
"createSoapRequest",
"(",
"Object",
"requestObj",
")",
"throws",
"ActivityException",
"{",
"try",
"{",
"MessageFactory",
"messageFactory",
"=",
"getSoapMessageFactory",
"(",
")",
";",
"SOAPMessage",
"soapMessage",
"=",
"messageFactory",
".",
... | Populate the SOAP request message. | [
"Populate",
"the",
"SOAP",
"request",
"message",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-workflow/src/com/centurylink/mdw/workflow/adapter/soap/MdwRpcWebServiceAdapter.java#L57-L95 | train |
CenturyLinkCloud/mdw | mdw-workflow/src/com/centurylink/mdw/workflow/adapter/soap/MdwRpcWebServiceAdapter.java | MdwRpcWebServiceAdapter.unwrapSoapResponse | protected Node unwrapSoapResponse(SOAPMessage soapResponse) throws ActivityException, AdapterException {
try {
// unwrap the soap content from the message
SOAPBody soapBody = soapResponse.getSOAPBody();
Node childElem = null;
Iterator<?> it = soapBody.getChildElements();
while (it.hasNext()) {
Node node = (Node) it.next();
if (node.getNodeType() == Node.ELEMENT_NODE && node.getLocalName().equals(getOutputMessageName())) {
NodeList childNodes = node.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
if (getResponsePartName().equals(childNodes.item(i).getLocalName())) {
String content = childNodes.item(i).getTextContent();
childElem = DomHelper.toDomNode(content);
}
}
}
}
if (childElem == null)
throw new SOAPException("SOAP body child element not found");
// extract soap response headers
SOAPHeader header = soapResponse.getSOAPHeader();
if (header != null) {
extractSoapResponseHeaders(header);
}
return childElem;
}
catch (Exception ex) {
throw new ActivityException(ex.getMessage(), ex);
}
} | java | protected Node unwrapSoapResponse(SOAPMessage soapResponse) throws ActivityException, AdapterException {
try {
// unwrap the soap content from the message
SOAPBody soapBody = soapResponse.getSOAPBody();
Node childElem = null;
Iterator<?> it = soapBody.getChildElements();
while (it.hasNext()) {
Node node = (Node) it.next();
if (node.getNodeType() == Node.ELEMENT_NODE && node.getLocalName().equals(getOutputMessageName())) {
NodeList childNodes = node.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
if (getResponsePartName().equals(childNodes.item(i).getLocalName())) {
String content = childNodes.item(i).getTextContent();
childElem = DomHelper.toDomNode(content);
}
}
}
}
if (childElem == null)
throw new SOAPException("SOAP body child element not found");
// extract soap response headers
SOAPHeader header = soapResponse.getSOAPHeader();
if (header != null) {
extractSoapResponseHeaders(header);
}
return childElem;
}
catch (Exception ex) {
throw new ActivityException(ex.getMessage(), ex);
}
} | [
"protected",
"Node",
"unwrapSoapResponse",
"(",
"SOAPMessage",
"soapResponse",
")",
"throws",
"ActivityException",
",",
"AdapterException",
"{",
"try",
"{",
"// unwrap the soap content from the message",
"SOAPBody",
"soapBody",
"=",
"soapResponse",
".",
"getSOAPBody",
"(",
... | Unwrap the SOAP response into a DOM Node. | [
"Unwrap",
"the",
"SOAP",
"response",
"into",
"a",
"DOM",
"Node",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-workflow/src/com/centurylink/mdw/workflow/adapter/soap/MdwRpcWebServiceAdapter.java#L100-L132 | train |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/service/api/ResourceReaderExtension.java | ResourceReaderExtension.applyImplicitParameters | @Override
public void applyImplicitParameters(ReaderContext context, Operation operation, Method method) {
// copied from io.swagger.servlet.extensions.ServletReaderExtension
final ApiImplicitParams implicitParams = method.getAnnotation(ApiImplicitParams.class);
if (implicitParams != null && implicitParams.value().length > 0) {
for (ApiImplicitParam param : implicitParams.value()) {
final Parameter p = readImplicitParam(context.getSwagger(), param);
if (p != null) {
if (p instanceof BodyParameter && param.format() != null)
p.getVendorExtensions().put("format", param.format());
operation.parameter(p);
}
}
}
} | java | @Override
public void applyImplicitParameters(ReaderContext context, Operation operation, Method method) {
// copied from io.swagger.servlet.extensions.ServletReaderExtension
final ApiImplicitParams implicitParams = method.getAnnotation(ApiImplicitParams.class);
if (implicitParams != null && implicitParams.value().length > 0) {
for (ApiImplicitParam param : implicitParams.value()) {
final Parameter p = readImplicitParam(context.getSwagger(), param);
if (p != null) {
if (p instanceof BodyParameter && param.format() != null)
p.getVendorExtensions().put("format", param.format());
operation.parameter(p);
}
}
}
} | [
"@",
"Override",
"public",
"void",
"applyImplicitParameters",
"(",
"ReaderContext",
"context",
",",
"Operation",
"operation",
",",
"Method",
"method",
")",
"{",
"// copied from io.swagger.servlet.extensions.ServletReaderExtension",
"final",
"ApiImplicitParams",
"implicitParams"... | Implemented to allow loading of custom types using CloudClassLoader. | [
"Implemented",
"to",
"allow",
"loading",
"of",
"custom",
"types",
"using",
"CloudClassLoader",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/service/api/ResourceReaderExtension.java#L171-L185 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/model/asset/Pagelet.java | Pagelet.translateType | private String translateType(String type, Map<String,String> attrs) {
String translated = type.toLowerCase();
if ("select".equals(type))
translated = "radio";
else if ("boolean".equals(type))
translated = "checkbox";
else if ("list".equals(type)) {
translated = "picklist";
String lbl = attrs.get("label");
if (lbl == null)
lbl = attrs.get("name");
if ("Output Documents".equals(lbl)) {
attrs.put("label", "Documents");
attrs.put("unselectedLabel", "Read-Only");
attrs.put("selectedLabel", "Writable");
}
}
else if ("hyperlink".equals(type)) {
if (attrs.containsKey("url"))
translated = "link";
else
translated = "text";
}
else if ("rule".equals(type)) {
if ("EXPRESSION".equals(attrs.get("type"))) {
translated = "expression";
}
else if ("TRANSFORM".equals(attrs.get("type"))) {
translated = "edit";
attrs.put("label", "Transform");
}
else {
translated = "edit";
attrs.put("label", "Script");
}
attrs.remove("type");
}
else if ("Java".equals(attrs.get("name"))) {
translated = "edit";
}
else {
// asset-driven
String source = attrs.get("source");
if ("Process".equals(source)) {
translated = "asset";
attrs.put("source", "proc");
}
else if ("TaskTemplates".equals(source)) {
translated = "asset";
attrs.put("source", "task");
}
else if ("RuleSets".equals(source)) {
String format = attrs.get("type");
if (format != null) {
String exts = "";
String[] formats = format.split(",");
for (int i = 0; i < formats.length; i++) {
String ext = Asset.getFileExtension(formats[i]);
if (ext != null) {
if (exts.length() > 0)
exts += ",";
exts += ext.substring(1);
}
}
if (exts.length() > 0) {
translated = "asset";
attrs.put("source", exts);
}
}
}
}
return translated;
} | java | private String translateType(String type, Map<String,String> attrs) {
String translated = type.toLowerCase();
if ("select".equals(type))
translated = "radio";
else if ("boolean".equals(type))
translated = "checkbox";
else if ("list".equals(type)) {
translated = "picklist";
String lbl = attrs.get("label");
if (lbl == null)
lbl = attrs.get("name");
if ("Output Documents".equals(lbl)) {
attrs.put("label", "Documents");
attrs.put("unselectedLabel", "Read-Only");
attrs.put("selectedLabel", "Writable");
}
}
else if ("hyperlink".equals(type)) {
if (attrs.containsKey("url"))
translated = "link";
else
translated = "text";
}
else if ("rule".equals(type)) {
if ("EXPRESSION".equals(attrs.get("type"))) {
translated = "expression";
}
else if ("TRANSFORM".equals(attrs.get("type"))) {
translated = "edit";
attrs.put("label", "Transform");
}
else {
translated = "edit";
attrs.put("label", "Script");
}
attrs.remove("type");
}
else if ("Java".equals(attrs.get("name"))) {
translated = "edit";
}
else {
// asset-driven
String source = attrs.get("source");
if ("Process".equals(source)) {
translated = "asset";
attrs.put("source", "proc");
}
else if ("TaskTemplates".equals(source)) {
translated = "asset";
attrs.put("source", "task");
}
else if ("RuleSets".equals(source)) {
String format = attrs.get("type");
if (format != null) {
String exts = "";
String[] formats = format.split(",");
for (int i = 0; i < formats.length; i++) {
String ext = Asset.getFileExtension(formats[i]);
if (ext != null) {
if (exts.length() > 0)
exts += ",";
exts += ext.substring(1);
}
}
if (exts.length() > 0) {
translated = "asset";
attrs.put("source", exts);
}
}
}
}
return translated;
} | [
"private",
"String",
"translateType",
"(",
"String",
"type",
",",
"Map",
"<",
"String",
",",
"String",
">",
"attrs",
")",
"{",
"String",
"translated",
"=",
"type",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"\"select\"",
".",
"equals",
"(",
"type",
... | Translate widget type. | [
"Translate",
"widget",
"type",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/model/asset/Pagelet.java#L199-L271 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/model/asset/Pagelet.java | Pagelet.adjustWidgets | private void adjustWidgets(String implCategory) {
// adjust to add script language options param
Map<Integer,Widget> companions = new HashMap<>();
for (int i = 0; i < widgets.size(); i++) {
Widget widget = widgets.get(i);
if ("expression".equals(widget.type) || ("edit".equals(widget.type) && !"Java".equals(widget.name))) {
Widget companion = new Widget("SCRIPT", "dropdown");
companion.setAttribute("label", "Language");
companion.options = Arrays.asList(widget.getAttribute("languages").split(","));
if (companion.options.contains("Groovy"))
companion.setAttribute("default", "Groovy");
else if (companion.options.contains("Kotlin Script"))
companion.setAttribute("default", "Kotlin Script");
String section = widget.getAttribute("section");
if (section != null)
companion.setAttribute("section", section);
companions.put(i, companion);
}
}
int offset = 0;
for (int idx : companions.keySet()) {
widgets.add(idx + offset, companions.get(idx));
offset++;
}
} | java | private void adjustWidgets(String implCategory) {
// adjust to add script language options param
Map<Integer,Widget> companions = new HashMap<>();
for (int i = 0; i < widgets.size(); i++) {
Widget widget = widgets.get(i);
if ("expression".equals(widget.type) || ("edit".equals(widget.type) && !"Java".equals(widget.name))) {
Widget companion = new Widget("SCRIPT", "dropdown");
companion.setAttribute("label", "Language");
companion.options = Arrays.asList(widget.getAttribute("languages").split(","));
if (companion.options.contains("Groovy"))
companion.setAttribute("default", "Groovy");
else if (companion.options.contains("Kotlin Script"))
companion.setAttribute("default", "Kotlin Script");
String section = widget.getAttribute("section");
if (section != null)
companion.setAttribute("section", section);
companions.put(i, companion);
}
}
int offset = 0;
for (int idx : companions.keySet()) {
widgets.add(idx + offset, companions.get(idx));
offset++;
}
} | [
"private",
"void",
"adjustWidgets",
"(",
"String",
"implCategory",
")",
"{",
"// adjust to add script language options param",
"Map",
"<",
"Integer",
",",
"Widget",
">",
"companions",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0"... | Adds companion widgets as needed. | [
"Adds",
"companion",
"widgets",
"as",
"needed",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/model/asset/Pagelet.java#L276-L300 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/app/Templates.java | Templates.substitute | public static String substitute(String input, Map<String,Object> values) {
StringBuilder output = new StringBuilder(input.length());
int index = 0;
Matcher matcher = SUBST_PATTERN.matcher(input);
while (matcher.find()) {
String match = matcher.group();
output.append(input.substring(index, matcher.start()));
Object value = values.get(match.substring(2, match.length() - 2));
output.append(value == null ? "" : String.valueOf(value));
index = matcher.end();
}
output.append(input.substring(index));
return output.toString();
} | java | public static String substitute(String input, Map<String,Object> values) {
StringBuilder output = new StringBuilder(input.length());
int index = 0;
Matcher matcher = SUBST_PATTERN.matcher(input);
while (matcher.find()) {
String match = matcher.group();
output.append(input.substring(index, matcher.start()));
Object value = values.get(match.substring(2, match.length() - 2));
output.append(value == null ? "" : String.valueOf(value));
index = matcher.end();
}
output.append(input.substring(index));
return output.toString();
} | [
"public",
"static",
"String",
"substitute",
"(",
"String",
"input",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"values",
")",
"{",
"StringBuilder",
"output",
"=",
"new",
"StringBuilder",
"(",
"input",
".",
"length",
"(",
")",
")",
";",
"int",
"index"... | Simple substitution mechanism. Missing values substituted with empty string. | [
"Simple",
"substitution",
"mechanism",
".",
"Missing",
"values",
"substituted",
"with",
"empty",
"string",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/app/Templates.java#L77-L90 | train |
CenturyLinkCloud/mdw | mdw-workflow/src/com/centurylink/mdw/workflow/activity/task/AutoFormManualTaskActivity.java | AutoFormManualTaskActivity.extractFormData | protected String extractFormData(JSONObject datadoc)
throws ActivityException, JSONException {
String varstring = this.getAttributeValue(TaskActivity.ATTRIBUTE_TASK_VARIABLES);
List<String[]> parsed = StringHelper.parseTable(varstring, ',', ';', 5);
for (String[] one : parsed) {
String varname = one[0];
String displayOption = one[2];
if (displayOption.equals(TaskActivity.VARIABLE_DISPLAY_NOTDISPLAYED)) continue;
if (displayOption.equals(TaskActivity.VARIABLE_DISPLAY_READONLY)) continue;
if (varname.startsWith("#{") || varname.startsWith("${")) continue;
String data = datadoc.has(varname) ? datadoc.getString(varname) : null;
setDataToVariable(varname, data);
}
return null;
} | java | protected String extractFormData(JSONObject datadoc)
throws ActivityException, JSONException {
String varstring = this.getAttributeValue(TaskActivity.ATTRIBUTE_TASK_VARIABLES);
List<String[]> parsed = StringHelper.parseTable(varstring, ',', ';', 5);
for (String[] one : parsed) {
String varname = one[0];
String displayOption = one[2];
if (displayOption.equals(TaskActivity.VARIABLE_DISPLAY_NOTDISPLAYED)) continue;
if (displayOption.equals(TaskActivity.VARIABLE_DISPLAY_READONLY)) continue;
if (varname.startsWith("#{") || varname.startsWith("${")) continue;
String data = datadoc.has(varname) ? datadoc.getString(varname) : null;
setDataToVariable(varname, data);
}
return null;
} | [
"protected",
"String",
"extractFormData",
"(",
"JSONObject",
"datadoc",
")",
"throws",
"ActivityException",
",",
"JSONException",
"{",
"String",
"varstring",
"=",
"this",
".",
"getAttributeValue",
"(",
"TaskActivity",
".",
"ATTRIBUTE_TASK_VARIABLES",
")",
";",
"List",... | This method is used to extract data from the message received from the task manager.
The method updates all variables specified as non-readonly
@param datadoc
@return completion code; when it returns null, the completion
code is taken from the completionCode parameter of
the message with key FormDataDocument.ATTR_ACTION
@throws ActivityException
@throws JSONException | [
"This",
"method",
"is",
"used",
"to",
"extract",
"data",
"from",
"the",
"message",
"received",
"from",
"the",
"task",
"manager",
".",
"The",
"method",
"updates",
"all",
"variables",
"specified",
"as",
"non",
"-",
"readonly"
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-workflow/src/com/centurylink/mdw/workflow/activity/task/AutoFormManualTaskActivity.java#L170-L184 | train |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/listener/file/FileListenerRegistration.java | FileListenerRegistration.onStartup | public void onStartup() throws StartupException {
try {
Map<String, Properties> fileListeners = getFileListeners();
for (String listenerName : fileListeners.keySet()) {
Properties listenerProps = fileListeners.get(listenerName);
String listenerClassName = listenerProps.getProperty("ClassName");
logger.info("Registering File Listener: " + listenerName + " Class: " + listenerClassName);
FileListener listener = getFileListenerInstance(listenerClassName);
listener.setName(listenerName);
registeredFileListeners.put(listenerName, listener);
listener.listen(listenerProps);
}
}
catch (Exception ex) {
ex.printStackTrace();
logger.severeException(ex.getMessage(), ex);
throw new StartupException(ex.getMessage());
}
} | java | public void onStartup() throws StartupException {
try {
Map<String, Properties> fileListeners = getFileListeners();
for (String listenerName : fileListeners.keySet()) {
Properties listenerProps = fileListeners.get(listenerName);
String listenerClassName = listenerProps.getProperty("ClassName");
logger.info("Registering File Listener: " + listenerName + " Class: " + listenerClassName);
FileListener listener = getFileListenerInstance(listenerClassName);
listener.setName(listenerName);
registeredFileListeners.put(listenerName, listener);
listener.listen(listenerProps);
}
}
catch (Exception ex) {
ex.printStackTrace();
logger.severeException(ex.getMessage(), ex);
throw new StartupException(ex.getMessage());
}
} | [
"public",
"void",
"onStartup",
"(",
")",
"throws",
"StartupException",
"{",
"try",
"{",
"Map",
"<",
"String",
",",
"Properties",
">",
"fileListeners",
"=",
"getFileListeners",
"(",
")",
";",
"for",
"(",
"String",
"listenerName",
":",
"fileListeners",
".",
"k... | Startup the file listeners. | [
"Startup",
"the",
"file",
"listeners",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/listener/file/FileListenerRegistration.java#L44-L62 | train |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/listener/file/FileListenerRegistration.java | FileListenerRegistration.onShutdown | public void onShutdown() {
for (String listenerName : registeredFileListeners.keySet()) {
logger.info("Deregistering File Listener: " + listenerName);
FileListener listener = registeredFileListeners.get(listenerName);
listener.stopListening();
}
} | java | public void onShutdown() {
for (String listenerName : registeredFileListeners.keySet()) {
logger.info("Deregistering File Listener: " + listenerName);
FileListener listener = registeredFileListeners.get(listenerName);
listener.stopListening();
}
} | [
"public",
"void",
"onShutdown",
"(",
")",
"{",
"for",
"(",
"String",
"listenerName",
":",
"registeredFileListeners",
".",
"keySet",
"(",
")",
")",
"{",
"logger",
".",
"info",
"(",
"\"Deregistering File Listener: \"",
"+",
"listenerName",
")",
";",
"FileListener"... | Shutdown the file listeners. | [
"Shutdown",
"the",
"file",
"listeners",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/listener/file/FileListenerRegistration.java#L67-L73 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/model/user/Workgroup.java | Workgroup.hasRole | public boolean hasRole(String roleName){
if (roles != null) {
for (String r : roles) {
if (r.equals(roleName))
return true;
}
}
return false;
} | java | public boolean hasRole(String roleName){
if (roles != null) {
for (String r : roles) {
if (r.equals(roleName))
return true;
}
}
return false;
} | [
"public",
"boolean",
"hasRole",
"(",
"String",
"roleName",
")",
"{",
"if",
"(",
"roles",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"r",
":",
"roles",
")",
"{",
"if",
"(",
"r",
".",
"equals",
"(",
"roleName",
")",
")",
"return",
"true",
";",
"... | Check whether the group has the specified role. | [
"Check",
"whether",
"the",
"group",
"has",
"the",
"specified",
"role",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/model/user/Workgroup.java#L148-L156 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/model/workflow/Process.java | Process.isWorkActivity | public boolean isWorkActivity(Long pWorkId) {
if(this.activities == null){
return false;
}
for(int i=0; i<activities.size(); i++){
if(pWorkId.longValue() == activities.get(i).getId().longValue()){
return true;
}
}
return false;
} | java | public boolean isWorkActivity(Long pWorkId) {
if(this.activities == null){
return false;
}
for(int i=0; i<activities.size(); i++){
if(pWorkId.longValue() == activities.get(i).getId().longValue()){
return true;
}
}
return false;
} | [
"public",
"boolean",
"isWorkActivity",
"(",
"Long",
"pWorkId",
")",
"{",
"if",
"(",
"this",
".",
"activities",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"activities",
".",
"size",
"(",
")"... | checks if the passed in workId is
Activity
@return boolean status | [
"checks",
"if",
"the",
"passed",
"in",
"workId",
"is",
"Activity"
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/model/workflow/Process.java#L102-L113 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/model/workflow/Process.java | Process.getSubProcessVO | public Process getSubProcessVO(Long id) {
if (this.getId() != null && this.getId().equals(id)) // Id field is null for instance definitions
return this;
if (this.subprocesses == null)
return null;
for (Process ret : subprocesses) {
if (ret.getId().equals(id))
return ret;
}
return null;
} | java | public Process getSubProcessVO(Long id) {
if (this.getId() != null && this.getId().equals(id)) // Id field is null for instance definitions
return this;
if (this.subprocesses == null)
return null;
for (Process ret : subprocesses) {
if (ret.getId().equals(id))
return ret;
}
return null;
} | [
"public",
"Process",
"getSubProcessVO",
"(",
"Long",
"id",
")",
"{",
"if",
"(",
"this",
".",
"getId",
"(",
")",
"!=",
"null",
"&&",
"this",
".",
"getId",
"(",
")",
".",
"equals",
"(",
"id",
")",
")",
"// Id field is null for instance definitions",
"return"... | returns the process VO identified by the passed in work id
It is also possible the sub process is referencing self.
@param id | [
"returns",
"the",
"process",
"VO",
"identified",
"by",
"the",
"passed",
"in",
"work",
"id",
"It",
"is",
"also",
"possible",
"the",
"sub",
"process",
"is",
"referencing",
"self",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/model/workflow/Process.java#L120-L130 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/model/workflow/Process.java | Process.getActivityVO | public Activity getActivityVO(Long pWorkId) {
if(this.activities == null){
return null;
}
for(int i=0; i<activities.size(); i++){
if(pWorkId.longValue() == activities.get(i).getId().longValue()){
return activities.get(i);
}
}
return null;
} | java | public Activity getActivityVO(Long pWorkId) {
if(this.activities == null){
return null;
}
for(int i=0; i<activities.size(); i++){
if(pWorkId.longValue() == activities.get(i).getId().longValue()){
return activities.get(i);
}
}
return null;
} | [
"public",
"Activity",
"getActivityVO",
"(",
"Long",
"pWorkId",
")",
"{",
"if",
"(",
"this",
".",
"activities",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"activities",
".",
"size",
"(",
")",... | Returns the Activity VO
@param pWorkId
@returb ActivityVO | [
"Returns",
"the",
"Activity",
"VO"
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/model/workflow/Process.java#L137-L148 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/model/workflow/Process.java | Process.getWorkTransitionVO | public Transition getWorkTransitionVO(Long pWorkTransId) {
if(this.transitions == null){
return null;
}
for(int i=0; i<transitions.size(); i++){
if(pWorkTransId.longValue() == transitions.get(i).getId().longValue()){
return transitions.get(i);
}
}
return null;
} | java | public Transition getWorkTransitionVO(Long pWorkTransId) {
if(this.transitions == null){
return null;
}
for(int i=0; i<transitions.size(); i++){
if(pWorkTransId.longValue() == transitions.get(i).getId().longValue()){
return transitions.get(i);
}
}
return null;
} | [
"public",
"Transition",
"getWorkTransitionVO",
"(",
"Long",
"pWorkTransId",
")",
"{",
"if",
"(",
"this",
".",
"transitions",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"transitions",
".",
"size"... | Returns the WorkTransitionVO
@param pWorkTransId
@returb WorkTransitionVO | [
"Returns",
"the",
"WorkTransitionVO"
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/model/workflow/Process.java#L155-L166 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/model/workflow/Process.java | Process.getTransition | public Transition getTransition(Long fromId, Integer eventType, String completionCode) {
Transition ret = null;
for (Transition transition : getTransitions()) {
if (transition.getFromId().equals(fromId)
&& transition.match(eventType, completionCode)) {
if (ret == null) ret = transition;
else {
throw new IllegalStateException("Multiple matching work transitions when one expected:\n"
+ " processId: " + getId() + " fromId: " + fromId + " eventType: "
+ eventType + "compCode: " + completionCode);
}
}
}
return ret;
} | java | public Transition getTransition(Long fromId, Integer eventType, String completionCode) {
Transition ret = null;
for (Transition transition : getTransitions()) {
if (transition.getFromId().equals(fromId)
&& transition.match(eventType, completionCode)) {
if (ret == null) ret = transition;
else {
throw new IllegalStateException("Multiple matching work transitions when one expected:\n"
+ " processId: " + getId() + " fromId: " + fromId + " eventType: "
+ eventType + "compCode: " + completionCode);
}
}
}
return ret;
} | [
"public",
"Transition",
"getTransition",
"(",
"Long",
"fromId",
",",
"Integer",
"eventType",
",",
"String",
"completionCode",
")",
"{",
"Transition",
"ret",
"=",
"null",
";",
"for",
"(",
"Transition",
"transition",
":",
"getTransitions",
"(",
")",
")",
"{",
... | Finds one work transition for this process matching the specified parameters
@param fromId
@param eventType
@param completionCode
@return the work transition value object (or null if not found) | [
"Finds",
"one",
"work",
"transition",
"for",
"this",
"process",
"matching",
"the",
"specified",
"parameters"
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/model/workflow/Process.java#L313-L327 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/model/workflow/Process.java | Process.getTransitions | public List<Transition> getTransitions(Long fromWorkId, Integer eventType, String completionCode) {
List<Transition> allTransitions = getAllTransitions(fromWorkId);
List<Transition> returnSet = findTransitions(allTransitions, eventType, completionCode);
if (returnSet.size() > 0)
return returnSet;
// look for default transition
boolean noLabelIsDefault = getTransitionWithNoLabel().equals(TRANSITION_ON_DEFAULT);
if (noLabelIsDefault) returnSet = findTransitions(allTransitions, eventType, null);
else returnSet = findTransitions(allTransitions, eventType, ActivityResultCodeConstant.RESULT_DEFAULT);
if (returnSet.size() > 0)
return returnSet;
// look for resume transition
if (eventType.equals(EventType.FINISH)) {
returnSet = new ArrayList<Transition>();
for (Transition trans : allTransitions) {
if (trans.getEventType().equals(EventType.RESUME))
returnSet.add(trans);
}
}
return returnSet;
} | java | public List<Transition> getTransitions(Long fromWorkId, Integer eventType, String completionCode) {
List<Transition> allTransitions = getAllTransitions(fromWorkId);
List<Transition> returnSet = findTransitions(allTransitions, eventType, completionCode);
if (returnSet.size() > 0)
return returnSet;
// look for default transition
boolean noLabelIsDefault = getTransitionWithNoLabel().equals(TRANSITION_ON_DEFAULT);
if (noLabelIsDefault) returnSet = findTransitions(allTransitions, eventType, null);
else returnSet = findTransitions(allTransitions, eventType, ActivityResultCodeConstant.RESULT_DEFAULT);
if (returnSet.size() > 0)
return returnSet;
// look for resume transition
if (eventType.equals(EventType.FINISH)) {
returnSet = new ArrayList<Transition>();
for (Transition trans : allTransitions) {
if (trans.getEventType().equals(EventType.RESUME))
returnSet.add(trans);
}
}
return returnSet;
} | [
"public",
"List",
"<",
"Transition",
">",
"getTransitions",
"(",
"Long",
"fromWorkId",
",",
"Integer",
"eventType",
",",
"String",
"completionCode",
")",
"{",
"List",
"<",
"Transition",
">",
"allTransitions",
"=",
"getAllTransitions",
"(",
"fromWorkId",
")",
";"... | Finds the work transitions from the given activity
that match the event type and completion code.
A DEFAULT completion code matches any completion
code if and only if there is no other matches
@param fromWorkId
@param eventType
@parame completionCode
@return the matching work transition value objects | [
"Finds",
"the",
"work",
"transitions",
"from",
"the",
"given",
"activity",
"that",
"match",
"the",
"event",
"type",
"and",
"completion",
"code",
".",
"A",
"DEFAULT",
"completion",
"code",
"matches",
"any",
"completion",
"code",
"if",
"and",
"only",
"if",
"th... | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/model/workflow/Process.java#L379-L399 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/model/workflow/Process.java | Process.getTransition | public Transition getTransition(Long id) {
for (Transition transition : getTransitions()) {
if (transition.getId().equals(id))
return transition;
}
return null; // not found
} | java | public Transition getTransition(Long id) {
for (Transition transition : getTransitions()) {
if (transition.getId().equals(id))
return transition;
}
return null; // not found
} | [
"public",
"Transition",
"getTransition",
"(",
"Long",
"id",
")",
"{",
"for",
"(",
"Transition",
"transition",
":",
"getTransitions",
"(",
")",
")",
"{",
"if",
"(",
"transition",
".",
"getId",
"(",
")",
".",
"equals",
"(",
"id",
")",
")",
"return",
"tra... | Find a work transition based on its id value
@param id
@return the matching transition VO, or null if not found | [
"Find",
"a",
"work",
"transition",
"based",
"on",
"its",
"id",
"value"
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/model/workflow/Process.java#L425-L431 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/model/workflow/Process.java | Process.getActivityById | public Activity getActivityById(String logicalId) {
for (Activity activityVO : getActivities()) {
if (activityVO.getLogicalId().equals(logicalId)) {
activityVO.setProcessName(getName());
return activityVO;
}
}
for (Process subProc : this.subprocesses) {
for (Activity activityVO : subProc.getActivities()) {
if (activityVO.getLogicalId().equals(logicalId)) {
activityVO.setProcessName(getName() + ":" + subProc.getName());
return activityVO;
}
}
}
return null;
} | java | public Activity getActivityById(String logicalId) {
for (Activity activityVO : getActivities()) {
if (activityVO.getLogicalId().equals(logicalId)) {
activityVO.setProcessName(getName());
return activityVO;
}
}
for (Process subProc : this.subprocesses) {
for (Activity activityVO : subProc.getActivities()) {
if (activityVO.getLogicalId().equals(logicalId)) {
activityVO.setProcessName(getName() + ":" + subProc.getName());
return activityVO;
}
}
}
return null;
} | [
"public",
"Activity",
"getActivityById",
"(",
"String",
"logicalId",
")",
"{",
"for",
"(",
"Activity",
"activityVO",
":",
"getActivities",
"(",
")",
")",
"{",
"if",
"(",
"activityVO",
".",
"getLogicalId",
"(",
")",
".",
"equals",
"(",
"logicalId",
")",
")"... | Also searches subprocs. | [
"Also",
"searches",
"subprocs",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/model/workflow/Process.java#L519-L536 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/util/HttpHelper.java | HttpHelper.postBytes | public byte[] postBytes(byte[] content) throws IOException {
if (!connection.isOpen())
connection.open();
connection.prepare("POST");
OutputStream os = connection.getOutputStream();
os.write(content);
response = connection.readInput();
os.close();
return getResponseBytes();
} | java | public byte[] postBytes(byte[] content) throws IOException {
if (!connection.isOpen())
connection.open();
connection.prepare("POST");
OutputStream os = connection.getOutputStream();
os.write(content);
response = connection.readInput();
os.close();
return getResponseBytes();
} | [
"public",
"byte",
"[",
"]",
"postBytes",
"(",
"byte",
"[",
"]",
"content",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"connection",
".",
"isOpen",
"(",
")",
")",
"connection",
".",
"open",
"(",
")",
";",
"connection",
".",
"prepare",
"(",
"\"... | Perform an HTTP POST request to the URL.
@param content string containing the content to be posted
@return string containing the response from the server | [
"Perform",
"an",
"HTTP",
"POST",
"request",
"to",
"the",
"URL",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/util/HttpHelper.java#L109-L122 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/util/HttpHelper.java | HttpHelper.getBytes | public byte[] getBytes() throws IOException {
if (!connection.isOpen())
connection.open();
connection.prepare("GET");
response = connection.readInput();
return getResponseBytes();
} | java | public byte[] getBytes() throws IOException {
if (!connection.isOpen())
connection.open();
connection.prepare("GET");
response = connection.readInput();
return getResponseBytes();
} | [
"public",
"byte",
"[",
"]",
"getBytes",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"connection",
".",
"isOpen",
"(",
")",
")",
"connection",
".",
"open",
"(",
")",
";",
"connection",
".",
"prepare",
"(",
"\"GET\"",
")",
";",
"response",
... | Perform an HTTP GET request against the URL.
@return the string response from the server | [
"Perform",
"an",
"HTTP",
"GET",
"request",
"against",
"the",
"URL",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/util/HttpHelper.java#L132-L139 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/util/HttpHelper.java | HttpHelper.put | public String put(File file) throws IOException {
if (!connection.isOpen())
connection.open();
connection.prepare("PUT");
String contentType = connection.getHeader("Content-Type");
if (contentType == null)
contentType = connection.getHeader("content-type");
if (contentType == null || contentType.isEmpty()) {
/**
* Default it to application/octet-stream if nothing has been specified
*/
connection.setHeader("Content-Type", "application/octet-stream");
}
OutputStream outStream = connection.getOutputStream();
InputStream inStream = new FileInputStream(file);
byte[] buf = new byte[1024];
int len = 0;
while (len != -1)
{
len = inStream.read(buf);
if (len > 0)
outStream.write(buf, 0, len);
}
inStream.close();
outStream.close();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getConnection().getInputStream()));
StringBuffer responseBuffer = new StringBuffer();
String line = null;
while ((line = reader.readLine()) != null) {
responseBuffer.append(line).append('\n');
}
reader.close();
connection.getConnection().disconnect();
response = new HttpResponse(responseBuffer.toString().getBytes());
response.setCode(connection.getConnection().getResponseCode());
if (response.getCode() < 200 || response.getCode() >= 300)
{
response.setMessage(connection.getConnection().getResponseMessage());
throw new IOException("Error uploading file: " + response.getCode() + " -- " + response.getMessage());
}
return getResponse();
} | java | public String put(File file) throws IOException {
if (!connection.isOpen())
connection.open();
connection.prepare("PUT");
String contentType = connection.getHeader("Content-Type");
if (contentType == null)
contentType = connection.getHeader("content-type");
if (contentType == null || contentType.isEmpty()) {
/**
* Default it to application/octet-stream if nothing has been specified
*/
connection.setHeader("Content-Type", "application/octet-stream");
}
OutputStream outStream = connection.getOutputStream();
InputStream inStream = new FileInputStream(file);
byte[] buf = new byte[1024];
int len = 0;
while (len != -1)
{
len = inStream.read(buf);
if (len > 0)
outStream.write(buf, 0, len);
}
inStream.close();
outStream.close();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getConnection().getInputStream()));
StringBuffer responseBuffer = new StringBuffer();
String line = null;
while ((line = reader.readLine()) != null) {
responseBuffer.append(line).append('\n');
}
reader.close();
connection.getConnection().disconnect();
response = new HttpResponse(responseBuffer.toString().getBytes());
response.setCode(connection.getConnection().getResponseCode());
if (response.getCode() < 200 || response.getCode() >= 300)
{
response.setMessage(connection.getConnection().getResponseMessage());
throw new IOException("Error uploading file: " + response.getCode() + " -- " + response.getMessage());
}
return getResponse();
} | [
"public",
"String",
"put",
"(",
"File",
"file",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"connection",
".",
"isOpen",
"(",
")",
")",
"connection",
".",
"open",
"(",
")",
";",
"connection",
".",
"prepare",
"(",
"\"PUT\"",
")",
";",
"String",
... | Upload a text file to the destination URL
@param file the file to be uploaded
@param force whether to overwrite if the destination file is newer
@return string with the response from the server | [
"Upload",
"a",
"text",
"file",
"to",
"the",
"destination",
"URL"
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/util/HttpHelper.java#L247-L299 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/util/HttpHelper.java | HttpHelper.deleteBytes | public byte[] deleteBytes(byte[] content) throws IOException {
if (!connection.isOpen())
connection.open();
connection.prepare("DELETE");
OutputStream os = null;
if (content != null) {
connection.getConnection().setDoOutput(true);
os = connection.getOutputStream();
os.write(content);
}
response = connection.readInput();
if (os != null)
os.close();
return getResponseBytes();
} | java | public byte[] deleteBytes(byte[] content) throws IOException {
if (!connection.isOpen())
connection.open();
connection.prepare("DELETE");
OutputStream os = null;
if (content != null) {
connection.getConnection().setDoOutput(true);
os = connection.getOutputStream();
os.write(content);
}
response = connection.readInput();
if (os != null)
os.close();
return getResponseBytes();
} | [
"public",
"byte",
"[",
"]",
"deleteBytes",
"(",
"byte",
"[",
"]",
"content",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"connection",
".",
"isOpen",
"(",
")",
")",
"connection",
".",
"open",
"(",
")",
";",
"connection",
".",
"prepare",
"(",
"... | Perform an HTTP DELETE request to the URL.
@param content bytes (not usually populated)
@return string containing the response from the server | [
"Perform",
"an",
"HTTP",
"DELETE",
"request",
"to",
"the",
"URL",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/util/HttpHelper.java#L319-L337 | train |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java | EventServicesImpl.getDistinctEventLogEventSources | public String[] getDistinctEventLogEventSources()
throws DataAccessException, EventException {
TransactionWrapper transaction = null;
EngineDataAccessDB edao = new EngineDataAccessDB();
try {
transaction = edao.startTransaction();
return edao.getDistinctEventLogEventSources();
} catch (SQLException e) {
throw new EventException("Failed to notify events", e);
} finally {
edao.stopTransaction(transaction);
}
} | java | public String[] getDistinctEventLogEventSources()
throws DataAccessException, EventException {
TransactionWrapper transaction = null;
EngineDataAccessDB edao = new EngineDataAccessDB();
try {
transaction = edao.startTransaction();
return edao.getDistinctEventLogEventSources();
} catch (SQLException e) {
throw new EventException("Failed to notify events", e);
} finally {
edao.stopTransaction(transaction);
}
} | [
"public",
"String",
"[",
"]",
"getDistinctEventLogEventSources",
"(",
")",
"throws",
"DataAccessException",
",",
"EventException",
"{",
"TransactionWrapper",
"transaction",
"=",
"null",
";",
"EngineDataAccessDB",
"edao",
"=",
"new",
"EngineDataAccessDB",
"(",
")",
";"... | Method that returns distinct event log sources
@return String[] | [
"Method",
"that",
"returns",
"distinct",
"event",
"log",
"sources"
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java#L121-L133 | train |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java | EventServicesImpl.setVariableInstance | public VariableInstance setVariableInstance(Long procInstId, String name, Object value)
throws DataAccessException {
TransactionWrapper transaction = null;
EngineDataAccessDB edao = new EngineDataAccessDB();
try {
transaction = edao.startTransaction();
VariableInstance varInst = edao.getVariableInstance(procInstId, name);
if (varInst != null) {
if (value instanceof String)
varInst.setStringValue((String)value);
else
varInst.setData(value);
edao.updateVariableInstance(varInst);
} else {
if (value != null) {
ProcessInstance procInst = edao.getProcessInstance(procInstId);
Process process = null;
if (procInst.getProcessInstDefId() > 0L)
process = ProcessCache.getProcessInstanceDefiniton(procInst.getProcessId(), procInst.getProcessInstDefId());
if (process == null)
process = ProcessCache.getProcess(procInst.getProcessId());
Variable variable = process.getVariable(name);
if (variable == null) {
throw new DataAccessException("Variable " + name + " is not defined for process " + process.getId());
}
varInst = new VariableInstance();
varInst.setName(name);
varInst.setVariableId(variable.getId());
varInst.setType(variable.getType());
if (value instanceof String) varInst.setStringValue((String)value);
else varInst.setData(value);
edao.createVariableInstance(varInst, procInstId);
} else varInst = null;
}
return varInst;
} catch (SQLException e) {
throw new DataAccessException(-1, "Failed to set variable value", e);
} finally {
edao.stopTransaction(transaction);
}
} | java | public VariableInstance setVariableInstance(Long procInstId, String name, Object value)
throws DataAccessException {
TransactionWrapper transaction = null;
EngineDataAccessDB edao = new EngineDataAccessDB();
try {
transaction = edao.startTransaction();
VariableInstance varInst = edao.getVariableInstance(procInstId, name);
if (varInst != null) {
if (value instanceof String)
varInst.setStringValue((String)value);
else
varInst.setData(value);
edao.updateVariableInstance(varInst);
} else {
if (value != null) {
ProcessInstance procInst = edao.getProcessInstance(procInstId);
Process process = null;
if (procInst.getProcessInstDefId() > 0L)
process = ProcessCache.getProcessInstanceDefiniton(procInst.getProcessId(), procInst.getProcessInstDefId());
if (process == null)
process = ProcessCache.getProcess(procInst.getProcessId());
Variable variable = process.getVariable(name);
if (variable == null) {
throw new DataAccessException("Variable " + name + " is not defined for process " + process.getId());
}
varInst = new VariableInstance();
varInst.setName(name);
varInst.setVariableId(variable.getId());
varInst.setType(variable.getType());
if (value instanceof String) varInst.setStringValue((String)value);
else varInst.setData(value);
edao.createVariableInstance(varInst, procInstId);
} else varInst = null;
}
return varInst;
} catch (SQLException e) {
throw new DataAccessException(-1, "Failed to set variable value", e);
} finally {
edao.stopTransaction(transaction);
}
} | [
"public",
"VariableInstance",
"setVariableInstance",
"(",
"Long",
"procInstId",
",",
"String",
"name",
",",
"Object",
"value",
")",
"throws",
"DataAccessException",
"{",
"TransactionWrapper",
"transaction",
"=",
"null",
";",
"EngineDataAccessDB",
"edao",
"=",
"new",
... | create or update variable instance value.
This does not take care of checking for embedded processes.
For document variables, the value must be DocumentReference, not the document content | [
"create",
"or",
"update",
"variable",
"instance",
"value",
".",
"This",
"does",
"not",
"take",
"care",
"of",
"checking",
"for",
"embedded",
"processes",
".",
"For",
"document",
"variables",
"the",
"value",
"must",
"be",
"DocumentReference",
"not",
"the",
"docu... | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java#L140-L182 | train |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java | EventServicesImpl.sendDelayEventsToWaitActivities | public void sendDelayEventsToWaitActivities(String masterRequestId)
throws DataAccessException, ProcessException {
TransactionWrapper transaction = null;
EngineDataAccessDB edao = new EngineDataAccessDB();
try {
transaction = edao.startTransaction();
List<ProcessInstance> procInsts = edao.getProcessInstancesByMasterRequestId(masterRequestId, null);
for (ProcessInstance pi : procInsts) {
List<ActivityInstance> actInsts = edao.getActivityInstancesForProcessInstance(pi.getId());
for (ActivityInstance ai : actInsts) {
if (ai.getStatusCode()==WorkStatus.STATUS_WAITING.intValue()) {
InternalEvent event = InternalEvent.createActivityDelayMessage(ai,
masterRequestId);
this.sendInternalEvent(event, edao);
}
}
}
} catch (SQLException e) {
throw new ProcessException(0, "Failed to send delay event wait activities runtime", e);
} finally {
edao.stopTransaction(transaction);
}
} | java | public void sendDelayEventsToWaitActivities(String masterRequestId)
throws DataAccessException, ProcessException {
TransactionWrapper transaction = null;
EngineDataAccessDB edao = new EngineDataAccessDB();
try {
transaction = edao.startTransaction();
List<ProcessInstance> procInsts = edao.getProcessInstancesByMasterRequestId(masterRequestId, null);
for (ProcessInstance pi : procInsts) {
List<ActivityInstance> actInsts = edao.getActivityInstancesForProcessInstance(pi.getId());
for (ActivityInstance ai : actInsts) {
if (ai.getStatusCode()==WorkStatus.STATUS_WAITING.intValue()) {
InternalEvent event = InternalEvent.createActivityDelayMessage(ai,
masterRequestId);
this.sendInternalEvent(event, edao);
}
}
}
} catch (SQLException e) {
throw new ProcessException(0, "Failed to send delay event wait activities runtime", e);
} finally {
edao.stopTransaction(transaction);
}
} | [
"public",
"void",
"sendDelayEventsToWaitActivities",
"(",
"String",
"masterRequestId",
")",
"throws",
"DataAccessException",
",",
"ProcessException",
"{",
"TransactionWrapper",
"transaction",
"=",
"null",
";",
"EngineDataAccessDB",
"edao",
"=",
"new",
"EngineDataAccessDB",
... | This is for regression tester only.
@param masterRequestId | [
"This",
"is",
"for",
"regression",
"tester",
"only",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java#L216-L238 | train |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java | EventServicesImpl.isProcessInstanceResumable | private boolean isProcessInstanceResumable(ProcessInstance pInstance) {
int statusCd = pInstance.getStatusCode().intValue();
if (statusCd == WorkStatus.STATUS_COMPLETED.intValue()) {
return false;
} else if (statusCd == WorkStatus.STATUS_CANCELLED.intValue()) {
return false;
}
return true;
} | java | private boolean isProcessInstanceResumable(ProcessInstance pInstance) {
int statusCd = pInstance.getStatusCode().intValue();
if (statusCd == WorkStatus.STATUS_COMPLETED.intValue()) {
return false;
} else if (statusCd == WorkStatus.STATUS_CANCELLED.intValue()) {
return false;
}
return true;
} | [
"private",
"boolean",
"isProcessInstanceResumable",
"(",
"ProcessInstance",
"pInstance",
")",
"{",
"int",
"statusCd",
"=",
"pInstance",
".",
"getStatusCode",
"(",
")",
".",
"intValue",
"(",
")",
";",
"if",
"(",
"statusCd",
"==",
"WorkStatus",
".",
"STATUS_COMPLE... | Checks if the process inst is resumable
@param pInstance
@return boolean status | [
"Checks",
"if",
"the",
"process",
"inst",
"is",
"resumable"
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java#L334-L343 | train |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java | EventServicesImpl.getProcessInstance | public ProcessInstance getProcessInstance(Long procInstId)
throws ProcessException, DataAccessException {
TransactionWrapper transaction = null;
EngineDataAccessDB edao = new EngineDataAccessDB();
try {
transaction = edao.startTransaction();
return edao.getProcessInstance(procInstId);
} catch (SQLException e) {
throw new ProcessException(0, "Failed to get process instance", e);
} finally {
edao.stopTransaction(transaction);
}
} | java | public ProcessInstance getProcessInstance(Long procInstId)
throws ProcessException, DataAccessException {
TransactionWrapper transaction = null;
EngineDataAccessDB edao = new EngineDataAccessDB();
try {
transaction = edao.startTransaction();
return edao.getProcessInstance(procInstId);
} catch (SQLException e) {
throw new ProcessException(0, "Failed to get process instance", e);
} finally {
edao.stopTransaction(transaction);
}
} | [
"public",
"ProcessInstance",
"getProcessInstance",
"(",
"Long",
"procInstId",
")",
"throws",
"ProcessException",
",",
"DataAccessException",
"{",
"TransactionWrapper",
"transaction",
"=",
"null",
";",
"EngineDataAccessDB",
"edao",
"=",
"new",
"EngineDataAccessDB",
"(",
... | Returns the ProcessInstance identified by the passed in Id
@param procInstId
@return ProcessInstance | [
"Returns",
"the",
"ProcessInstance",
"identified",
"by",
"the",
"passed",
"in",
"Id"
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java#L351-L364 | train |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java | EventServicesImpl.getProcessInstances | @Override
public List<ProcessInstance> getProcessInstances(String masterRequestId, String processName)
throws ProcessException, DataAccessException {
TransactionWrapper transaction = null;
EngineDataAccessDB edao = new EngineDataAccessDB();
try {
Process procdef = ProcessCache.getProcess(processName, 0);
if (procdef==null) return null;
transaction = edao.startTransaction();
return edao.getProcessInstancesByMasterRequestId(masterRequestId, procdef.getId());
} catch (SQLException e) {
throw new ProcessException(0, "Failed to remove event waits", e);
} finally {
edao.stopTransaction(transaction);
}
} | java | @Override
public List<ProcessInstance> getProcessInstances(String masterRequestId, String processName)
throws ProcessException, DataAccessException {
TransactionWrapper transaction = null;
EngineDataAccessDB edao = new EngineDataAccessDB();
try {
Process procdef = ProcessCache.getProcess(processName, 0);
if (procdef==null) return null;
transaction = edao.startTransaction();
return edao.getProcessInstancesByMasterRequestId(masterRequestId, procdef.getId());
} catch (SQLException e) {
throw new ProcessException(0, "Failed to remove event waits", e);
} finally {
edao.stopTransaction(transaction);
}
} | [
"@",
"Override",
"public",
"List",
"<",
"ProcessInstance",
">",
"getProcessInstances",
"(",
"String",
"masterRequestId",
",",
"String",
"processName",
")",
"throws",
"ProcessException",
",",
"DataAccessException",
"{",
"TransactionWrapper",
"transaction",
"=",
"null",
... | Returns the process instances by process name and master request ID.
@param processName
@param masterRequestId
@return the list of process instances. If the process definition is not found, null
is returned; if process definition is found but no process instances are found,
an empty list is returned.
@throws ProcessException
@throws DataAccessException | [
"Returns",
"the",
"process",
"instances",
"by",
"process",
"name",
"and",
"master",
"request",
"ID",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java#L377-L392 | train |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java | EventServicesImpl.getActivityInstances | public List<ActivityInstance> getActivityInstances(String masterRequestId, String processName, String activityLogicalId)
throws ProcessException, DataAccessException {
TransactionWrapper transaction = null;
EngineDataAccessDB edao = new EngineDataAccessDB();
try {
Process procdef = ProcessCache.getProcess(processName, 0);
if (procdef==null) return null;
Activity actdef = procdef.getActivityByLogicalId(activityLogicalId);
if (actdef==null) return null;
transaction = edao.startTransaction();
List<ActivityInstance> actInstList = new ArrayList<ActivityInstance>();
List<ProcessInstance> procInstList =
edao.getProcessInstancesByMasterRequestId(masterRequestId, procdef.getId());
if (procInstList.size()==0) return actInstList;
for (ProcessInstance pi : procInstList) {
List<ActivityInstance> actInsts = edao.getActivityInstances(actdef.getId(), pi.getId(), false, false);
for (ActivityInstance ai : actInsts) {
actInstList.add(ai);
}
}
return actInstList;
} catch (SQLException e) {
throw new ProcessException(0, "Failed to remove event waits", e);
} finally {
edao.stopTransaction(transaction);
}
} | java | public List<ActivityInstance> getActivityInstances(String masterRequestId, String processName, String activityLogicalId)
throws ProcessException, DataAccessException {
TransactionWrapper transaction = null;
EngineDataAccessDB edao = new EngineDataAccessDB();
try {
Process procdef = ProcessCache.getProcess(processName, 0);
if (procdef==null) return null;
Activity actdef = procdef.getActivityByLogicalId(activityLogicalId);
if (actdef==null) return null;
transaction = edao.startTransaction();
List<ActivityInstance> actInstList = new ArrayList<ActivityInstance>();
List<ProcessInstance> procInstList =
edao.getProcessInstancesByMasterRequestId(masterRequestId, procdef.getId());
if (procInstList.size()==0) return actInstList;
for (ProcessInstance pi : procInstList) {
List<ActivityInstance> actInsts = edao.getActivityInstances(actdef.getId(), pi.getId(), false, false);
for (ActivityInstance ai : actInsts) {
actInstList.add(ai);
}
}
return actInstList;
} catch (SQLException e) {
throw new ProcessException(0, "Failed to remove event waits", e);
} finally {
edao.stopTransaction(transaction);
}
} | [
"public",
"List",
"<",
"ActivityInstance",
">",
"getActivityInstances",
"(",
"String",
"masterRequestId",
",",
"String",
"processName",
",",
"String",
"activityLogicalId",
")",
"throws",
"ProcessException",
",",
"DataAccessException",
"{",
"TransactionWrapper",
"transacti... | Returns the activity instances by process name, activity logical ID, and master request ID.
@param processName
@param activityLogicalId
@param masterRequestId
@return the list of activity instances. If the process definition or the activity
with the given logical ID is not found, null
is returned; if process definition is found but no process instances are found,
or no such activity instances are found, an empty list is returned.
@throws ProcessException
@throws DataAccessException | [
"Returns",
"the",
"activity",
"instances",
"by",
"process",
"name",
"activity",
"logical",
"ID",
"and",
"master",
"request",
"ID",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java#L407-L433 | train |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java | EventServicesImpl.getActivityInstance | public ActivityInstance getActivityInstance(Long pActivityInstId)
throws ProcessException, DataAccessException {
ActivityInstance ai;
TransactionWrapper transaction = null;
EngineDataAccessDB edao = new EngineDataAccessDB();
try {
transaction = edao.startTransaction();
ai = edao.getActivityInstance(pActivityInstId);
} catch (SQLException e) {
throw new ProcessException(0, "Failed to get activity instance", e);
} finally {
edao.stopTransaction(transaction);
}
return ai;
} | java | public ActivityInstance getActivityInstance(Long pActivityInstId)
throws ProcessException, DataAccessException {
ActivityInstance ai;
TransactionWrapper transaction = null;
EngineDataAccessDB edao = new EngineDataAccessDB();
try {
transaction = edao.startTransaction();
ai = edao.getActivityInstance(pActivityInstId);
} catch (SQLException e) {
throw new ProcessException(0, "Failed to get activity instance", e);
} finally {
edao.stopTransaction(transaction);
}
return ai;
} | [
"public",
"ActivityInstance",
"getActivityInstance",
"(",
"Long",
"pActivityInstId",
")",
"throws",
"ProcessException",
",",
"DataAccessException",
"{",
"ActivityInstance",
"ai",
";",
"TransactionWrapper",
"transaction",
"=",
"null",
";",
"EngineDataAccessDB",
"edao",
"="... | Returns the ActivityInstance identified by the passed in Id
@param pActivityInstId
@return ActivityInstance | [
"Returns",
"the",
"ActivityInstance",
"identified",
"by",
"the",
"passed",
"in",
"Id"
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java#L441-L455 | train |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java | EventServicesImpl.getWorkTransitionInstance | public TransitionInstance getWorkTransitionInstance(Long pId)
throws DataAccessException, ProcessException {
TransitionInstance wti;
TransactionWrapper transaction = null;
EngineDataAccessDB edao = new EngineDataAccessDB();
try {
transaction = edao.startTransaction();
wti = edao.getWorkTransitionInstance(pId);
} catch (SQLException e) {
throw new ProcessException(0, "Failed to get work transition instance", e);
} finally {
edao.stopTransaction(transaction);
}
return wti;
} | java | public TransitionInstance getWorkTransitionInstance(Long pId)
throws DataAccessException, ProcessException {
TransitionInstance wti;
TransactionWrapper transaction = null;
EngineDataAccessDB edao = new EngineDataAccessDB();
try {
transaction = edao.startTransaction();
wti = edao.getWorkTransitionInstance(pId);
} catch (SQLException e) {
throw new ProcessException(0, "Failed to get work transition instance", e);
} finally {
edao.stopTransaction(transaction);
}
return wti;
} | [
"public",
"TransitionInstance",
"getWorkTransitionInstance",
"(",
"Long",
"pId",
")",
"throws",
"DataAccessException",
",",
"ProcessException",
"{",
"TransitionInstance",
"wti",
";",
"TransactionWrapper",
"transaction",
"=",
"null",
";",
"EngineDataAccessDB",
"edao",
"=",... | Returns the WorkTransitionVO based on the passed in params
@param pId
@return WorkTransitionINstance | [
"Returns",
"the",
"WorkTransitionVO",
"based",
"on",
"the",
"passed",
"in",
"params"
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java#L463-L477 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/model/Value.java | Value.getJson | public JSONObject getJson() throws JSONException {
JSONObject json = create();
if (value != null)
json.put("value", value);
if (label != null)
json.put("label", label);
if (type != null)
json.put("type", type);
if (display != null)
json.put("display", display.toString());
if (sequence != 0)
json.put("sequence", sequence);
if (indexKey != null)
json.put("indexKey", indexKey);
return json;
} | java | public JSONObject getJson() throws JSONException {
JSONObject json = create();
if (value != null)
json.put("value", value);
if (label != null)
json.put("label", label);
if (type != null)
json.put("type", type);
if (display != null)
json.put("display", display.toString());
if (sequence != 0)
json.put("sequence", sequence);
if (indexKey != null)
json.put("indexKey", indexKey);
return json;
} | [
"public",
"JSONObject",
"getJson",
"(",
")",
"throws",
"JSONException",
"{",
"JSONObject",
"json",
"=",
"create",
"(",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"json",
".",
"put",
"(",
"\"value\"",
",",
"value",
")",
";",
"if",
"(",
"label",
... | expects to be a json object named 'name',
so does not include name | [
"expects",
"to",
"be",
"a",
"json",
"object",
"named",
"name",
"so",
"does",
"not",
"include",
"name"
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/model/Value.java#L99-L114 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/model/Value.java | Value.getDisplay | @ApiModelProperty(hidden=true)
public static Display getDisplay(String option) {
if ("Optional".equals(option))
return Display.Optional;
else if ("Required".equals(option))
return Display.Required;
else if ("Read Only".equals(option))
return Display.ReadOnly;
else if ("Hidden".equals(option))
return Display.Hidden;
else
return null;
} | java | @ApiModelProperty(hidden=true)
public static Display getDisplay(String option) {
if ("Optional".equals(option))
return Display.Optional;
else if ("Required".equals(option))
return Display.Required;
else if ("Read Only".equals(option))
return Display.ReadOnly;
else if ("Hidden".equals(option))
return Display.Hidden;
else
return null;
} | [
"@",
"ApiModelProperty",
"(",
"hidden",
"=",
"true",
")",
"public",
"static",
"Display",
"getDisplay",
"(",
"String",
"option",
")",
"{",
"if",
"(",
"\"Optional\"",
".",
"equals",
"(",
"option",
")",
")",
"return",
"Display",
".",
"Optional",
";",
"else",
... | Maps Designer display option to Display type. | [
"Maps",
"Designer",
"display",
"option",
"to",
"Display",
"type",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/model/Value.java#L128-L140 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/model/Value.java | Value.getDisplay | public static Display getDisplay(int mode) {
if (mode == 0)
return Display.Required;
else if (mode == 1)
return Display.Optional;
else if (mode == 2)
return Display.ReadOnly;
else if (mode == 3)
return Display.Hidden;
else
return null;
} | java | public static Display getDisplay(int mode) {
if (mode == 0)
return Display.Required;
else if (mode == 1)
return Display.Optional;
else if (mode == 2)
return Display.ReadOnly;
else if (mode == 3)
return Display.Hidden;
else
return null;
} | [
"public",
"static",
"Display",
"getDisplay",
"(",
"int",
"mode",
")",
"{",
"if",
"(",
"mode",
"==",
"0",
")",
"return",
"Display",
".",
"Required",
";",
"else",
"if",
"(",
"mode",
"==",
"1",
")",
"return",
"Display",
".",
"Optional",
";",
"else",
"if... | Maps VariableVO display mode to Display type. | [
"Maps",
"VariableVO",
"display",
"mode",
"to",
"Display",
"type",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/model/Value.java#L145-L156 | train |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/timer/startup/UserGroupMonitor.java | UserGroupMonitor.onStartup | public void onStartup() throws StartupException {
if (monitor == null) {
monitor = this;
thread = new Thread() {
@Override
public void run() {
this.setName("UserGroupMonitor-thread");
monitor.start();
}
};
thread.start();
}
} | java | public void onStartup() throws StartupException {
if (monitor == null) {
monitor = this;
thread = new Thread() {
@Override
public void run() {
this.setName("UserGroupMonitor-thread");
monitor.start();
}
};
thread.start();
}
} | [
"public",
"void",
"onStartup",
"(",
")",
"throws",
"StartupException",
"{",
"if",
"(",
"monitor",
"==",
"null",
")",
"{",
"monitor",
"=",
"this",
";",
"thread",
"=",
"new",
"Thread",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
... | Invoked when the server starts up. | [
"Invoked",
"when",
"the",
"server",
"starts",
"up",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/timer/startup/UserGroupMonitor.java#L45-L57 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/util/JMSServices.java | JMSServices.sendTextMessage | public void sendTextMessage(String queueName, String message, int delaySeconds)
throws NamingException, JMSException, ServiceLocatorException {
sendTextMessage(null, queueName, message, delaySeconds, null);
} | java | public void sendTextMessage(String queueName, String message, int delaySeconds)
throws NamingException, JMSException, ServiceLocatorException {
sendTextMessage(null, queueName, message, delaySeconds, null);
} | [
"public",
"void",
"sendTextMessage",
"(",
"String",
"queueName",
",",
"String",
"message",
",",
"int",
"delaySeconds",
")",
"throws",
"NamingException",
",",
"JMSException",
",",
"ServiceLocatorException",
"{",
"sendTextMessage",
"(",
"null",
",",
"queueName",
",",
... | Sends a JMS text message to a local queue.
@param queueName
local queues are based on logical queue names
@param message
the message string
@param delaySeconds
0 for immediate
@throws ServiceLocatorException | [
"Sends",
"a",
"JMS",
"text",
"message",
"to",
"a",
"local",
"queue",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/util/JMSServices.java#L117-L120 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/util/JMSServices.java | JMSServices.sendTextMessage | public void sendTextMessage(String contextUrl, String queueName, String message,
int delaySeconds, String correlationId)
throws NamingException, JMSException, ServiceLocatorException {
if (logger.isDebugEnabled())
logger.debug("Send JMS message: " + message);
if (mdwMessageProducer != null) {
if (logger.isDebugEnabled())
logger.debug("Send JMS message: queue " + queueName + " corrId " + correlationId
+ " delay " + delaySeconds);
mdwMessageProducer.sendMessage(message, queueName, correlationId, delaySeconds,
DeliveryMode.NON_PERSISTENT);
}
else {
QueueConnection connection = null;
QueueSession session = null;
QueueSender sender = null;
Queue queue = null;
try {
QueueConnectionFactory connectionFactory = getQueueConnectionFactory(contextUrl);
connection = connectionFactory.createQueueConnection();
session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
if (contextUrl == null)
queue = getQueue(session, queueName);
else
queue = getQueue(contextUrl, queueName);
if (queue == null)
queue = session.createQueue(queueName);
sender = session.createSender(queue);
TextMessage textMessage = session.createTextMessage(message);
if (delaySeconds > 0)
jmsProvider.setMessageDelay(sender, textMessage, delaySeconds);
if (correlationId != null)
textMessage.setJMSCorrelationID(correlationId);
connection.start();
if (contextUrl == null)
sender.send(textMessage, DeliveryMode.NON_PERSISTENT, sender.getPriority(),
sender.getTimeToLive());
else
sender.send(textMessage);
// }
// catch(ServiceLocatorException ex) {
// logger.severeException(ex.getMessage(), ex);
// JMSException jmsEx = new JMSException(ex.getMessage());
// jmsEx.setLinkedException(ex);
// throw jmsEx;
}
finally {
closeResources(connection, session, sender);
}
}
} | java | public void sendTextMessage(String contextUrl, String queueName, String message,
int delaySeconds, String correlationId)
throws NamingException, JMSException, ServiceLocatorException {
if (logger.isDebugEnabled())
logger.debug("Send JMS message: " + message);
if (mdwMessageProducer != null) {
if (logger.isDebugEnabled())
logger.debug("Send JMS message: queue " + queueName + " corrId " + correlationId
+ " delay " + delaySeconds);
mdwMessageProducer.sendMessage(message, queueName, correlationId, delaySeconds,
DeliveryMode.NON_PERSISTENT);
}
else {
QueueConnection connection = null;
QueueSession session = null;
QueueSender sender = null;
Queue queue = null;
try {
QueueConnectionFactory connectionFactory = getQueueConnectionFactory(contextUrl);
connection = connectionFactory.createQueueConnection();
session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
if (contextUrl == null)
queue = getQueue(session, queueName);
else
queue = getQueue(contextUrl, queueName);
if (queue == null)
queue = session.createQueue(queueName);
sender = session.createSender(queue);
TextMessage textMessage = session.createTextMessage(message);
if (delaySeconds > 0)
jmsProvider.setMessageDelay(sender, textMessage, delaySeconds);
if (correlationId != null)
textMessage.setJMSCorrelationID(correlationId);
connection.start();
if (contextUrl == null)
sender.send(textMessage, DeliveryMode.NON_PERSISTENT, sender.getPriority(),
sender.getTimeToLive());
else
sender.send(textMessage);
// }
// catch(ServiceLocatorException ex) {
// logger.severeException(ex.getMessage(), ex);
// JMSException jmsEx = new JMSException(ex.getMessage());
// jmsEx.setLinkedException(ex);
// throw jmsEx;
}
finally {
closeResources(connection, session, sender);
}
}
} | [
"public",
"void",
"sendTextMessage",
"(",
"String",
"contextUrl",
",",
"String",
"queueName",
",",
"String",
"message",
",",
"int",
"delaySeconds",
",",
"String",
"correlationId",
")",
"throws",
"NamingException",
",",
"JMSException",
",",
"ServiceLocatorException",
... | Sends a JMS text message.
@param contextUrl
null for local queues
@param queueName
local queues are based on logical queue names
@param message
the message string
@param delaySeconds
0 for immediate
@throws ServiceLocatorException | [
"Sends",
"a",
"JMS",
"text",
"message",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/util/JMSServices.java#L135-L190 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/util/JMSServices.java | JMSServices.getQueue | public Queue getQueue(Session session, String commonName) throws ServiceLocatorException {
Queue queue = (Queue) queueCache.get(commonName);
if (queue == null) {
try {
String name = namingProvider.qualifyJmsQueueName(commonName);
queue = jmsProvider.getQueue(session, namingProvider, name);
if (queue != null)
queueCache.put(commonName, queue);
}
catch (Exception ex) {
throw new ServiceLocatorException(-1, ex.getMessage(), ex);
}
}
return queue;
} | java | public Queue getQueue(Session session, String commonName) throws ServiceLocatorException {
Queue queue = (Queue) queueCache.get(commonName);
if (queue == null) {
try {
String name = namingProvider.qualifyJmsQueueName(commonName);
queue = jmsProvider.getQueue(session, namingProvider, name);
if (queue != null)
queueCache.put(commonName, queue);
}
catch (Exception ex) {
throw new ServiceLocatorException(-1, ex.getMessage(), ex);
}
}
return queue;
} | [
"public",
"Queue",
"getQueue",
"(",
"Session",
"session",
",",
"String",
"commonName",
")",
"throws",
"ServiceLocatorException",
"{",
"Queue",
"queue",
"=",
"(",
"Queue",
")",
"queueCache",
".",
"get",
"(",
"commonName",
")",
";",
"if",
"(",
"queue",
"==",
... | Uses the container-specific qualifier to look up a JMS queue.
@param commonName
the vendor-neutral logical queue name
@return javax.jms.Queue | [
"Uses",
"the",
"container",
"-",
"specific",
"qualifier",
"to",
"look",
"up",
"a",
"JMS",
"queue",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/util/JMSServices.java#L221-L235 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/util/JMSServices.java | JMSServices.getQueue | public Queue getQueue(String contextUrl, String queueName) throws ServiceLocatorException {
try {
String jndiName = null;
if (contextUrl == null) {
jndiName = namingProvider.qualifyJmsQueueName(queueName);
}
else {
jndiName = queueName; // don't qualify remote queue names
}
return (Queue) namingProvider.lookup(contextUrl, jndiName, Queue.class);
}
catch (Exception ex) {
throw new ServiceLocatorException(-1, ex.getMessage(), ex);
}
} | java | public Queue getQueue(String contextUrl, String queueName) throws ServiceLocatorException {
try {
String jndiName = null;
if (contextUrl == null) {
jndiName = namingProvider.qualifyJmsQueueName(queueName);
}
else {
jndiName = queueName; // don't qualify remote queue names
}
return (Queue) namingProvider.lookup(contextUrl, jndiName, Queue.class);
}
catch (Exception ex) {
throw new ServiceLocatorException(-1, ex.getMessage(), ex);
}
} | [
"public",
"Queue",
"getQueue",
"(",
"String",
"contextUrl",
",",
"String",
"queueName",
")",
"throws",
"ServiceLocatorException",
"{",
"try",
"{",
"String",
"jndiName",
"=",
"null",
";",
"if",
"(",
"contextUrl",
"==",
"null",
")",
"{",
"jndiName",
"=",
"nami... | Looks up and returns a JMS queue.
@param queueName
remote queue name
@param contextUrl
the context url (or null for local)
@return javax.jms.Queue | [
"Looks",
"up",
"and",
"returns",
"a",
"JMS",
"queue",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/util/JMSServices.java#L246-L260 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/util/JMSServices.java | JMSServices.broadcastTextMessage | public void broadcastTextMessage(String topicName, String textMessage, int delaySeconds)
throws NamingException, JMSException, ServiceLocatorException {
if (mdwMessageProducer != null) {
mdwMessageProducer.broadcastMessageToTopic(topicName, textMessage);
}
else {
TopicConnectionFactory tFactory = null;
TopicConnection tConnection = null;
TopicSession tSession = null;
TopicPublisher tPublisher = null;
try {
// if (logger.isDebugEnabled()) logger.debug("broadcast JMS
// message: " +
// textMessage);
// cannot log above - causing recursive broadcasting
tFactory = getTopicConnectionFactory(null);
tConnection = tFactory.createTopicConnection();
tSession = tConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
Topic topic = getTopic(topicName);
tPublisher = tSession.createPublisher(topic);
// TODO: platform-independent delay
// WLMessageProducer wlMessageProducer =
// (WLMessageProducer)tPublisher;
// long delayInMilliSec = 0;
// if(pMinDelay > 0){
// delayInMilliSec = delaySeconds*1000;
// }
// wlMessageProducer.setTimeToDeliver(delayInMilliSec);
TextMessage message = tSession.createTextMessage();
tConnection.start();
message.setText(textMessage);
tPublisher.publish(message, DeliveryMode.PERSISTENT,
TextMessage.DEFAULT_DELIVERY_MODE, TextMessage.DEFAULT_TIME_TO_LIVE);
// }catch(ServiceLocatorException ex){
// ex.printStackTrace();
// never log exception here!!! infinite loop when publishing log
// messages
// throw new JMSException(ex.getMessage());
}
finally {
closeResources(tConnection, tSession, tPublisher);
}
}
} | java | public void broadcastTextMessage(String topicName, String textMessage, int delaySeconds)
throws NamingException, JMSException, ServiceLocatorException {
if (mdwMessageProducer != null) {
mdwMessageProducer.broadcastMessageToTopic(topicName, textMessage);
}
else {
TopicConnectionFactory tFactory = null;
TopicConnection tConnection = null;
TopicSession tSession = null;
TopicPublisher tPublisher = null;
try {
// if (logger.isDebugEnabled()) logger.debug("broadcast JMS
// message: " +
// textMessage);
// cannot log above - causing recursive broadcasting
tFactory = getTopicConnectionFactory(null);
tConnection = tFactory.createTopicConnection();
tSession = tConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
Topic topic = getTopic(topicName);
tPublisher = tSession.createPublisher(topic);
// TODO: platform-independent delay
// WLMessageProducer wlMessageProducer =
// (WLMessageProducer)tPublisher;
// long delayInMilliSec = 0;
// if(pMinDelay > 0){
// delayInMilliSec = delaySeconds*1000;
// }
// wlMessageProducer.setTimeToDeliver(delayInMilliSec);
TextMessage message = tSession.createTextMessage();
tConnection.start();
message.setText(textMessage);
tPublisher.publish(message, DeliveryMode.PERSISTENT,
TextMessage.DEFAULT_DELIVERY_MODE, TextMessage.DEFAULT_TIME_TO_LIVE);
// }catch(ServiceLocatorException ex){
// ex.printStackTrace();
// never log exception here!!! infinite loop when publishing log
// messages
// throw new JMSException(ex.getMessage());
}
finally {
closeResources(tConnection, tSession, tPublisher);
}
}
} | [
"public",
"void",
"broadcastTextMessage",
"(",
"String",
"topicName",
",",
"String",
"textMessage",
",",
"int",
"delaySeconds",
")",
"throws",
"NamingException",
",",
"JMSException",
",",
"ServiceLocatorException",
"{",
"if",
"(",
"mdwMessageProducer",
"!=",
"null",
... | Sends the passed in text message to a local topic
@param topicName
@param pMessage
@param delaySeconds
@throws ServiceLocatorException | [
"Sends",
"the",
"passed",
"in",
"text",
"message",
"to",
"a",
"local",
"topic"
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/util/JMSServices.java#L299-L345 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/dataaccess/DatabaseAccess.java | DatabaseAccess.runSelect | public ResultSet runSelect(String logMessage, String query, Object[] arguments) throws SQLException {
long before = System.currentTimeMillis();
try {
return runSelect(query, arguments);
}
finally {
if (logger.isDebugEnabled()) {
long after = System.currentTimeMillis();
logger.debug(logMessage + " (" + (after - before) + " ms): " + DbAccess.substitute(query, arguments));
}
}
} | java | public ResultSet runSelect(String logMessage, String query, Object[] arguments) throws SQLException {
long before = System.currentTimeMillis();
try {
return runSelect(query, arguments);
}
finally {
if (logger.isDebugEnabled()) {
long after = System.currentTimeMillis();
logger.debug(logMessage + " (" + (after - before) + " ms): " + DbAccess.substitute(query, arguments));
}
}
} | [
"public",
"ResultSet",
"runSelect",
"(",
"String",
"logMessage",
",",
"String",
"query",
",",
"Object",
"[",
"]",
"arguments",
")",
"throws",
"SQLException",
"{",
"long",
"before",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"try",
"{",
"return",... | Ordinarily db query logging is at TRACE level. Use this method
to log queries at DEBUG level. | [
"Ordinarily",
"db",
"query",
"logging",
"is",
"at",
"TRACE",
"level",
".",
"Use",
"this",
"method",
"to",
"log",
"queries",
"at",
"DEBUG",
"level",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/dataaccess/DatabaseAccess.java#L436-L447 | train |
CenturyLinkCloud/mdw | mdw-workflow/assets/com/centurylink/mdw/drools/DroolsActivity.java | DroolsActivity.getKnowledgeBase | protected KieBase getKnowledgeBase(String name, String version) throws ActivityException {
return getKnowledgeBase(name, version, null);
} | java | protected KieBase getKnowledgeBase(String name, String version) throws ActivityException {
return getKnowledgeBase(name, version, null);
} | [
"protected",
"KieBase",
"getKnowledgeBase",
"(",
"String",
"name",
",",
"String",
"version",
")",
"throws",
"ActivityException",
"{",
"return",
"getKnowledgeBase",
"(",
"name",
",",
"version",
",",
"null",
")",
";",
"}"
] | Get knowledge base with no modifiers. | [
"Get",
"knowledge",
"base",
"with",
"no",
"modifiers",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-workflow/assets/com/centurylink/mdw/drools/DroolsActivity.java#L103-L105 | train |
CenturyLinkCloud/mdw | mdw-workflow/assets/com/centurylink/mdw/drools/DroolsActivity.java | DroolsActivity.getClassLoader | protected ClassLoader getClassLoader() {
ClassLoader loader = null;
Package pkg = PackageCache.getProcessPackage(getProcessId());
if (pkg != null) {
loader = pkg.getCloudClassLoader();
}
if (loader == null) {
loader = getClass().getClassLoader();
}
return loader;
} | java | protected ClassLoader getClassLoader() {
ClassLoader loader = null;
Package pkg = PackageCache.getProcessPackage(getProcessId());
if (pkg != null) {
loader = pkg.getCloudClassLoader();
}
if (loader == null) {
loader = getClass().getClassLoader();
}
return loader;
} | [
"protected",
"ClassLoader",
"getClassLoader",
"(",
")",
"{",
"ClassLoader",
"loader",
"=",
"null",
";",
"Package",
"pkg",
"=",
"PackageCache",
".",
"getProcessPackage",
"(",
"getProcessId",
"(",
")",
")",
";",
"if",
"(",
"pkg",
"!=",
"null",
")",
"{",
"loa... | Get the class loader based on package bundle version spec
default is mdw-workflow loader
@return | [
"Get",
"the",
"class",
"loader",
"based",
"on",
"package",
"bundle",
"version",
"spec",
"default",
"is",
"mdw",
"-",
"workflow",
"loader"
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-workflow/assets/com/centurylink/mdw/drools/DroolsActivity.java#L137-L147 | train |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/service/rest/System.java | System.getRoles | public List<String> getRoles(String path) {
List<String> roles = super.getRoles(path);
roles.add(Role.ASSET_DESIGN);
return roles;
} | java | public List<String> getRoles(String path) {
List<String> roles = super.getRoles(path);
roles.add(Role.ASSET_DESIGN);
return roles;
} | [
"public",
"List",
"<",
"String",
">",
"getRoles",
"(",
"String",
"path",
")",
"{",
"List",
"<",
"String",
">",
"roles",
"=",
"super",
".",
"getRoles",
"(",
"path",
")",
";",
"roles",
".",
"add",
"(",
"Role",
".",
"ASSET_DESIGN",
")",
";",
"return",
... | ASSET_DESIGN role can PUT in-memory config for running tests. | [
"ASSET_DESIGN",
"role",
"can",
"PUT",
"in",
"-",
"memory",
"config",
"for",
"running",
"tests",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/service/rest/System.java#L53-L57 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/cli/SwaggerCodegen.java | SwaggerCodegen.toApiImport | @Override
public String toApiImport(String name) {
if (!apiPackage().isEmpty())
return apiPackage();
else if (trimApiPaths)
return trimmedPaths.get(name).substring(1).replace('/', '.');
else
return super.toApiImport(name);
} | java | @Override
public String toApiImport(String name) {
if (!apiPackage().isEmpty())
return apiPackage();
else if (trimApiPaths)
return trimmedPaths.get(name).substring(1).replace('/', '.');
else
return super.toApiImport(name);
} | [
"@",
"Override",
"public",
"String",
"toApiImport",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"!",
"apiPackage",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"return",
"apiPackage",
"(",
")",
";",
"else",
"if",
"(",
"trimApiPaths",
")",
"return",
"trimme... | We use this for API package in our templates when trimmedPaths is true. | [
"We",
"use",
"this",
"for",
"API",
"package",
"in",
"our",
"templates",
"when",
"trimmedPaths",
"is",
"true",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/cli/SwaggerCodegen.java#L173-L181 | train |
CenturyLinkCloud/mdw | mdw-hub/src/com/centurylink/mdw/hub/context/WebAppContext.java | WebAppContext.listOverrideFiles | public static List<File> listOverrideFiles(String type) throws IOException {
List<File> files = new ArrayList<File>();
if (getMdw().getOverrideRoot().isDirectory()) {
File dir = new File(getMdw().getOverrideRoot() + "/" + type);
if (dir.isDirectory())
addFiles(files, dir, type);
}
return files;
} | java | public static List<File> listOverrideFiles(String type) throws IOException {
List<File> files = new ArrayList<File>();
if (getMdw().getOverrideRoot().isDirectory()) {
File dir = new File(getMdw().getOverrideRoot() + "/" + type);
if (dir.isDirectory())
addFiles(files, dir, type);
}
return files;
} | [
"public",
"static",
"List",
"<",
"File",
">",
"listOverrideFiles",
"(",
"String",
"type",
")",
"throws",
"IOException",
"{",
"List",
"<",
"File",
">",
"files",
"=",
"new",
"ArrayList",
"<",
"File",
">",
"(",
")",
";",
"if",
"(",
"getMdw",
"(",
")",
"... | Recursively list override files. Assumes dir path == ext == type. | [
"Recursively",
"list",
"override",
"files",
".",
"Assumes",
"dir",
"path",
"==",
"ext",
"==",
"type",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-hub/src/com/centurylink/mdw/hub/context/WebAppContext.java#L102-L110 | train |
CenturyLinkCloud/mdw | mdw-workflow/assets/com/centurylink/mdw/system/filepanel/FileView.java | FileView.search | private int search(int startLine, boolean backward) throws IOException {
search = search.toLowerCase();
try (Stream<String> stream = Files.lines(path)) {
if (backward) {
int idx = -1;
if (startLine > 0)
idx = searchTo(startLine - 1, true);
if (idx < 0)
idx = searchFrom(startLine, true);
return idx;
}
else {
int idx = searchFrom(startLine);
if (idx < 0) {
// wrap search
idx = searchTo(startLine - 1);
}
return idx;
}
}
catch (UncheckedIOException ex) {
throw ex.getCause();
}
} | java | private int search(int startLine, boolean backward) throws IOException {
search = search.toLowerCase();
try (Stream<String> stream = Files.lines(path)) {
if (backward) {
int idx = -1;
if (startLine > 0)
idx = searchTo(startLine - 1, true);
if (idx < 0)
idx = searchFrom(startLine, true);
return idx;
}
else {
int idx = searchFrom(startLine);
if (idx < 0) {
// wrap search
idx = searchTo(startLine - 1);
}
return idx;
}
}
catch (UncheckedIOException ex) {
throw ex.getCause();
}
} | [
"private",
"int",
"search",
"(",
"int",
"startLine",
",",
"boolean",
"backward",
")",
"throws",
"IOException",
"{",
"search",
"=",
"search",
".",
"toLowerCase",
"(",
")",
";",
"try",
"(",
"Stream",
"<",
"String",
">",
"stream",
"=",
"Files",
".",
"lines"... | Search pass locates line index of first match. | [
"Search",
"pass",
"locates",
"line",
"index",
"of",
"first",
"match",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-workflow/assets/com/centurylink/mdw/system/filepanel/FileView.java#L138-L161 | train |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/timer/process/ScheduledProcessStart.java | ScheduledProcessStart.handleEventMessage | @Override
public String handleEventMessage(String msg, Object msgdoc,
Map<String, String> metainfo) throws EventHandlerException {
return null;
} | java | @Override
public String handleEventMessage(String msg, Object msgdoc,
Map<String, String> metainfo) throws EventHandlerException {
return null;
} | [
"@",
"Override",
"public",
"String",
"handleEventMessage",
"(",
"String",
"msg",
",",
"Object",
"msgdoc",
",",
"Map",
"<",
"String",
",",
"String",
">",
"metainfo",
")",
"throws",
"EventHandlerException",
"{",
"return",
"null",
";",
"}"
] | This is not used - the class extends ExternalEventHandlerBase
only to get access to convenient methods | [
"This",
"is",
"not",
"used",
"-",
"the",
"class",
"extends",
"ExternalEventHandlerBase",
"only",
"to",
"get",
"access",
"to",
"convenient",
"methods"
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/timer/process/ScheduledProcessStart.java#L71-L75 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/script/GroovyExecutor.java | GroovyExecutor.initializeDynamicJavaAssets | private static void initializeDynamicJavaAssets() throws DataAccessException, IOException, CachingException {
logger.info("Initializing Dynamic Java assets for Groovy...");
for (Asset java : AssetCache.getAssets(Asset.JAVA)) {
Package pkg = PackageCache.getAssetPackage(java.getId());
String packageName = pkg == null ? null : JavaNaming.getValidPackageName(pkg.getName());
File dir = createNeededDirs(packageName);
String filename = dir + "/" + java.getName();
if (filename.endsWith(".java"))
filename = filename.substring(0, filename.length() - 5);
filename += ".groovy";
File file = new File(filename);
logger.mdwDebug(" - writing " + file.getAbsoluteFile());
if (file.exists())
file.delete();
String content = java.getStringContent();
if (content != null) {
if (Compatibility.hasCodeSubstitutions())
content = doCompatibilityCodeSubstitutions(java.getLabel(), content);
FileWriter writer = new FileWriter(file);
writer.write(content);
writer.close();
}
}
logger.info("Dynamic Java assets initialized for groovy.");
} | java | private static void initializeDynamicJavaAssets() throws DataAccessException, IOException, CachingException {
logger.info("Initializing Dynamic Java assets for Groovy...");
for (Asset java : AssetCache.getAssets(Asset.JAVA)) {
Package pkg = PackageCache.getAssetPackage(java.getId());
String packageName = pkg == null ? null : JavaNaming.getValidPackageName(pkg.getName());
File dir = createNeededDirs(packageName);
String filename = dir + "/" + java.getName();
if (filename.endsWith(".java"))
filename = filename.substring(0, filename.length() - 5);
filename += ".groovy";
File file = new File(filename);
logger.mdwDebug(" - writing " + file.getAbsoluteFile());
if (file.exists())
file.delete();
String content = java.getStringContent();
if (content != null) {
if (Compatibility.hasCodeSubstitutions())
content = doCompatibilityCodeSubstitutions(java.getLabel(), content);
FileWriter writer = new FileWriter(file);
writer.write(content);
writer.close();
}
}
logger.info("Dynamic Java assets initialized for groovy.");
} | [
"private",
"static",
"void",
"initializeDynamicJavaAssets",
"(",
")",
"throws",
"DataAccessException",
",",
"IOException",
",",
"CachingException",
"{",
"logger",
".",
"info",
"(",
"\"Initializing Dynamic Java assets for Groovy...\"",
")",
";",
"for",
"(",
"Asset",
"jav... | so that Groovy scripts can reference these assets during compilation | [
"so",
"that",
"Groovy",
"scripts",
"can",
"reference",
"these",
"assets",
"during",
"compilation"
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/script/GroovyExecutor.java#L249-L275 | train |
CenturyLinkCloud/mdw | mdw-workflow/assets/com/centurylink/mdw/slack/SlackService.java | SlackService.post | public JSONObject post(String path, JSONObject content, Map<String,String> headers)
throws ServiceException, JSONException {
String sub = getSegment(path, 4);
if ("event".equals(sub)) {
SlackEvent event = new SlackEvent(content);
EventHandler eventHandler = getEventHandler(event.getType(), event);
if (eventHandler == null) {
throw new ServiceException("Unsupported handler type: " + event.getType()
+ (event.getChannel() == null ? "" : (":" + event.getChannel())));
}
return eventHandler.handleEvent(event);
} else {
// action/options request
SlackRequest request = new SlackRequest(content);
String userId = getAuthUser(headers);
// TODO: ability to map request.getUser() to corresponding MDW user
String callbackId = request.getCallbackId();
if (callbackId != null) {
int underscore = callbackId.lastIndexOf('_');
if (underscore > 0) {
String handlerType = callbackId.substring(0, underscore);
String id = callbackId.substring(callbackId.lastIndexOf('/') + 1);
ActionHandler actionHandler = getActionHandler(handlerType, userId, id,
request);
if (actionHandler == null)
throw new ServiceException("Unsupported handler type: " + handlerType);
return actionHandler.handleRequest(userId, id, request);
}
}
throw new ServiceException(ServiceException.BAD_REQUEST, "Bad or missing callback_id");
}
} | java | public JSONObject post(String path, JSONObject content, Map<String,String> headers)
throws ServiceException, JSONException {
String sub = getSegment(path, 4);
if ("event".equals(sub)) {
SlackEvent event = new SlackEvent(content);
EventHandler eventHandler = getEventHandler(event.getType(), event);
if (eventHandler == null) {
throw new ServiceException("Unsupported handler type: " + event.getType()
+ (event.getChannel() == null ? "" : (":" + event.getChannel())));
}
return eventHandler.handleEvent(event);
} else {
// action/options request
SlackRequest request = new SlackRequest(content);
String userId = getAuthUser(headers);
// TODO: ability to map request.getUser() to corresponding MDW user
String callbackId = request.getCallbackId();
if (callbackId != null) {
int underscore = callbackId.lastIndexOf('_');
if (underscore > 0) {
String handlerType = callbackId.substring(0, underscore);
String id = callbackId.substring(callbackId.lastIndexOf('/') + 1);
ActionHandler actionHandler = getActionHandler(handlerType, userId, id,
request);
if (actionHandler == null)
throw new ServiceException("Unsupported handler type: " + handlerType);
return actionHandler.handleRequest(userId, id, request);
}
}
throw new ServiceException(ServiceException.BAD_REQUEST, "Bad or missing callback_id");
}
} | [
"public",
"JSONObject",
"post",
"(",
"String",
"path",
",",
"JSONObject",
"content",
",",
"Map",
"<",
"String",
",",
"String",
">",
"headers",
")",
"throws",
"ServiceException",
",",
"JSONException",
"{",
"String",
"sub",
"=",
"getSegment",
"(",
"path",
",",... | Responds to requests from Slack. | [
"Responds",
"to",
"requests",
"from",
"Slack",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-workflow/assets/com/centurylink/mdw/slack/SlackService.java#L42-L74 | train |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/service/rest/AuthenticatedUser.java | AuthenticatedUser.get | @Override
public JSONObject get(String path, Map<String,String> headers) throws ServiceException, JSONException {
// we trust this header value because only MDW can set it
String authUser = (String)headers.get(Listener.AUTHENTICATED_USER_HEADER);
try {
if (authUser == null)
throw new ServiceException("Missing parameter: " + Listener.AUTHENTICATED_USER_HEADER);
UserServices userServices = ServiceLocator.getUserServices();
User userVO = userServices.getUser(authUser);
if (userVO == null)
throw new ServiceException(HTTP_404_NOT_FOUND, "User not found: " + authUser);
return userVO.getJsonWithRoles();
}
catch (DataAccessException ex) {
throw new ServiceException(ex.getCode(), ex.getMessage(), ex);
}
catch (Exception ex) {
throw new ServiceException("Error getting authenticated user: " + authUser, ex);
}
} | java | @Override
public JSONObject get(String path, Map<String,String> headers) throws ServiceException, JSONException {
// we trust this header value because only MDW can set it
String authUser = (String)headers.get(Listener.AUTHENTICATED_USER_HEADER);
try {
if (authUser == null)
throw new ServiceException("Missing parameter: " + Listener.AUTHENTICATED_USER_HEADER);
UserServices userServices = ServiceLocator.getUserServices();
User userVO = userServices.getUser(authUser);
if (userVO == null)
throw new ServiceException(HTTP_404_NOT_FOUND, "User not found: " + authUser);
return userVO.getJsonWithRoles();
}
catch (DataAccessException ex) {
throw new ServiceException(ex.getCode(), ex.getMessage(), ex);
}
catch (Exception ex) {
throw new ServiceException("Error getting authenticated user: " + authUser, ex);
}
} | [
"@",
"Override",
"public",
"JSONObject",
"get",
"(",
"String",
"path",
",",
"Map",
"<",
"String",
",",
"String",
">",
"headers",
")",
"throws",
"ServiceException",
",",
"JSONException",
"{",
"// we trust this header value because only MDW can set it",
"String",
"authU... | Retrieve the current authenticated user. | [
"Retrieve",
"the",
"current",
"authenticated",
"user",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/service/rest/AuthenticatedUser.java#L49-L68 | train |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/services/messenger/MessengerFactory.java | MessengerFactory.getEngineUrl | public static String getEngineUrl(String serverSpec) throws NamingException {
String url;
int at = serverSpec.indexOf('@');
if (at>0) {
url = serverSpec.substring(at+1);
} else {
int colonDashDash = serverSpec.indexOf("://");
if (colonDashDash>0) {
url = serverSpec;
} else {
url = PropertyManager.getProperty(PropertyNames.MDW_REMOTE_SERVER + "." + serverSpec);
if (url==null) throw new NamingException("Cannot find engine URL for " + serverSpec);
}
}
return url;
} | java | public static String getEngineUrl(String serverSpec) throws NamingException {
String url;
int at = serverSpec.indexOf('@');
if (at>0) {
url = serverSpec.substring(at+1);
} else {
int colonDashDash = serverSpec.indexOf("://");
if (colonDashDash>0) {
url = serverSpec;
} else {
url = PropertyManager.getProperty(PropertyNames.MDW_REMOTE_SERVER + "." + serverSpec);
if (url==null) throw new NamingException("Cannot find engine URL for " + serverSpec);
}
}
return url;
} | [
"public",
"static",
"String",
"getEngineUrl",
"(",
"String",
"serverSpec",
")",
"throws",
"NamingException",
"{",
"String",
"url",
";",
"int",
"at",
"=",
"serverSpec",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"at",
">",
"0",
")",
"{",
"url",... | Returns engine URL for another server, using server specification as input.
Server specification can be one of the following forms
a) URL of the form t3://host:port, iiop://host:port, rmi://host:port, http://host:port/context_and_path
b) a logical server name, in which case the URL is obtained from property mdw.remote.server.<server-name>
c) server_name@URL
@param serverSpec
@return URL for the engine
@throws NamingException | [
"Returns",
"engine",
"URL",
"for",
"another",
"server",
"using",
"server",
"specification",
"as",
"input",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/services/messenger/MessengerFactory.java#L114-L129 | train |
CenturyLinkCloud/mdw | mdw-workflow/src/com/centurylink/mdw/workflow/activity/validate/SwaggerValidatorActivity.java | SwaggerValidatorActivity.handleResult | protected Object handleResult(Result result) throws ActivityException {
ServiceValuesAccess serviceValues = getRuntimeContext().getServiceValues();
StatusResponse statusResponse;
if (result.isError()) {
logsevere("Validation error: " + result.getStatus().toString());
statusResponse = new StatusResponse(result.getWorstCode(), result.getStatus().getMessage());
String responseHeadersVarName = serviceValues.getResponseHeadersVariableName();
Map<String,String> responseHeaders = serviceValues.getResponseHeaders();
if (responseHeaders == null) {
Variable responseHeadersVar = getMainProcessDefinition().getVariable(responseHeadersVarName);
if (responseHeadersVar == null)
throw new ActivityException("Missing response headers variable: " + responseHeadersVarName);
responseHeaders = new HashMap<>();
}
responseHeaders.put(Listener.METAINFO_HTTP_STATUS_CODE, String.valueOf(statusResponse.getStatus().getCode()));
setVariableValue(responseHeadersVarName, responseHeaders);
}
else {
statusResponse = new StatusResponse(com.centurylink.mdw.model.Status.OK, "Valid request");
}
String responseVariableName = serviceValues.getResponseVariableName();
Variable responseVariable = getMainProcessDefinition().getVariable(responseVariableName);
if (responseVariable == null)
throw new ActivityException("Missing response variable: " + responseVariableName);
Object responseObject;
if (responseVariable.getType().equals(Jsonable.class.getName()))
responseObject = statusResponse; // _type has not been set, so serialization would fail
else
responseObject = serviceValues.fromJson(responseVariableName, statusResponse.getJson());
setVariableValue(responseVariableName, responseObject);
return !result.isError();
} | java | protected Object handleResult(Result result) throws ActivityException {
ServiceValuesAccess serviceValues = getRuntimeContext().getServiceValues();
StatusResponse statusResponse;
if (result.isError()) {
logsevere("Validation error: " + result.getStatus().toString());
statusResponse = new StatusResponse(result.getWorstCode(), result.getStatus().getMessage());
String responseHeadersVarName = serviceValues.getResponseHeadersVariableName();
Map<String,String> responseHeaders = serviceValues.getResponseHeaders();
if (responseHeaders == null) {
Variable responseHeadersVar = getMainProcessDefinition().getVariable(responseHeadersVarName);
if (responseHeadersVar == null)
throw new ActivityException("Missing response headers variable: " + responseHeadersVarName);
responseHeaders = new HashMap<>();
}
responseHeaders.put(Listener.METAINFO_HTTP_STATUS_CODE, String.valueOf(statusResponse.getStatus().getCode()));
setVariableValue(responseHeadersVarName, responseHeaders);
}
else {
statusResponse = new StatusResponse(com.centurylink.mdw.model.Status.OK, "Valid request");
}
String responseVariableName = serviceValues.getResponseVariableName();
Variable responseVariable = getMainProcessDefinition().getVariable(responseVariableName);
if (responseVariable == null)
throw new ActivityException("Missing response variable: " + responseVariableName);
Object responseObject;
if (responseVariable.getType().equals(Jsonable.class.getName()))
responseObject = statusResponse; // _type has not been set, so serialization would fail
else
responseObject = serviceValues.fromJson(responseVariableName, statusResponse.getJson());
setVariableValue(responseVariableName, responseObject);
return !result.isError();
} | [
"protected",
"Object",
"handleResult",
"(",
"Result",
"result",
")",
"throws",
"ActivityException",
"{",
"ServiceValuesAccess",
"serviceValues",
"=",
"getRuntimeContext",
"(",
")",
".",
"getServiceValues",
"(",
")",
";",
"StatusResponse",
"statusResponse",
";",
"if",
... | Populates "response" variable with a default JSON status object. Can be overwritten by
custom logic in a downstream activity, or in a JsonRestService implementation. | [
"Populates",
"response",
"variable",
"with",
"a",
"default",
"JSON",
"status",
"object",
".",
"Can",
"be",
"overwritten",
"by",
"custom",
"logic",
"in",
"a",
"downstream",
"activity",
"or",
"in",
"a",
"JsonRestService",
"implementation",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-workflow/src/com/centurylink/mdw/workflow/activity/validate/SwaggerValidatorActivity.java#L130-L161 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/cli/Init.java | Init.deleteDynamicTemplates | private void deleteDynamicTemplates() throws IOException {
File codegenDir = new File(getProjectDir() + "/codegen");
if (codegenDir.exists()) {
getOut().println("Deleting " + codegenDir);
new Delete(codegenDir, true).run();
}
File assetsDir = new File(getProjectDir() + "/assets");
if (assetsDir.exists()) {
getOut().println("Deleting " + assetsDir);
new Delete(assetsDir, true).run();
}
File configuratorDir = new File(getProjectDir() + "/configurator");
if (configuratorDir.exists()) {
getOut().println("Deleting " + configuratorDir);
new Delete(configuratorDir, true).run();
}
} | java | private void deleteDynamicTemplates() throws IOException {
File codegenDir = new File(getProjectDir() + "/codegen");
if (codegenDir.exists()) {
getOut().println("Deleting " + codegenDir);
new Delete(codegenDir, true).run();
}
File assetsDir = new File(getProjectDir() + "/assets");
if (assetsDir.exists()) {
getOut().println("Deleting " + assetsDir);
new Delete(assetsDir, true).run();
}
File configuratorDir = new File(getProjectDir() + "/configurator");
if (configuratorDir.exists()) {
getOut().println("Deleting " + configuratorDir);
new Delete(configuratorDir, true).run();
}
} | [
"private",
"void",
"deleteDynamicTemplates",
"(",
")",
"throws",
"IOException",
"{",
"File",
"codegenDir",
"=",
"new",
"File",
"(",
"getProjectDir",
"(",
")",
"+",
"\"/codegen\"",
")",
";",
"if",
"(",
"codegenDir",
".",
"exists",
"(",
")",
")",
"{",
"getOu... | These will be retrieved just-in-time based on current mdw version. | [
"These",
"will",
"be",
"retrieved",
"just",
"-",
"in",
"-",
"time",
"based",
"on",
"current",
"mdw",
"version",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/cli/Init.java#L165-L181 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/common/service/SystemMessages.java | SystemMessages.bulletinOff | public static void bulletinOff(Bulletin bulletin, Level level, String message) {
if (bulletin == null)
return;
synchronized (bulletins) {
bulletins.remove(bulletin.getId(), bulletin);
}
try {
WebSocketMessenger.getInstance().send("SystemMessage", bulletin.off(message).getJson().toString());
}
catch (IOException ex) {
logger.warnException("Unable to publish to websocket", ex);
}
} | java | public static void bulletinOff(Bulletin bulletin, Level level, String message) {
if (bulletin == null)
return;
synchronized (bulletins) {
bulletins.remove(bulletin.getId(), bulletin);
}
try {
WebSocketMessenger.getInstance().send("SystemMessage", bulletin.off(message).getJson().toString());
}
catch (IOException ex) {
logger.warnException("Unable to publish to websocket", ex);
}
} | [
"public",
"static",
"void",
"bulletinOff",
"(",
"Bulletin",
"bulletin",
",",
"Level",
"level",
",",
"String",
"message",
")",
"{",
"if",
"(",
"bulletin",
"==",
"null",
")",
"return",
";",
"synchronized",
"(",
"bulletins",
")",
"{",
"bulletins",
".",
"remov... | Should be the same instance or have the same id as the bulletinOn message. | [
"Should",
"be",
"the",
"same",
"instance",
"or",
"have",
"the",
"same",
"id",
"as",
"the",
"bulletinOn",
"message",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/common/service/SystemMessages.java#L76-L88 | train |
CenturyLinkCloud/mdw | mdw-workflow/assets/com/centurylink/mdw/system/filepanel/FilePanelService.java | FilePanelService.exclude | private static boolean exclude(String host, java.nio.file.Path path) {
List<PathMatcher> exclusions = getExcludes(host);
if (exclusions == null && host != null) {
exclusions = getExcludes(null); // check global config
}
if (exclusions != null) {
for (PathMatcher matcher : exclusions) {
if (matcher.matches(path))
return true;
}
}
return false;
} | java | private static boolean exclude(String host, java.nio.file.Path path) {
List<PathMatcher> exclusions = getExcludes(host);
if (exclusions == null && host != null) {
exclusions = getExcludes(null); // check global config
}
if (exclusions != null) {
for (PathMatcher matcher : exclusions) {
if (matcher.matches(path))
return true;
}
}
return false;
} | [
"private",
"static",
"boolean",
"exclude",
"(",
"String",
"host",
",",
"java",
".",
"nio",
".",
"file",
".",
"Path",
"path",
")",
"{",
"List",
"<",
"PathMatcher",
">",
"exclusions",
"=",
"getExcludes",
"(",
"host",
")",
";",
"if",
"(",
"exclusions",
"=... | Checks for matching exclude patterns. | [
"Checks",
"for",
"matching",
"exclude",
"patterns",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-workflow/assets/com/centurylink/mdw/system/filepanel/FilePanelService.java#L363-L375 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/cli/Setup.java | Setup.getMdwVersion | public String getMdwVersion() throws IOException {
if (mdwVersion == null) {
YamlProperties yaml = getProjectYaml();
if (yaml != null) {
mdwVersion = yaml.getString(Props.ProjectYaml.MDW_VERSION);
}
}
return mdwVersion;
} | java | public String getMdwVersion() throws IOException {
if (mdwVersion == null) {
YamlProperties yaml = getProjectYaml();
if (yaml != null) {
mdwVersion = yaml.getString(Props.ProjectYaml.MDW_VERSION);
}
}
return mdwVersion;
} | [
"public",
"String",
"getMdwVersion",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mdwVersion",
"==",
"null",
")",
"{",
"YamlProperties",
"yaml",
"=",
"getProjectYaml",
"(",
")",
";",
"if",
"(",
"yaml",
"!=",
"null",
")",
"{",
"mdwVersion",
"=",
"y... | Reads from project.yaml | [
"Reads",
"from",
"project",
".",
"yaml"
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/cli/Setup.java#L215-L223 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/cli/Setup.java | Setup.findMdwVersion | public String findMdwVersion(boolean snapshots) throws IOException {
URL url = new URL(getReleasesUrl() + MDW_COMMON_PATH);
if (snapshots)
url = new URL(getSnapshotsUrl() + MDW_COMMON_PATH);
Crawl crawl = new Crawl(url, snapshots);
crawl.run();
if (crawl.getReleases().size() == 0)
throw new IOException("Unable to locate MDW releases: " + url);
return crawl.getReleases().get(crawl.getReleases().size() - 1);
} | java | public String findMdwVersion(boolean snapshots) throws IOException {
URL url = new URL(getReleasesUrl() + MDW_COMMON_PATH);
if (snapshots)
url = new URL(getSnapshotsUrl() + MDW_COMMON_PATH);
Crawl crawl = new Crawl(url, snapshots);
crawl.run();
if (crawl.getReleases().size() == 0)
throw new IOException("Unable to locate MDW releases: " + url);
return crawl.getReleases().get(crawl.getReleases().size() - 1);
} | [
"public",
"String",
"findMdwVersion",
"(",
"boolean",
"snapshots",
")",
"throws",
"IOException",
"{",
"URL",
"url",
"=",
"new",
"URL",
"(",
"getReleasesUrl",
"(",
")",
"+",
"MDW_COMMON_PATH",
")",
";",
"if",
"(",
"snapshots",
")",
"url",
"=",
"new",
"URL",... | Crawls to find the latest stable version. | [
"Crawls",
"to",
"find",
"the",
"latest",
"stable",
"version",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/cli/Setup.java#L279-L288 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/cli/Setup.java | Setup.initBaseAssetPackages | protected void initBaseAssetPackages() throws IOException {
baseAssetPackages = new ArrayList<>();
addBasePackages(getAssetRoot(), getAssetRoot());
if (baseAssetPackages.isEmpty())
baseAssetPackages = Packages.DEFAULT_BASE_PACKAGES;
} | java | protected void initBaseAssetPackages() throws IOException {
baseAssetPackages = new ArrayList<>();
addBasePackages(getAssetRoot(), getAssetRoot());
if (baseAssetPackages.isEmpty())
baseAssetPackages = Packages.DEFAULT_BASE_PACKAGES;
} | [
"protected",
"void",
"initBaseAssetPackages",
"(",
")",
"throws",
"IOException",
"{",
"baseAssetPackages",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"addBasePackages",
"(",
"getAssetRoot",
"(",
")",
",",
"getAssetRoot",
"(",
")",
")",
";",
"if",
"(",
"ba... | Checks for any existing packages. If none present, adds the defaults. | [
"Checks",
"for",
"any",
"existing",
"packages",
".",
"If",
"none",
"present",
"adds",
"the",
"defaults",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/cli/Setup.java#L293-L298 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/cli/Setup.java | Setup.getRelativePath | public String getRelativePath(File from, File to) {
Path fromPath = Paths.get(from.getPath()).normalize().toAbsolutePath();
Path toPath = Paths.get(to.getPath()).normalize().toAbsolutePath();
return fromPath.relativize(toPath).toString().replace('\\', '/');
} | java | public String getRelativePath(File from, File to) {
Path fromPath = Paths.get(from.getPath()).normalize().toAbsolutePath();
Path toPath = Paths.get(to.getPath()).normalize().toAbsolutePath();
return fromPath.relativize(toPath).toString().replace('\\', '/');
} | [
"public",
"String",
"getRelativePath",
"(",
"File",
"from",
",",
"File",
"to",
")",
"{",
"Path",
"fromPath",
"=",
"Paths",
".",
"get",
"(",
"from",
".",
"getPath",
"(",
")",
")",
".",
"normalize",
"(",
")",
".",
"toAbsolutePath",
"(",
")",
";",
"Path... | Returns 'to' file or dir path relative to 'from' dir.
Result always uses forward slashes and has no trailing slash. | [
"Returns",
"to",
"file",
"or",
"dir",
"path",
"relative",
"to",
"from",
"dir",
".",
"Result",
"always",
"uses",
"forward",
"slashes",
"and",
"has",
"no",
"trailing",
"slash",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/cli/Setup.java#L405-L409 | train |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/cli/Setup.java | Setup.downloadTemplates | protected void downloadTemplates(ProgressMonitor... monitors) throws IOException {
File templateDir = getTemplateDir();
if (!templateDir.exists()) {
if (!templateDir.mkdirs())
throw new IOException("Unable to create directory: " + templateDir.getAbsolutePath());
String templatesUrl = getTemplatesUrl();
getOut().println("Retrieving templates: " + templatesUrl);
File tempZip = Files.createTempFile("mdw-templates-", ".zip").toFile();
new Download(new URL(templatesUrl), tempZip).run(monitors);
File tempDir = Files.createTempDirectory("mdw-templates-").toFile();
new Unzip(tempZip, tempDir, false).run();
File codegenDir = new File(templateDir + "/codegen");
new Copy(new File(tempDir + "/codegen"), codegenDir, true).run();
File assetsDir = new File(templateDir + "/assets");
new Copy(new File(tempDir + "/assets"), assetsDir, true).run();
}
} | java | protected void downloadTemplates(ProgressMonitor... monitors) throws IOException {
File templateDir = getTemplateDir();
if (!templateDir.exists()) {
if (!templateDir.mkdirs())
throw new IOException("Unable to create directory: " + templateDir.getAbsolutePath());
String templatesUrl = getTemplatesUrl();
getOut().println("Retrieving templates: " + templatesUrl);
File tempZip = Files.createTempFile("mdw-templates-", ".zip").toFile();
new Download(new URL(templatesUrl), tempZip).run(monitors);
File tempDir = Files.createTempDirectory("mdw-templates-").toFile();
new Unzip(tempZip, tempDir, false).run();
File codegenDir = new File(templateDir + "/codegen");
new Copy(new File(tempDir + "/codegen"), codegenDir, true).run();
File assetsDir = new File(templateDir + "/assets");
new Copy(new File(tempDir + "/assets"), assetsDir, true).run();
}
} | [
"protected",
"void",
"downloadTemplates",
"(",
"ProgressMonitor",
"...",
"monitors",
")",
"throws",
"IOException",
"{",
"File",
"templateDir",
"=",
"getTemplateDir",
"(",
")",
";",
"if",
"(",
"!",
"templateDir",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
... | Downloads asset templates for codegen, etc. | [
"Downloads",
"asset",
"templates",
"for",
"codegen",
"etc",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/cli/Setup.java#L583-L599 | train |
CenturyLinkCloud/mdw | mdw-workflow/assets/com/centurylink/mdw/zipkin/TraceAdapterMonitor.java | TraceAdapterMonitor.onRequest | @Override
public Object onRequest(ActivityRuntimeContext context, Object content, Map<String,String> headers, Object connection) {
if (connection instanceof HttpConnection) {
HttpConnection httpConnection = (HttpConnection)connection;
Tracing tracing = TraceHelper.getTracing("mdw-adapter");
HttpTracing httpTracing = HttpTracing.create(tracing).toBuilder()
.clientParser(new HttpClientParser() {
public <Req> void request(HttpAdapter<Req, ?> adapter, Req req, SpanCustomizer customizer) {
// customize span name
customizer.name(context.getActivity().oneLineName());
}
})
.build();
Tracer tracer = httpTracing.tracing().tracer();
handler = HttpClientHandler.create(httpTracing, new ClientAdapter());
injector = httpTracing.tracing().propagation().injector((httpRequest, key, value) -> headers.put(key, value));
span = handler.handleSend(injector, new HttpRequest(httpConnection));
scope = tracer.withSpanInScope(span);
}
return null;
} | java | @Override
public Object onRequest(ActivityRuntimeContext context, Object content, Map<String,String> headers, Object connection) {
if (connection instanceof HttpConnection) {
HttpConnection httpConnection = (HttpConnection)connection;
Tracing tracing = TraceHelper.getTracing("mdw-adapter");
HttpTracing httpTracing = HttpTracing.create(tracing).toBuilder()
.clientParser(new HttpClientParser() {
public <Req> void request(HttpAdapter<Req, ?> adapter, Req req, SpanCustomizer customizer) {
// customize span name
customizer.name(context.getActivity().oneLineName());
}
})
.build();
Tracer tracer = httpTracing.tracing().tracer();
handler = HttpClientHandler.create(httpTracing, new ClientAdapter());
injector = httpTracing.tracing().propagation().injector((httpRequest, key, value) -> headers.put(key, value));
span = handler.handleSend(injector, new HttpRequest(httpConnection));
scope = tracer.withSpanInScope(span);
}
return null;
} | [
"@",
"Override",
"public",
"Object",
"onRequest",
"(",
"ActivityRuntimeContext",
"context",
",",
"Object",
"content",
",",
"Map",
"<",
"String",
",",
"String",
">",
"headers",
",",
"Object",
"connection",
")",
"{",
"if",
"(",
"connection",
"instanceof",
"HttpC... | Only for HTTP. | [
"Only",
"for",
"HTTP",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-workflow/assets/com/centurylink/mdw/zipkin/TraceAdapterMonitor.java#L33-L53 | train |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/services/task/TaskWorkflowHelper.java | TaskWorkflowHelper.createTaskInstance | static TaskInstance createTaskInstance(Long taskId, String masterRequestId, Long procInstId,
String secOwner, Long secOwnerId, String title, String comments) throws ServiceException, DataAccessException {
return createTaskInstance(taskId, masterRequestId, procInstId, secOwner, secOwnerId, title, comments, 0, null, null);
} | java | static TaskInstance createTaskInstance(Long taskId, String masterRequestId, Long procInstId,
String secOwner, Long secOwnerId, String title, String comments) throws ServiceException, DataAccessException {
return createTaskInstance(taskId, masterRequestId, procInstId, secOwner, secOwnerId, title, comments, 0, null, null);
} | [
"static",
"TaskInstance",
"createTaskInstance",
"(",
"Long",
"taskId",
",",
"String",
"masterRequestId",
",",
"Long",
"procInstId",
",",
"String",
"secOwner",
",",
"Long",
"secOwnerId",
",",
"String",
"title",
",",
"String",
"comments",
")",
"throws",
"ServiceExce... | Convenience method for below. | [
"Convenience",
"method",
"for",
"below",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/services/task/TaskWorkflowHelper.java#L99-L102 | train |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/services/task/TaskWorkflowHelper.java | TaskWorkflowHelper.createTaskInstance | static TaskInstance createTaskInstance(Long taskId, String masterOwnerId,
String title, String comment, Instant due, Long userId, Long secondaryOwner)
throws ServiceException, DataAccessException {
CodeTimer timer = new CodeTimer("createTaskInstance()", true);
TaskTemplate task = TaskTemplateCache.getTaskTemplate(taskId);
TaskInstance ti = createTaskInstance(taskId, masterOwnerId, OwnerType.USER, userId,
(secondaryOwner != null ? OwnerType.DOCUMENT : null), secondaryOwner,
task.getTaskName(), title, comment, due, 0);
TaskWorkflowHelper helper = new TaskWorkflowHelper(ti);
if (due!=null) {
String alertIntervalString = task.getAttribute(TaskAttributeConstant.ALERT_INTERVAL);
int alertInterval = StringHelper.isEmpty(alertIntervalString) ? 0 : Integer.parseInt(alertIntervalString);
helper.scheduleTaskSlaEvent(Date.from(due), alertInterval, false);
}
// create instance groups for template based tasks
List<String> groups = helper.determineWorkgroups(null);
if (groups != null && groups.size() > 0)
new TaskDataAccess().setTaskInstanceGroups(ti.getTaskInstanceId(), StringHelper.toStringArray(groups));
helper.notifyTaskAction(TaskAction.CREATE, null, null); // notification/observer/auto-assign
helper.auditLog("Create", "MDW");
timer.stopAndLogTiming("");
return ti;
} | java | static TaskInstance createTaskInstance(Long taskId, String masterOwnerId,
String title, String comment, Instant due, Long userId, Long secondaryOwner)
throws ServiceException, DataAccessException {
CodeTimer timer = new CodeTimer("createTaskInstance()", true);
TaskTemplate task = TaskTemplateCache.getTaskTemplate(taskId);
TaskInstance ti = createTaskInstance(taskId, masterOwnerId, OwnerType.USER, userId,
(secondaryOwner != null ? OwnerType.DOCUMENT : null), secondaryOwner,
task.getTaskName(), title, comment, due, 0);
TaskWorkflowHelper helper = new TaskWorkflowHelper(ti);
if (due!=null) {
String alertIntervalString = task.getAttribute(TaskAttributeConstant.ALERT_INTERVAL);
int alertInterval = StringHelper.isEmpty(alertIntervalString) ? 0 : Integer.parseInt(alertIntervalString);
helper.scheduleTaskSlaEvent(Date.from(due), alertInterval, false);
}
// create instance groups for template based tasks
List<String> groups = helper.determineWorkgroups(null);
if (groups != null && groups.size() > 0)
new TaskDataAccess().setTaskInstanceGroups(ti.getTaskInstanceId(), StringHelper.toStringArray(groups));
helper.notifyTaskAction(TaskAction.CREATE, null, null); // notification/observer/auto-assign
helper.auditLog("Create", "MDW");
timer.stopAndLogTiming("");
return ti;
} | [
"static",
"TaskInstance",
"createTaskInstance",
"(",
"Long",
"taskId",
",",
"String",
"masterOwnerId",
",",
"String",
"title",
",",
"String",
"comment",
",",
"Instant",
"due",
",",
"Long",
"userId",
",",
"Long",
"secondaryOwner",
")",
"throws",
"ServiceException",... | This version is used by the task manager to create a task instance
not associated with a process instance.
@param taskId
@param masterOwnerId
@param comment optional
@param due optional
@param userId
@param secondaryOwner (optional)
@return TaskInstance | [
"This",
"version",
"is",
"used",
"by",
"the",
"task",
"manager",
"to",
"create",
"a",
"task",
"instance",
"not",
"associated",
"with",
"a",
"process",
"instance",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/services/task/TaskWorkflowHelper.java#L222-L247 | train |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/services/task/TaskWorkflowHelper.java | TaskWorkflowHelper.determineWorkgroups | List<String> determineWorkgroups(Map<String,String> indexes)
throws ServiceException {
TaskTemplate taskTemplate = getTemplate();
String routingStrategyAttr = taskTemplate.getAttribute(TaskAttributeConstant.ROUTING_STRATEGY);
if (StringHelper.isEmpty(routingStrategyAttr)) {
return taskTemplate.getWorkgroups();
}
else {
try {
RoutingStrategy strategy = TaskInstanceStrategyFactory.getRoutingStrategy(routingStrategyAttr,
OwnerType.PROCESS_INSTANCE.equals(taskInstance.getOwnerType()) ? taskInstance.getOwnerId() : null);
if (strategy instanceof ParameterizedStrategy) {
populateStrategyParams((ParameterizedStrategy)strategy, getTemplate(), taskInstance.getOwnerId(), indexes);
}
return strategy.determineWorkgroups(taskTemplate, taskInstance);
}
catch (Exception ex) {
throw new ServiceException(ex.getMessage(), ex);
}
}
} | java | List<String> determineWorkgroups(Map<String,String> indexes)
throws ServiceException {
TaskTemplate taskTemplate = getTemplate();
String routingStrategyAttr = taskTemplate.getAttribute(TaskAttributeConstant.ROUTING_STRATEGY);
if (StringHelper.isEmpty(routingStrategyAttr)) {
return taskTemplate.getWorkgroups();
}
else {
try {
RoutingStrategy strategy = TaskInstanceStrategyFactory.getRoutingStrategy(routingStrategyAttr,
OwnerType.PROCESS_INSTANCE.equals(taskInstance.getOwnerType()) ? taskInstance.getOwnerId() : null);
if (strategy instanceof ParameterizedStrategy) {
populateStrategyParams((ParameterizedStrategy)strategy, getTemplate(), taskInstance.getOwnerId(), indexes);
}
return strategy.determineWorkgroups(taskTemplate, taskInstance);
}
catch (Exception ex) {
throw new ServiceException(ex.getMessage(), ex);
}
}
} | [
"List",
"<",
"String",
">",
"determineWorkgroups",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"indexes",
")",
"throws",
"ServiceException",
"{",
"TaskTemplate",
"taskTemplate",
"=",
"getTemplate",
"(",
")",
";",
"String",
"routingStrategyAttr",
"=",
"taskTem... | Determines a task instance's workgroups based on the defined strategy. If no strategy exists,
default to the workgroups defined in the task template.
By default this method propagates StrategyException as ServiceException. If users wish to continue
processing they can override the default strategy implementation to catch StrategyExceptions. | [
"Determines",
"a",
"task",
"instance",
"s",
"workgroups",
"based",
"on",
"the",
"defined",
"strategy",
".",
"If",
"no",
"strategy",
"exists",
"default",
"to",
"the",
"workgroups",
"defined",
"in",
"the",
"task",
"template",
"."
] | 91167fe65a25a5d7022cdcf8b0fae8506f5b87ce | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/services/task/TaskWorkflowHelper.java#L741-L761 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.