id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
144,300
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java
MavenModelScannerPlugin.addPluginExecutions
private void addPluginExecutions(MavenPluginDescriptor mavenPluginDescriptor, Plugin plugin, Store store) { List<PluginExecution> executions = plugin.getExecutions(); for (PluginExecution pluginExecution : executions) { MavenPluginExecutionDescriptor executionDescriptor = store.create(MavenPluginExecutionDescriptor.class); executionDescriptor.setId(pluginExecution.getId()); executionDescriptor.setPhase(pluginExecution.getPhase()); executionDescriptor.setInherited(pluginExecution.isInherited()); mavenPluginDescriptor.getExecutions().add(executionDescriptor); addExecutionGoals(executionDescriptor, pluginExecution, store); addConfiguration(executionDescriptor, (Xpp3Dom) pluginExecution.getConfiguration(), store); } }
java
private void addPluginExecutions(MavenPluginDescriptor mavenPluginDescriptor, Plugin plugin, Store store) { List<PluginExecution> executions = plugin.getExecutions(); for (PluginExecution pluginExecution : executions) { MavenPluginExecutionDescriptor executionDescriptor = store.create(MavenPluginExecutionDescriptor.class); executionDescriptor.setId(pluginExecution.getId()); executionDescriptor.setPhase(pluginExecution.getPhase()); executionDescriptor.setInherited(pluginExecution.isInherited()); mavenPluginDescriptor.getExecutions().add(executionDescriptor); addExecutionGoals(executionDescriptor, pluginExecution, store); addConfiguration(executionDescriptor, (Xpp3Dom) pluginExecution.getConfiguration(), store); } }
[ "private", "void", "addPluginExecutions", "(", "MavenPluginDescriptor", "mavenPluginDescriptor", ",", "Plugin", "plugin", ",", "Store", "store", ")", "{", "List", "<", "PluginExecution", ">", "executions", "=", "plugin", ".", "getExecutions", "(", ")", ";", "for", "(", "PluginExecution", "pluginExecution", ":", "executions", ")", "{", "MavenPluginExecutionDescriptor", "executionDescriptor", "=", "store", ".", "create", "(", "MavenPluginExecutionDescriptor", ".", "class", ")", ";", "executionDescriptor", ".", "setId", "(", "pluginExecution", ".", "getId", "(", ")", ")", ";", "executionDescriptor", ".", "setPhase", "(", "pluginExecution", ".", "getPhase", "(", ")", ")", ";", "executionDescriptor", ".", "setInherited", "(", "pluginExecution", ".", "isInherited", "(", ")", ")", ";", "mavenPluginDescriptor", ".", "getExecutions", "(", ")", ".", "add", "(", "executionDescriptor", ")", ";", "addExecutionGoals", "(", "executionDescriptor", ",", "pluginExecution", ",", "store", ")", ";", "addConfiguration", "(", "executionDescriptor", ",", "(", "Xpp3Dom", ")", "pluginExecution", ".", "getConfiguration", "(", ")", ",", "store", ")", ";", "}", "}" ]
Adds information about plugin executions. @param mavenPluginDescriptor The descriptor for the plugin. @param plugin The Plugin. @param store The database.
[ "Adds", "information", "about", "plugin", "executions", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java#L500-L512
144,301
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java
MavenModelScannerPlugin.addPlugins
private void addPlugins(BaseProfileDescriptor pomDescriptor, BuildBase build, ScannerContext scannerContext) { if (null == build) { return; } List<Plugin> plugins = build.getPlugins(); List<MavenPluginDescriptor> pluginDescriptors = createMavenPluginDescriptors(plugins, scannerContext); pomDescriptor.getPlugins().addAll(pluginDescriptors); }
java
private void addPlugins(BaseProfileDescriptor pomDescriptor, BuildBase build, ScannerContext scannerContext) { if (null == build) { return; } List<Plugin> plugins = build.getPlugins(); List<MavenPluginDescriptor> pluginDescriptors = createMavenPluginDescriptors(plugins, scannerContext); pomDescriptor.getPlugins().addAll(pluginDescriptors); }
[ "private", "void", "addPlugins", "(", "BaseProfileDescriptor", "pomDescriptor", ",", "BuildBase", "build", ",", "ScannerContext", "scannerContext", ")", "{", "if", "(", "null", "==", "build", ")", "{", "return", ";", "}", "List", "<", "Plugin", ">", "plugins", "=", "build", ".", "getPlugins", "(", ")", ";", "List", "<", "MavenPluginDescriptor", ">", "pluginDescriptors", "=", "createMavenPluginDescriptors", "(", "plugins", ",", "scannerContext", ")", ";", "pomDescriptor", ".", "getPlugins", "(", ")", ".", "addAll", "(", "pluginDescriptors", ")", ";", "}" ]
Adds information about plugins. @param pomDescriptor The descriptor for the current POM. @param build Information required to build the project. @param scannerContext The scanner context.
[ "Adds", "information", "about", "plugins", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java#L524-L531
144,302
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java
MavenModelScannerPlugin._addProfileDependencies
private void _addProfileDependencies(MavenProfileDescriptor profileDescriptor, List<Dependency> dependencies, ScannerContext scannerContext) { for (Dependency dependency : dependencies) { MavenArtifactDescriptor dependencyArtifactDescriptor = getMavenArtifactDescriptor(dependency, scannerContext); Store store = scannerContext.getStore(); ProfileDeclaresDependencyDescriptor profileDependsOnDescriptor = store.create(profileDescriptor, ProfileDeclaresDependencyDescriptor.class, dependencyArtifactDescriptor); profileDependsOnDescriptor.setOptional(dependency.isOptional()); profileDependsOnDescriptor.setScope(dependency.getScope()); } }
java
private void _addProfileDependencies(MavenProfileDescriptor profileDescriptor, List<Dependency> dependencies, ScannerContext scannerContext) { for (Dependency dependency : dependencies) { MavenArtifactDescriptor dependencyArtifactDescriptor = getMavenArtifactDescriptor(dependency, scannerContext); Store store = scannerContext.getStore(); ProfileDeclaresDependencyDescriptor profileDependsOnDescriptor = store.create(profileDescriptor, ProfileDeclaresDependencyDescriptor.class, dependencyArtifactDescriptor); profileDependsOnDescriptor.setOptional(dependency.isOptional()); profileDependsOnDescriptor.setScope(dependency.getScope()); } }
[ "private", "void", "_addProfileDependencies", "(", "MavenProfileDescriptor", "profileDescriptor", ",", "List", "<", "Dependency", ">", "dependencies", ",", "ScannerContext", "scannerContext", ")", "{", "for", "(", "Dependency", "dependency", ":", "dependencies", ")", "{", "MavenArtifactDescriptor", "dependencyArtifactDescriptor", "=", "getMavenArtifactDescriptor", "(", "dependency", ",", "scannerContext", ")", ";", "Store", "store", "=", "scannerContext", ".", "getStore", "(", ")", ";", "ProfileDeclaresDependencyDescriptor", "profileDependsOnDescriptor", "=", "store", ".", "create", "(", "profileDescriptor", ",", "ProfileDeclaresDependencyDescriptor", ".", "class", ",", "dependencyArtifactDescriptor", ")", ";", "profileDependsOnDescriptor", ".", "setOptional", "(", "dependency", ".", "isOptional", "(", ")", ")", ";", "profileDependsOnDescriptor", ".", "setScope", "(", "dependency", ".", "getScope", "(", ")", ")", ";", "}", "}" ]
Adds information about profile dependencies. @param profileDescriptor The descriptor for the current profile. @param dependencies The dependencies information. @param scannerContext The scanner context.
[ "Adds", "information", "about", "profile", "dependencies", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java#L543-L552
144,303
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java
MavenModelScannerPlugin.addProfiles
private void addProfiles(MavenPomDescriptor pomDescriptor, Model model, ScannerContext scannerContext) { List<Profile> profiles = model.getProfiles(); Store store = scannerContext.getStore(); for (Profile profile : profiles) { MavenProfileDescriptor mavenProfileDescriptor = store.create(MavenProfileDescriptor.class); pomDescriptor.getProfiles().add(mavenProfileDescriptor); mavenProfileDescriptor.setId(profile.getId()); addProperties(mavenProfileDescriptor, profile.getProperties(), store); addModules(mavenProfileDescriptor, profile.getModules(), store); addPlugins(mavenProfileDescriptor, profile.getBuild(), scannerContext); addManagedPlugins(mavenProfileDescriptor, profile.getBuild(), scannerContext); addDependencies(mavenProfileDescriptor, ProfileDeclaresDependencyDescriptor.class, ProfileManagesDependencyDescriptor.class, profile, scannerContext); addActivation(mavenProfileDescriptor, profile.getActivation(), store); addRepository(of(mavenProfileDescriptor), profile.getRepositories(), store); } }
java
private void addProfiles(MavenPomDescriptor pomDescriptor, Model model, ScannerContext scannerContext) { List<Profile> profiles = model.getProfiles(); Store store = scannerContext.getStore(); for (Profile profile : profiles) { MavenProfileDescriptor mavenProfileDescriptor = store.create(MavenProfileDescriptor.class); pomDescriptor.getProfiles().add(mavenProfileDescriptor); mavenProfileDescriptor.setId(profile.getId()); addProperties(mavenProfileDescriptor, profile.getProperties(), store); addModules(mavenProfileDescriptor, profile.getModules(), store); addPlugins(mavenProfileDescriptor, profile.getBuild(), scannerContext); addManagedPlugins(mavenProfileDescriptor, profile.getBuild(), scannerContext); addDependencies(mavenProfileDescriptor, ProfileDeclaresDependencyDescriptor.class, ProfileManagesDependencyDescriptor.class, profile, scannerContext); addActivation(mavenProfileDescriptor, profile.getActivation(), store); addRepository(of(mavenProfileDescriptor), profile.getRepositories(), store); } }
[ "private", "void", "addProfiles", "(", "MavenPomDescriptor", "pomDescriptor", ",", "Model", "model", ",", "ScannerContext", "scannerContext", ")", "{", "List", "<", "Profile", ">", "profiles", "=", "model", ".", "getProfiles", "(", ")", ";", "Store", "store", "=", "scannerContext", ".", "getStore", "(", ")", ";", "for", "(", "Profile", "profile", ":", "profiles", ")", "{", "MavenProfileDescriptor", "mavenProfileDescriptor", "=", "store", ".", "create", "(", "MavenProfileDescriptor", ".", "class", ")", ";", "pomDescriptor", ".", "getProfiles", "(", ")", ".", "add", "(", "mavenProfileDescriptor", ")", ";", "mavenProfileDescriptor", ".", "setId", "(", "profile", ".", "getId", "(", ")", ")", ";", "addProperties", "(", "mavenProfileDescriptor", ",", "profile", ".", "getProperties", "(", ")", ",", "store", ")", ";", "addModules", "(", "mavenProfileDescriptor", ",", "profile", ".", "getModules", "(", ")", ",", "store", ")", ";", "addPlugins", "(", "mavenProfileDescriptor", ",", "profile", ".", "getBuild", "(", ")", ",", "scannerContext", ")", ";", "addManagedPlugins", "(", "mavenProfileDescriptor", ",", "profile", ".", "getBuild", "(", ")", ",", "scannerContext", ")", ";", "addDependencies", "(", "mavenProfileDescriptor", ",", "ProfileDeclaresDependencyDescriptor", ".", "class", ",", "ProfileManagesDependencyDescriptor", ".", "class", ",", "profile", ",", "scannerContext", ")", ";", "addActivation", "(", "mavenProfileDescriptor", ",", "profile", ".", "getActivation", "(", ")", ",", "store", ")", ";", "addRepository", "(", "of", "(", "mavenProfileDescriptor", ")", ",", "profile", ".", "getRepositories", "(", ")", ",", "store", ")", ";", "}", "}" ]
Adds information about defined profile. @param pomDescriptor The descriptor for the current POM. @param model The Maven Model. @param scannerContext The scanner context.
[ "Adds", "information", "about", "defined", "profile", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java#L564-L579
144,304
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java
MavenModelScannerPlugin.addProperties
private void addProperties(BaseProfileDescriptor pomDescriptor, Properties properties, Store store) { Set<Entry<Object, Object>> entrySet = properties.entrySet(); for (Entry<Object, Object> entry : entrySet) { PropertyDescriptor propertyDescriptor = store.create(PropertyDescriptor.class); propertyDescriptor.setName(entry.getKey().toString()); propertyDescriptor.setValue(entry.getValue().toString()); pomDescriptor.getProperties().add(propertyDescriptor); } }
java
private void addProperties(BaseProfileDescriptor pomDescriptor, Properties properties, Store store) { Set<Entry<Object, Object>> entrySet = properties.entrySet(); for (Entry<Object, Object> entry : entrySet) { PropertyDescriptor propertyDescriptor = store.create(PropertyDescriptor.class); propertyDescriptor.setName(entry.getKey().toString()); propertyDescriptor.setValue(entry.getValue().toString()); pomDescriptor.getProperties().add(propertyDescriptor); } }
[ "private", "void", "addProperties", "(", "BaseProfileDescriptor", "pomDescriptor", ",", "Properties", "properties", ",", "Store", "store", ")", "{", "Set", "<", "Entry", "<", "Object", ",", "Object", ">", ">", "entrySet", "=", "properties", ".", "entrySet", "(", ")", ";", "for", "(", "Entry", "<", "Object", ",", "Object", ">", "entry", ":", "entrySet", ")", "{", "PropertyDescriptor", "propertyDescriptor", "=", "store", ".", "create", "(", "PropertyDescriptor", ".", "class", ")", ";", "propertyDescriptor", ".", "setName", "(", "entry", ".", "getKey", "(", ")", ".", "toString", "(", ")", ")", ";", "propertyDescriptor", ".", "setValue", "(", "entry", ".", "getValue", "(", ")", ".", "toString", "(", ")", ")", ";", "pomDescriptor", ".", "getProperties", "(", ")", ".", "add", "(", "propertyDescriptor", ")", ";", "}", "}" ]
Adds information about defined properties. @param pomDescriptor The descriptor for the current POM. @param properties The properties information. @param store The database.
[ "Adds", "information", "about", "defined", "properties", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java#L614-L623
144,305
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java
MavenModelScannerPlugin.getMavenArtifactDescriptor
private MavenArtifactDescriptor getMavenArtifactDescriptor(Dependency dependency, ScannerContext context) { DependencyCoordinates coordinates = new DependencyCoordinates(dependency); return getArtifactResolver(context).resolve(coordinates, context); }
java
private MavenArtifactDescriptor getMavenArtifactDescriptor(Dependency dependency, ScannerContext context) { DependencyCoordinates coordinates = new DependencyCoordinates(dependency); return getArtifactResolver(context).resolve(coordinates, context); }
[ "private", "MavenArtifactDescriptor", "getMavenArtifactDescriptor", "(", "Dependency", "dependency", ",", "ScannerContext", "context", ")", "{", "DependencyCoordinates", "coordinates", "=", "new", "DependencyCoordinates", "(", "dependency", ")", ";", "return", "getArtifactResolver", "(", "context", ")", ".", "resolve", "(", "coordinates", ",", "context", ")", ";", "}" ]
Creates a MavenArtifactDescriptor and fills it with all information from given dependency. @param dependency Dependency. @param context The scanner context. @return The MavenArtifactDescriptor.
[ "Creates", "a", "MavenArtifactDescriptor", "and", "fills", "it", "with", "all", "information", "from", "given", "dependency", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java#L635-L638
144,306
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java
MavenModelScannerPlugin.getConfigChildNodes
private ValueDescriptor<?> getConfigChildNodes(Xpp3Dom node, Store store) { Xpp3Dom[] children = node.getChildren(); if (children.length == 0) { PropertyDescriptor propertyDescriptor = store.create(PropertyDescriptor.class); propertyDescriptor.setName(node.getName()); propertyDescriptor.setValue(node.getValue()); return propertyDescriptor; } ArrayValueDescriptor childDescriptor = store.create(ArrayValueDescriptor.class); childDescriptor.setName(node.getName()); for (Xpp3Dom child : children) { childDescriptor.getValue().add(getConfigChildNodes(child, store)); } return childDescriptor; }
java
private ValueDescriptor<?> getConfigChildNodes(Xpp3Dom node, Store store) { Xpp3Dom[] children = node.getChildren(); if (children.length == 0) { PropertyDescriptor propertyDescriptor = store.create(PropertyDescriptor.class); propertyDescriptor.setName(node.getName()); propertyDescriptor.setValue(node.getValue()); return propertyDescriptor; } ArrayValueDescriptor childDescriptor = store.create(ArrayValueDescriptor.class); childDescriptor.setName(node.getName()); for (Xpp3Dom child : children) { childDescriptor.getValue().add(getConfigChildNodes(child, store)); } return childDescriptor; }
[ "private", "ValueDescriptor", "<", "?", ">", "getConfigChildNodes", "(", "Xpp3Dom", "node", ",", "Store", "store", ")", "{", "Xpp3Dom", "[", "]", "children", "=", "node", ".", "getChildren", "(", ")", ";", "if", "(", "children", ".", "length", "==", "0", ")", "{", "PropertyDescriptor", "propertyDescriptor", "=", "store", ".", "create", "(", "PropertyDescriptor", ".", "class", ")", ";", "propertyDescriptor", ".", "setName", "(", "node", ".", "getName", "(", ")", ")", ";", "propertyDescriptor", ".", "setValue", "(", "node", ".", "getValue", "(", ")", ")", ";", "return", "propertyDescriptor", ";", "}", "ArrayValueDescriptor", "childDescriptor", "=", "store", ".", "create", "(", "ArrayValueDescriptor", ".", "class", ")", ";", "childDescriptor", ".", "setName", "(", "node", ".", "getName", "(", ")", ")", ";", "for", "(", "Xpp3Dom", "child", ":", "children", ")", "{", "childDescriptor", ".", "getValue", "(", ")", ".", "add", "(", "getConfigChildNodes", "(", "child", ",", "store", ")", ")", ";", "}", "return", "childDescriptor", ";", "}" ]
Returns information about child config entries. @param node Current config node. @param store The database. @return Child config information.
[ "Returns", "information", "about", "child", "config", "entries", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java#L649-L663
144,307
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/api/scanner/MavenRepositoryResolver.java
MavenRepositoryResolver.resolve
public static MavenRepositoryDescriptor resolve(Store store, String url) { MavenRepositoryDescriptor repositoryDescriptor = store.find(MavenRepositoryDescriptor.class, url); if (repositoryDescriptor == null) { repositoryDescriptor = store.create(MavenRepositoryDescriptor.class); repositoryDescriptor.setUrl(url); } return repositoryDescriptor; }
java
public static MavenRepositoryDescriptor resolve(Store store, String url) { MavenRepositoryDescriptor repositoryDescriptor = store.find(MavenRepositoryDescriptor.class, url); if (repositoryDescriptor == null) { repositoryDescriptor = store.create(MavenRepositoryDescriptor.class); repositoryDescriptor.setUrl(url); } return repositoryDescriptor; }
[ "public", "static", "MavenRepositoryDescriptor", "resolve", "(", "Store", "store", ",", "String", "url", ")", "{", "MavenRepositoryDescriptor", "repositoryDescriptor", "=", "store", ".", "find", "(", "MavenRepositoryDescriptor", ".", "class", ",", "url", ")", ";", "if", "(", "repositoryDescriptor", "==", "null", ")", "{", "repositoryDescriptor", "=", "store", ".", "create", "(", "MavenRepositoryDescriptor", ".", "class", ")", ";", "repositoryDescriptor", ".", "setUrl", "(", "url", ")", ";", "}", "return", "repositoryDescriptor", ";", "}" ]
Finds or creates a repository descriptor for the given url. @param store the {@link Store} @param url the repository url @return a {@link MavenRepositoryDescriptor} for the given url.
[ "Finds", "or", "creates", "a", "repository", "descriptor", "for", "the", "given", "url", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/api/scanner/MavenRepositoryResolver.java#L20-L27
144,308
OnyxDevTools/onyx-database-parent
onyx-database-examples/indexes/src/main/java/com/onyxdevtools/index/Main.java
Main.seedData
private static void seedData(PersistenceManager manager) throws OnyxException { // Create test data Book harryPotter = new Book(); harryPotter.setTitle("Harry Potter, Deathly Hallows"); harryPotter.setDescription("Story about a kid that has abnormal creepy powers that seeks revenge on a poor innocent guy named Voldomort."); harryPotter.setGenre("CHILDREN"); Book theGiver = new Book(); theGiver.setTitle("The Giver"); theGiver.setDescription("Something about a whole community of color blind people."); theGiver.setGenre("CHILDREN"); Book twilight = new Book(); twilight.setTitle("Twilight"); twilight.setGenre("CHILDREN"); twilight.setDescription("Book that lead to awful teenie bopper vampire movie."); Book longWayDown = new Book(); longWayDown.setTitle("Long Way Down"); longWayDown.setGenre("TRAVEL"); longWayDown.setDescription("Boring story about something I cant remember."); // Save book data manager.saveEntity(harryPotter); manager.saveEntity(theGiver); manager.saveEntity(twilight); manager.saveEntity(longWayDown); }
java
private static void seedData(PersistenceManager manager) throws OnyxException { // Create test data Book harryPotter = new Book(); harryPotter.setTitle("Harry Potter, Deathly Hallows"); harryPotter.setDescription("Story about a kid that has abnormal creepy powers that seeks revenge on a poor innocent guy named Voldomort."); harryPotter.setGenre("CHILDREN"); Book theGiver = new Book(); theGiver.setTitle("The Giver"); theGiver.setDescription("Something about a whole community of color blind people."); theGiver.setGenre("CHILDREN"); Book twilight = new Book(); twilight.setTitle("Twilight"); twilight.setGenre("CHILDREN"); twilight.setDescription("Book that lead to awful teenie bopper vampire movie."); Book longWayDown = new Book(); longWayDown.setTitle("Long Way Down"); longWayDown.setGenre("TRAVEL"); longWayDown.setDescription("Boring story about something I cant remember."); // Save book data manager.saveEntity(harryPotter); manager.saveEntity(theGiver); manager.saveEntity(twilight); manager.saveEntity(longWayDown); }
[ "private", "static", "void", "seedData", "(", "PersistenceManager", "manager", ")", "throws", "OnyxException", "{", "// Create test data", "Book", "harryPotter", "=", "new", "Book", "(", ")", ";", "harryPotter", ".", "setTitle", "(", "\"Harry Potter, Deathly Hallows\"", ")", ";", "harryPotter", ".", "setDescription", "(", "\"Story about a kid that has abnormal creepy powers that seeks revenge on a poor innocent guy named Voldomort.\"", ")", ";", "harryPotter", ".", "setGenre", "(", "\"CHILDREN\"", ")", ";", "Book", "theGiver", "=", "new", "Book", "(", ")", ";", "theGiver", ".", "setTitle", "(", "\"The Giver\"", ")", ";", "theGiver", ".", "setDescription", "(", "\"Something about a whole community of color blind people.\"", ")", ";", "theGiver", ".", "setGenre", "(", "\"CHILDREN\"", ")", ";", "Book", "twilight", "=", "new", "Book", "(", ")", ";", "twilight", ".", "setTitle", "(", "\"Twilight\"", ")", ";", "twilight", ".", "setGenre", "(", "\"CHILDREN\"", ")", ";", "twilight", ".", "setDescription", "(", "\"Book that lead to awful teenie bopper vampire movie.\"", ")", ";", "Book", "longWayDown", "=", "new", "Book", "(", ")", ";", "longWayDown", ".", "setTitle", "(", "\"Long Way Down\"", ")", ";", "longWayDown", ".", "setGenre", "(", "\"TRAVEL\"", ")", ";", "longWayDown", ".", "setDescription", "(", "\"Boring story about something I cant remember.\"", ")", ";", "// Save book data", "manager", ".", "saveEntity", "(", "harryPotter", ")", ";", "manager", ".", "saveEntity", "(", "theGiver", ")", ";", "manager", ".", "saveEntity", "(", "twilight", ")", ";", "manager", ".", "saveEntity", "(", "longWayDown", ")", ";", "}" ]
Insert test data into a test database @param manager Persistence Manager used to insert data
[ "Insert", "test", "data", "into", "a", "test", "database" ]
474dfc273a094dbc2ca08fcc08a2858cd538c920
https://github.com/OnyxDevTools/onyx-database-parent/blob/474dfc273a094dbc2ca08fcc08a2858cd538c920/onyx-database-examples/indexes/src/main/java/com/onyxdevtools/index/Main.java#L45-L73
144,309
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenProjectScannerPlugin.java
MavenProjectScannerPlugin.getMavenArtifactDescriptor
private <T extends MavenArtifactDescriptor> T getMavenArtifactDescriptor(Coordinates coordinates, ArtifactResolver artifactResolver, Class<T> type, Scanner scanner) { MavenArtifactDescriptor mavenArtifactDescriptor = artifactResolver.resolve(coordinates, scanner.getContext()); return scanner.getContext().getStore().addDescriptorType(mavenArtifactDescriptor, type); }
java
private <T extends MavenArtifactDescriptor> T getMavenArtifactDescriptor(Coordinates coordinates, ArtifactResolver artifactResolver, Class<T> type, Scanner scanner) { MavenArtifactDescriptor mavenArtifactDescriptor = artifactResolver.resolve(coordinates, scanner.getContext()); return scanner.getContext().getStore().addDescriptorType(mavenArtifactDescriptor, type); }
[ "private", "<", "T", "extends", "MavenArtifactDescriptor", ">", "T", "getMavenArtifactDescriptor", "(", "Coordinates", "coordinates", ",", "ArtifactResolver", "artifactResolver", ",", "Class", "<", "T", ">", "type", ",", "Scanner", "scanner", ")", "{", "MavenArtifactDescriptor", "mavenArtifactDescriptor", "=", "artifactResolver", ".", "resolve", "(", "coordinates", ",", "scanner", ".", "getContext", "(", ")", ")", ";", "return", "scanner", ".", "getContext", "(", ")", ".", "getStore", "(", ")", ".", "addDescriptorType", "(", "mavenArtifactDescriptor", ",", "type", ")", ";", "}" ]
Returns a resolved maven artifact descriptor for the given coordinates. @param coordinates The artifact coordinates. @param artifactResolver The artifact resolver. @param type The expected type. @param scanner The scanner. @return The artifact descriptor.
[ "Returns", "a", "resolved", "maven", "artifact", "descriptor", "for", "the", "given", "coordinates", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenProjectScannerPlugin.java#L121-L125
144,310
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenProjectScannerPlugin.java
MavenProjectScannerPlugin.resolveProject
protected <T extends MavenProjectDescriptor> T resolveProject(MavenProject project, Class<T> expectedType, ScannerContext scannerContext) { Store store = scannerContext.getStore(); String id = project.getGroupId() + ":" + project.getArtifactId() + ":" + project.getVersion(); MavenProjectDescriptor projectDescriptor = store.find(MavenProjectDescriptor.class, id); if (projectDescriptor == null) { projectDescriptor = store.create(expectedType, id); projectDescriptor.setName(project.getName()); projectDescriptor.setGroupId(project.getGroupId()); projectDescriptor.setArtifactId(project.getArtifactId()); projectDescriptor.setVersion(project.getVersion()); projectDescriptor.setPackaging(project.getPackaging()); projectDescriptor.setFullQualifiedName(id); } else if (!expectedType.isAssignableFrom(projectDescriptor.getClass())) { projectDescriptor = store.addDescriptorType(projectDescriptor, expectedType); } return expectedType.cast(projectDescriptor); }
java
protected <T extends MavenProjectDescriptor> T resolveProject(MavenProject project, Class<T> expectedType, ScannerContext scannerContext) { Store store = scannerContext.getStore(); String id = project.getGroupId() + ":" + project.getArtifactId() + ":" + project.getVersion(); MavenProjectDescriptor projectDescriptor = store.find(MavenProjectDescriptor.class, id); if (projectDescriptor == null) { projectDescriptor = store.create(expectedType, id); projectDescriptor.setName(project.getName()); projectDescriptor.setGroupId(project.getGroupId()); projectDescriptor.setArtifactId(project.getArtifactId()); projectDescriptor.setVersion(project.getVersion()); projectDescriptor.setPackaging(project.getPackaging()); projectDescriptor.setFullQualifiedName(id); } else if (!expectedType.isAssignableFrom(projectDescriptor.getClass())) { projectDescriptor = store.addDescriptorType(projectDescriptor, expectedType); } return expectedType.cast(projectDescriptor); }
[ "protected", "<", "T", "extends", "MavenProjectDescriptor", ">", "T", "resolveProject", "(", "MavenProject", "project", ",", "Class", "<", "T", ">", "expectedType", ",", "ScannerContext", "scannerContext", ")", "{", "Store", "store", "=", "scannerContext", ".", "getStore", "(", ")", ";", "String", "id", "=", "project", ".", "getGroupId", "(", ")", "+", "\":\"", "+", "project", ".", "getArtifactId", "(", ")", "+", "\":\"", "+", "project", ".", "getVersion", "(", ")", ";", "MavenProjectDescriptor", "projectDescriptor", "=", "store", ".", "find", "(", "MavenProjectDescriptor", ".", "class", ",", "id", ")", ";", "if", "(", "projectDescriptor", "==", "null", ")", "{", "projectDescriptor", "=", "store", ".", "create", "(", "expectedType", ",", "id", ")", ";", "projectDescriptor", ".", "setName", "(", "project", ".", "getName", "(", ")", ")", ";", "projectDescriptor", ".", "setGroupId", "(", "project", ".", "getGroupId", "(", ")", ")", ";", "projectDescriptor", ".", "setArtifactId", "(", "project", ".", "getArtifactId", "(", ")", ")", ";", "projectDescriptor", ".", "setVersion", "(", "project", ".", "getVersion", "(", ")", ")", ";", "projectDescriptor", ".", "setPackaging", "(", "project", ".", "getPackaging", "(", ")", ")", ";", "projectDescriptor", ".", "setFullQualifiedName", "(", "id", ")", ";", "}", "else", "if", "(", "!", "expectedType", ".", "isAssignableFrom", "(", "projectDescriptor", ".", "getClass", "(", ")", ")", ")", "{", "projectDescriptor", "=", "store", ".", "addDescriptorType", "(", "projectDescriptor", ",", "expectedType", ")", ";", "}", "return", "expectedType", ".", "cast", "(", "projectDescriptor", ")", ";", "}" ]
Resolves a maven project. @param project The project @param expectedType The expected descriptor type. @param scannerContext The scanner context. @param <T> The expected descriptor type. @return The maven project descriptor.
[ "Resolves", "a", "maven", "project", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenProjectScannerPlugin.java#L140-L156
144,311
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenProjectScannerPlugin.java
MavenProjectScannerPlugin.addProjectDetails
private void addProjectDetails(MavenProject project, MavenProjectDirectoryDescriptor projectDescriptor, Scanner scanner) { ScannerContext scannerContext = scanner.getContext(); addParent(project, projectDescriptor, scannerContext); addModules(project, projectDescriptor, scannerContext); addModel(project, projectDescriptor, scanner); }
java
private void addProjectDetails(MavenProject project, MavenProjectDirectoryDescriptor projectDescriptor, Scanner scanner) { ScannerContext scannerContext = scanner.getContext(); addParent(project, projectDescriptor, scannerContext); addModules(project, projectDescriptor, scannerContext); addModel(project, projectDescriptor, scanner); }
[ "private", "void", "addProjectDetails", "(", "MavenProject", "project", ",", "MavenProjectDirectoryDescriptor", "projectDescriptor", ",", "Scanner", "scanner", ")", "{", "ScannerContext", "scannerContext", "=", "scanner", ".", "getContext", "(", ")", ";", "addParent", "(", "project", ",", "projectDescriptor", ",", "scannerContext", ")", ";", "addModules", "(", "project", ",", "projectDescriptor", ",", "scannerContext", ")", ";", "addModel", "(", "project", ",", "projectDescriptor", ",", "scanner", ")", ";", "}" ]
Add project specific information. @param project The project. @param projectDescriptor The project descriptor.
[ "Add", "project", "specific", "information", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenProjectScannerPlugin.java#L199-L204
144,312
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenProjectScannerPlugin.java
MavenProjectScannerPlugin.addModel
private void addModel(MavenProject project, MavenProjectDirectoryDescriptor projectDescriptor, Scanner scanner) { File pomXmlFile = project.getFile(); FileDescriptor mavenPomXmlDescriptor = scanner.scan(pomXmlFile, pomXmlFile.getAbsolutePath(), MavenScope.PROJECT); projectDescriptor.setModel(mavenPomXmlDescriptor); // Effective model MavenPomDescriptor effectiveModelDescriptor = scanner.getContext().getStore().create(MavenPomDescriptor.class); Model model = new EffectiveModel(project.getModel()); scanner.getContext().push(MavenPomDescriptor.class, effectiveModelDescriptor); scanner.scan(model, pomXmlFile.getAbsolutePath(), MavenScope.PROJECT); scanner.getContext().pop(MavenPomDescriptor.class); projectDescriptor.setEffectiveModel(effectiveModelDescriptor); }
java
private void addModel(MavenProject project, MavenProjectDirectoryDescriptor projectDescriptor, Scanner scanner) { File pomXmlFile = project.getFile(); FileDescriptor mavenPomXmlDescriptor = scanner.scan(pomXmlFile, pomXmlFile.getAbsolutePath(), MavenScope.PROJECT); projectDescriptor.setModel(mavenPomXmlDescriptor); // Effective model MavenPomDescriptor effectiveModelDescriptor = scanner.getContext().getStore().create(MavenPomDescriptor.class); Model model = new EffectiveModel(project.getModel()); scanner.getContext().push(MavenPomDescriptor.class, effectiveModelDescriptor); scanner.scan(model, pomXmlFile.getAbsolutePath(), MavenScope.PROJECT); scanner.getContext().pop(MavenPomDescriptor.class); projectDescriptor.setEffectiveModel(effectiveModelDescriptor); }
[ "private", "void", "addModel", "(", "MavenProject", "project", ",", "MavenProjectDirectoryDescriptor", "projectDescriptor", ",", "Scanner", "scanner", ")", "{", "File", "pomXmlFile", "=", "project", ".", "getFile", "(", ")", ";", "FileDescriptor", "mavenPomXmlDescriptor", "=", "scanner", ".", "scan", "(", "pomXmlFile", ",", "pomXmlFile", ".", "getAbsolutePath", "(", ")", ",", "MavenScope", ".", "PROJECT", ")", ";", "projectDescriptor", ".", "setModel", "(", "mavenPomXmlDescriptor", ")", ";", "// Effective model", "MavenPomDescriptor", "effectiveModelDescriptor", "=", "scanner", ".", "getContext", "(", ")", ".", "getStore", "(", ")", ".", "create", "(", "MavenPomDescriptor", ".", "class", ")", ";", "Model", "model", "=", "new", "EffectiveModel", "(", "project", ".", "getModel", "(", ")", ")", ";", "scanner", ".", "getContext", "(", ")", ".", "push", "(", "MavenPomDescriptor", ".", "class", ",", "effectiveModelDescriptor", ")", ";", "scanner", ".", "scan", "(", "model", ",", "pomXmlFile", ".", "getAbsolutePath", "(", ")", ",", "MavenScope", ".", "PROJECT", ")", ";", "scanner", ".", "getContext", "(", ")", ".", "pop", "(", "MavenPomDescriptor", ".", "class", ")", ";", "projectDescriptor", ".", "setEffectiveModel", "(", "effectiveModelDescriptor", ")", ";", "}" ]
Scan the pom.xml file and add it as model. @param project The Maven project @param projectDescriptor The project descriptor. @param scanner The scanner.
[ "Scan", "the", "pom", ".", "xml", "file", "and", "add", "it", "as", "model", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenProjectScannerPlugin.java#L216-L227
144,313
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenProjectScannerPlugin.java
MavenProjectScannerPlugin.addParent
private void addParent(MavenProject project, MavenProjectDirectoryDescriptor projectDescriptor, ScannerContext scannerContext) { MavenProject parent = project.getParent(); if (parent != null) { MavenProjectDescriptor parentDescriptor = resolveProject(parent, MavenProjectDescriptor.class, scannerContext); projectDescriptor.setParent(parentDescriptor); } }
java
private void addParent(MavenProject project, MavenProjectDirectoryDescriptor projectDescriptor, ScannerContext scannerContext) { MavenProject parent = project.getParent(); if (parent != null) { MavenProjectDescriptor parentDescriptor = resolveProject(parent, MavenProjectDescriptor.class, scannerContext); projectDescriptor.setParent(parentDescriptor); } }
[ "private", "void", "addParent", "(", "MavenProject", "project", ",", "MavenProjectDirectoryDescriptor", "projectDescriptor", ",", "ScannerContext", "scannerContext", ")", "{", "MavenProject", "parent", "=", "project", ".", "getParent", "(", ")", ";", "if", "(", "parent", "!=", "null", ")", "{", "MavenProjectDescriptor", "parentDescriptor", "=", "resolveProject", "(", "parent", ",", "MavenProjectDescriptor", ".", "class", ",", "scannerContext", ")", ";", "projectDescriptor", ".", "setParent", "(", "parentDescriptor", ")", ";", "}", "}" ]
Add the relation to the parent project. @param project The project. @param projectDescriptor The project descriptor.
[ "Add", "the", "relation", "to", "the", "parent", "project", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenProjectScannerPlugin.java#L237-L243
144,314
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenProjectScannerPlugin.java
MavenProjectScannerPlugin.addModules
private void addModules(MavenProject project, MavenProjectDirectoryDescriptor projectDescriptor, ScannerContext scannerContext) { File projectDirectory = project.getBasedir(); Set<File> modules = new HashSet<>(); for (String moduleName : project.getModules()) { File module = new File(projectDirectory, moduleName); modules.add(module); } for (MavenProject module : project.getCollectedProjects()) { if (modules.contains(module.getBasedir())) { MavenProjectDescriptor moduleDescriptor = resolveProject(module, MavenProjectDescriptor.class, scannerContext); projectDescriptor.getModules().add(moduleDescriptor); } } }
java
private void addModules(MavenProject project, MavenProjectDirectoryDescriptor projectDescriptor, ScannerContext scannerContext) { File projectDirectory = project.getBasedir(); Set<File> modules = new HashSet<>(); for (String moduleName : project.getModules()) { File module = new File(projectDirectory, moduleName); modules.add(module); } for (MavenProject module : project.getCollectedProjects()) { if (modules.contains(module.getBasedir())) { MavenProjectDescriptor moduleDescriptor = resolveProject(module, MavenProjectDescriptor.class, scannerContext); projectDescriptor.getModules().add(moduleDescriptor); } } }
[ "private", "void", "addModules", "(", "MavenProject", "project", ",", "MavenProjectDirectoryDescriptor", "projectDescriptor", ",", "ScannerContext", "scannerContext", ")", "{", "File", "projectDirectory", "=", "project", ".", "getBasedir", "(", ")", ";", "Set", "<", "File", ">", "modules", "=", "new", "HashSet", "<>", "(", ")", ";", "for", "(", "String", "moduleName", ":", "project", ".", "getModules", "(", ")", ")", "{", "File", "module", "=", "new", "File", "(", "projectDirectory", ",", "moduleName", ")", ";", "modules", ".", "add", "(", "module", ")", ";", "}", "for", "(", "MavenProject", "module", ":", "project", ".", "getCollectedProjects", "(", ")", ")", "{", "if", "(", "modules", ".", "contains", "(", "module", ".", "getBasedir", "(", ")", ")", ")", "{", "MavenProjectDescriptor", "moduleDescriptor", "=", "resolveProject", "(", "module", ",", "MavenProjectDescriptor", ".", "class", ",", "scannerContext", ")", ";", "projectDescriptor", ".", "getModules", "(", ")", ".", "add", "(", "moduleDescriptor", ")", ";", "}", "}", "}" ]
Add relations to the modules. @param project The project. @param projectDescriptor The project descriptor. @param scannerContext The scanner context.
[ "Add", "relations", "to", "the", "modules", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenProjectScannerPlugin.java#L255-L268
144,315
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenProjectScannerPlugin.java
MavenProjectScannerPlugin.scanClassesDirectory
private void scanClassesDirectory(MavenProjectDirectoryDescriptor projectDescriptor, MavenArtifactDescriptor artifactDescriptor, final String directoryName, Scanner scanner) { File directory = new File(directoryName); if (directory.exists()) { scanArtifact(projectDescriptor, artifactDescriptor, directory, directoryName, scanner); } }
java
private void scanClassesDirectory(MavenProjectDirectoryDescriptor projectDescriptor, MavenArtifactDescriptor artifactDescriptor, final String directoryName, Scanner scanner) { File directory = new File(directoryName); if (directory.exists()) { scanArtifact(projectDescriptor, artifactDescriptor, directory, directoryName, scanner); } }
[ "private", "void", "scanClassesDirectory", "(", "MavenProjectDirectoryDescriptor", "projectDescriptor", ",", "MavenArtifactDescriptor", "artifactDescriptor", ",", "final", "String", "directoryName", ",", "Scanner", "scanner", ")", "{", "File", "directory", "=", "new", "File", "(", "directoryName", ")", ";", "if", "(", "directory", ".", "exists", "(", ")", ")", "{", "scanArtifact", "(", "projectDescriptor", ",", "artifactDescriptor", ",", "directory", ",", "directoryName", ",", "scanner", ")", ";", "}", "}" ]
Scan the given directory for classes and add them to an artifact. @param projectDescriptor The maven project. @param artifactDescriptor The artifact. @param directoryName The name of the directory. @param scanner The scanner.
[ "Scan", "the", "given", "directory", "for", "classes", "and", "add", "them", "to", "an", "artifact", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenProjectScannerPlugin.java#L282-L288
144,316
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenProjectScannerPlugin.java
MavenProjectScannerPlugin.scanFile
private <F extends FileDescriptor> F scanFile(MavenProjectDirectoryDescriptor projectDescriptor, File file, String path, Scope scope, Scanner scanner) { scanner.getContext().push(MavenProjectDirectoryDescriptor.class, projectDescriptor); try { return scanner.scan(file, path, scope); } finally { scanner.getContext().pop(MavenProjectDirectoryDescriptor.class); } }
java
private <F extends FileDescriptor> F scanFile(MavenProjectDirectoryDescriptor projectDescriptor, File file, String path, Scope scope, Scanner scanner) { scanner.getContext().push(MavenProjectDirectoryDescriptor.class, projectDescriptor); try { return scanner.scan(file, path, scope); } finally { scanner.getContext().pop(MavenProjectDirectoryDescriptor.class); } }
[ "private", "<", "F", "extends", "FileDescriptor", ">", "F", "scanFile", "(", "MavenProjectDirectoryDescriptor", "projectDescriptor", ",", "File", "file", ",", "String", "path", ",", "Scope", "scope", ",", "Scanner", "scanner", ")", "{", "scanner", ".", "getContext", "(", ")", ".", "push", "(", "MavenProjectDirectoryDescriptor", ".", "class", ",", "projectDescriptor", ")", ";", "try", "{", "return", "scanner", ".", "scan", "(", "file", ",", "path", ",", "scope", ")", ";", "}", "finally", "{", "scanner", ".", "getContext", "(", ")", ".", "pop", "(", "MavenProjectDirectoryDescriptor", ".", "class", ")", ";", "}", "}" ]
Scan a given file. <p> The current project is pushed to the context. </p> @param projectDescriptor The maven project descriptor. @param file The file. @param path The path. @param scope The scope. @param scanner The scanner.
[ "Scan", "a", "given", "file", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenProjectScannerPlugin.java#L360-L367
144,317
OnyxDevTools/onyx-database-parent
onyx-database-examples/spring-example/src/main/java/com/onyxdevtools/spring/MeetingController.java
MeetingController.findBoringMeetings
@SuppressWarnings({"unchecked", "SpellCheckingInspection"}) List<Meeting> findBoringMeetings() { Query query = new Query(Meeting.class, new QueryCriteria("notes", QueryCriteriaOperator.CONTAINS, "Boring")); List<Meeting> boringMeetings = null; try { boringMeetings = persistenceManager.executeQuery(query); } catch (OnyxException e) { // Log an error } return boringMeetings; }
java
@SuppressWarnings({"unchecked", "SpellCheckingInspection"}) List<Meeting> findBoringMeetings() { Query query = new Query(Meeting.class, new QueryCriteria("notes", QueryCriteriaOperator.CONTAINS, "Boring")); List<Meeting> boringMeetings = null; try { boringMeetings = persistenceManager.executeQuery(query); } catch (OnyxException e) { // Log an error } return boringMeetings; }
[ "@", "SuppressWarnings", "(", "{", "\"unchecked\"", ",", "\"SpellCheckingInspection\"", "}", ")", "List", "<", "Meeting", ">", "findBoringMeetings", "(", ")", "{", "Query", "query", "=", "new", "Query", "(", "Meeting", ".", "class", ",", "new", "QueryCriteria", "(", "\"notes\"", ",", "QueryCriteriaOperator", ".", "CONTAINS", ",", "\"Boring\"", ")", ")", ";", "List", "<", "Meeting", ">", "boringMeetings", "=", "null", ";", "try", "{", "boringMeetings", "=", "persistenceManager", ".", "executeQuery", "(", "query", ")", ";", "}", "catch", "(", "OnyxException", "e", ")", "{", "// Log an error", "}", "return", "boringMeetings", ";", "}" ]
Method used to stream all meetings at work that are snoozers and are really hard to stay awake but, you still have to pay attention because someone is going to call on you and ask you a dumb question. @return A list of really boring meetings
[ "Method", "used", "to", "stream", "all", "meetings", "at", "work", "that", "are", "snoozers", "and", "are", "really", "hard", "to", "stay", "awake", "but", "you", "still", "have", "to", "pay", "attention", "because", "someone", "is", "going", "to", "call", "on", "you", "and", "ask", "you", "a", "dumb", "question", "." ]
474dfc273a094dbc2ca08fcc08a2858cd538c920
https://github.com/OnyxDevTools/onyx-database-parent/blob/474dfc273a094dbc2ca08fcc08a2858cd538c920/onyx-database-examples/spring-example/src/main/java/com/onyxdevtools/spring/MeetingController.java#L43-L54
144,318
OnyxDevTools/onyx-database-parent
onyx-database-examples/spring-example/src/main/java/com/onyxdevtools/spring/MeetingApplicationConfiguration.java
MeetingApplicationConfiguration.persistenceManagerFactory
@Bean protected PersistenceManagerFactory persistenceManagerFactory() throws InitializationException { CacheManagerFactory cacheManagerFactory = new CacheManagerFactory(); cacheManagerFactory.initialize(); return cacheManagerFactory; }
java
@Bean protected PersistenceManagerFactory persistenceManagerFactory() throws InitializationException { CacheManagerFactory cacheManagerFactory = new CacheManagerFactory(); cacheManagerFactory.initialize(); return cacheManagerFactory; }
[ "@", "Bean", "protected", "PersistenceManagerFactory", "persistenceManagerFactory", "(", ")", "throws", "InitializationException", "{", "CacheManagerFactory", "cacheManagerFactory", "=", "new", "CacheManagerFactory", "(", ")", ";", "cacheManagerFactory", ".", "initialize", "(", ")", ";", "return", "cacheManagerFactory", ";", "}" ]
Persistence Manager factory. This determines your database connection. This would have the same usage if you were connecting to an embedded or remote database. The only difference would be the factory type. @return Initialized Persistence Manager Factory
[ "Persistence", "Manager", "factory", ".", "This", "determines", "your", "database", "connection", ".", "This", "would", "have", "the", "same", "usage", "if", "you", "were", "connecting", "to", "an", "embedded", "or", "remote", "database", ".", "The", "only", "difference", "would", "be", "the", "factory", "type", "." ]
474dfc273a094dbc2ca08fcc08a2858cd538c920
https://github.com/OnyxDevTools/onyx-database-parent/blob/474dfc273a094dbc2ca08fcc08a2858cd538c920/onyx-database-examples/spring-example/src/main/java/com/onyxdevtools/spring/MeetingApplicationConfiguration.java#L20-L26
144,319
OnyxDevTools/onyx-database-parent
onyx-database-examples/remote-persistence-manager/onyx-database-server/src/main/java/com/onyxdevtools/server/Main.java
Main.main
public static void main(String[] args) throws Exception { String pathToOnyxDB = System.getProperty("user.home") + File.separatorChar + ".onyxdb" + File.separatorChar + "sandbox" + File.separatorChar +"remote-db.oxd"; DatabaseServer server1 = new DatabaseServer(pathToOnyxDB); server1.setPort(8081); server1.setCredentials("onyx-remote", "SavingDataIsFun!"); server1.start(); System.out.println("Server Started"); server1.join(); //joins the database thread with the application thread }
java
public static void main(String[] args) throws Exception { String pathToOnyxDB = System.getProperty("user.home") + File.separatorChar + ".onyxdb" + File.separatorChar + "sandbox" + File.separatorChar +"remote-db.oxd"; DatabaseServer server1 = new DatabaseServer(pathToOnyxDB); server1.setPort(8081); server1.setCredentials("onyx-remote", "SavingDataIsFun!"); server1.start(); System.out.println("Server Started"); server1.join(); //joins the database thread with the application thread }
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "Exception", "{", "String", "pathToOnyxDB", "=", "System", ".", "getProperty", "(", "\"user.home\"", ")", "+", "File", ".", "separatorChar", "+", "\".onyxdb\"", "+", "File", ".", "separatorChar", "+", "\"sandbox\"", "+", "File", ".", "separatorChar", "+", "\"remote-db.oxd\"", ";", "DatabaseServer", "server1", "=", "new", "DatabaseServer", "(", "pathToOnyxDB", ")", ";", "server1", ".", "setPort", "(", "8081", ")", ";", "server1", ".", "setCredentials", "(", "\"onyx-remote\"", ",", "\"SavingDataIsFun!\"", ")", ";", "server1", ".", "start", "(", ")", ";", "System", ".", "out", ".", "println", "(", "\"Server Started\"", ")", ";", "server1", ".", "join", "(", ")", ";", "//joins the database thread with the application thread", "}" ]
Run Database Server ex: executable /Database/Location/On/Disk 8080 admin admin @param args Command line arguments @throws Exception General exception
[ "Run", "Database", "Server" ]
474dfc273a094dbc2ca08fcc08a2858cd538c920
https://github.com/OnyxDevTools/onyx-database-parent/blob/474dfc273a094dbc2ca08fcc08a2858cd538c920/onyx-database-examples/remote-persistence-manager/onyx-database-server/src/main/java/com/onyxdevtools/server/Main.java#L19-L34
144,320
OnyxDevTools/onyx-database-parent
onyx-database-examples/partition/src/main/java/com/onyxdevtools/partition/Main.java
Main.seedData
private static void seedData(PersistenceManager manager) throws OnyxException { // Create a call log for area code (555) CellPhone myPhoneNumber = new CellPhone(); myPhoneNumber.setCellPhoneNumber("(555) 303-2322"); myPhoneNumber.setAreaCode(555); manager.saveEntity(myPhoneNumber); CallLog callToMom = new CallLog(); callToMom.setDestinationNumber("(555) 323-2222"); callToMom.setNSAListening(true); callToMom.setCallFrom(myPhoneNumber); callToMom.setCallFromAreaCode(myPhoneNumber.getAreaCode()); manager.saveEntity(callToMom); @SuppressWarnings("SpellCheckingInspection") CallLog callToEdwardSnowden = new CallLog(); callToEdwardSnowden.setDestinationNumber("(555) 122-2341"); callToEdwardSnowden.setNSAListening(false); callToEdwardSnowden.setCallFrom(myPhoneNumber); callToEdwardSnowden.setCallFromAreaCode(myPhoneNumber.getAreaCode()); manager.saveEntity(callToEdwardSnowden); // Create a call log for area code (123) // Note: Identifiers are not unique among partitions. Since the entire object graph is saved, // it is possible in this example to have the same identifiers for a CallLog in area code 555 as well as 123 CellPhone mySecretPhone = new CellPhone(); mySecretPhone.setCellPhoneNumber("(123) 936-3733"); mySecretPhone.setAreaCode(123); manager.saveEntity(mySecretPhone); CallLog callToSomeoneShady = new CallLog(); callToSomeoneShady.setDestinationNumber("(555) 322-1143"); callToSomeoneShady.setNSAListening(false); callToSomeoneShady.setCallFrom(mySecretPhone); callToSomeoneShady.setCallFromAreaCode(mySecretPhone.getAreaCode()); manager.saveEntity(callToSomeoneShady); CallLog callToJoe = new CallLog(); callToJoe.setDestinationNumber("(555) 286-9987"); callToJoe.setNSAListening(true); callToJoe.setCallFrom(mySecretPhone); callToJoe.setCallFromAreaCode(mySecretPhone.getAreaCode()); manager.saveEntity(callToJoe); }
java
private static void seedData(PersistenceManager manager) throws OnyxException { // Create a call log for area code (555) CellPhone myPhoneNumber = new CellPhone(); myPhoneNumber.setCellPhoneNumber("(555) 303-2322"); myPhoneNumber.setAreaCode(555); manager.saveEntity(myPhoneNumber); CallLog callToMom = new CallLog(); callToMom.setDestinationNumber("(555) 323-2222"); callToMom.setNSAListening(true); callToMom.setCallFrom(myPhoneNumber); callToMom.setCallFromAreaCode(myPhoneNumber.getAreaCode()); manager.saveEntity(callToMom); @SuppressWarnings("SpellCheckingInspection") CallLog callToEdwardSnowden = new CallLog(); callToEdwardSnowden.setDestinationNumber("(555) 122-2341"); callToEdwardSnowden.setNSAListening(false); callToEdwardSnowden.setCallFrom(myPhoneNumber); callToEdwardSnowden.setCallFromAreaCode(myPhoneNumber.getAreaCode()); manager.saveEntity(callToEdwardSnowden); // Create a call log for area code (123) // Note: Identifiers are not unique among partitions. Since the entire object graph is saved, // it is possible in this example to have the same identifiers for a CallLog in area code 555 as well as 123 CellPhone mySecretPhone = new CellPhone(); mySecretPhone.setCellPhoneNumber("(123) 936-3733"); mySecretPhone.setAreaCode(123); manager.saveEntity(mySecretPhone); CallLog callToSomeoneShady = new CallLog(); callToSomeoneShady.setDestinationNumber("(555) 322-1143"); callToSomeoneShady.setNSAListening(false); callToSomeoneShady.setCallFrom(mySecretPhone); callToSomeoneShady.setCallFromAreaCode(mySecretPhone.getAreaCode()); manager.saveEntity(callToSomeoneShady); CallLog callToJoe = new CallLog(); callToJoe.setDestinationNumber("(555) 286-9987"); callToJoe.setNSAListening(true); callToJoe.setCallFrom(mySecretPhone); callToJoe.setCallFromAreaCode(mySecretPhone.getAreaCode()); manager.saveEntity(callToJoe); }
[ "private", "static", "void", "seedData", "(", "PersistenceManager", "manager", ")", "throws", "OnyxException", "{", "// Create a call log for area code (555)", "CellPhone", "myPhoneNumber", "=", "new", "CellPhone", "(", ")", ";", "myPhoneNumber", ".", "setCellPhoneNumber", "(", "\"(555) 303-2322\"", ")", ";", "myPhoneNumber", ".", "setAreaCode", "(", "555", ")", ";", "manager", ".", "saveEntity", "(", "myPhoneNumber", ")", ";", "CallLog", "callToMom", "=", "new", "CallLog", "(", ")", ";", "callToMom", ".", "setDestinationNumber", "(", "\"(555) 323-2222\"", ")", ";", "callToMom", ".", "setNSAListening", "(", "true", ")", ";", "callToMom", ".", "setCallFrom", "(", "myPhoneNumber", ")", ";", "callToMom", ".", "setCallFromAreaCode", "(", "myPhoneNumber", ".", "getAreaCode", "(", ")", ")", ";", "manager", ".", "saveEntity", "(", "callToMom", ")", ";", "@", "SuppressWarnings", "(", "\"SpellCheckingInspection\"", ")", "CallLog", "callToEdwardSnowden", "=", "new", "CallLog", "(", ")", ";", "callToEdwardSnowden", ".", "setDestinationNumber", "(", "\"(555) 122-2341\"", ")", ";", "callToEdwardSnowden", ".", "setNSAListening", "(", "false", ")", ";", "callToEdwardSnowden", ".", "setCallFrom", "(", "myPhoneNumber", ")", ";", "callToEdwardSnowden", ".", "setCallFromAreaCode", "(", "myPhoneNumber", ".", "getAreaCode", "(", ")", ")", ";", "manager", ".", "saveEntity", "(", "callToEdwardSnowden", ")", ";", "// Create a call log for area code (123)", "// Note: Identifiers are not unique among partitions. Since the entire object graph is saved,", "// it is possible in this example to have the same identifiers for a CallLog in area code 555 as well as 123", "CellPhone", "mySecretPhone", "=", "new", "CellPhone", "(", ")", ";", "mySecretPhone", ".", "setCellPhoneNumber", "(", "\"(123) 936-3733\"", ")", ";", "mySecretPhone", ".", "setAreaCode", "(", "123", ")", ";", "manager", ".", "saveEntity", "(", "mySecretPhone", ")", ";", "CallLog", "callToSomeoneShady", "=", "new", "CallLog", "(", ")", ";", "callToSomeoneShady", ".", "setDestinationNumber", "(", "\"(555) 322-1143\"", ")", ";", "callToSomeoneShady", ".", "setNSAListening", "(", "false", ")", ";", "callToSomeoneShady", ".", "setCallFrom", "(", "mySecretPhone", ")", ";", "callToSomeoneShady", ".", "setCallFromAreaCode", "(", "mySecretPhone", ".", "getAreaCode", "(", ")", ")", ";", "manager", ".", "saveEntity", "(", "callToSomeoneShady", ")", ";", "CallLog", "callToJoe", "=", "new", "CallLog", "(", ")", ";", "callToJoe", ".", "setDestinationNumber", "(", "\"(555) 286-9987\"", ")", ";", "callToJoe", ".", "setNSAListening", "(", "true", ")", ";", "callToJoe", ".", "setCallFrom", "(", "mySecretPhone", ")", ";", "callToJoe", ".", "setCallFromAreaCode", "(", "mySecretPhone", ".", "getAreaCode", "(", ")", ")", ";", "manager", ".", "saveEntity", "(", "callToJoe", ")", ";", "}" ]
Seed Cell phone log data @param manager Persistence Manager to use to seed data @throws OnyxException Generic exception from persistence manager
[ "Seed", "Cell", "phone", "log", "data" ]
474dfc273a094dbc2ca08fcc08a2858cd538c920
https://github.com/OnyxDevTools/onyx-database-parent/blob/474dfc273a094dbc2ca08fcc08a2858cd538c920/onyx-database-examples/partition/src/main/java/com/onyxdevtools/partition/Main.java#L76-L121
144,321
OnyxDevTools/onyx-database-parent
onyx-database-examples/performance-benchmarks/src/main/java/com/onyxdevtools/provider/manager/OnyxPersistenceManager.java
OnyxPersistenceManager.update
public void update(Object object) { try { persistenceManager.saveEntity((IManagedEntity) object); } catch (InitializationException ignore){} catch (Exception e) { e.printStackTrace(); } }
java
public void update(Object object) { try { persistenceManager.saveEntity((IManagedEntity) object); } catch (InitializationException ignore){} catch (Exception e) { e.printStackTrace(); } }
[ "public", "void", "update", "(", "Object", "object", ")", "{", "try", "{", "persistenceManager", ".", "saveEntity", "(", "(", "IManagedEntity", ")", "object", ")", ";", "}", "catch", "(", "InitializationException", "ignore", ")", "{", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
Update an entity that must already exist. Within onyx there is no differentiation between inserting and updating so either way it will call the saveEntity method @param object Object to update
[ "Update", "an", "entity", "that", "must", "already", "exist", ".", "Within", "onyx", "there", "is", "no", "differentiation", "between", "inserting", "and", "updating", "so", "either", "way", "it", "will", "call", "the", "saveEntity", "method" ]
474dfc273a094dbc2ca08fcc08a2858cd538c920
https://github.com/OnyxDevTools/onyx-database-parent/blob/474dfc273a094dbc2ca08fcc08a2858cd538c920/onyx-database-examples/performance-benchmarks/src/main/java/com/onyxdevtools/provider/manager/OnyxPersistenceManager.java#L38-L45
144,322
OnyxDevTools/onyx-database-parent
onyx-database-examples/performance-benchmarks/src/main/java/com/onyxdevtools/provider/manager/OnyxPersistenceManager.java
OnyxPersistenceManager.list
public List list(Class clazz, String key, Object value) { QueryCriteria criteria = new QueryCriteria(key, QueryCriteriaOperator.EQUAL, value); Query query = new Query(clazz, criteria); try { return persistenceManager.executeLazyQuery(query); } catch (InitializationException ignore){} catch (Exception e) { e.printStackTrace(); } return null; }
java
public List list(Class clazz, String key, Object value) { QueryCriteria criteria = new QueryCriteria(key, QueryCriteriaOperator.EQUAL, value); Query query = new Query(clazz, criteria); try { return persistenceManager.executeLazyQuery(query); } catch (InitializationException ignore){} catch (Exception e) { e.printStackTrace(); } return null; }
[ "public", "List", "list", "(", "Class", "clazz", ",", "String", "key", ",", "Object", "value", ")", "{", "QueryCriteria", "criteria", "=", "new", "QueryCriteria", "(", "key", ",", "QueryCriteriaOperator", ".", "EQUAL", ",", "value", ")", ";", "Query", "query", "=", "new", "Query", "(", "clazz", ",", "criteria", ")", ";", "try", "{", "return", "persistenceManager", ".", "executeLazyQuery", "(", "query", ")", ";", "}", "catch", "(", "InitializationException", "ignore", ")", "{", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "null", ";", "}" ]
Execute query with criteria of key = key @param clazz Entity to query @param key Attribute to predicate upon @param value Attribute key to predicate upon @return List of entities that match the criteria
[ "Execute", "query", "with", "criteria", "of", "key", "=", "key" ]
474dfc273a094dbc2ca08fcc08a2858cd538c920
https://github.com/OnyxDevTools/onyx-database-parent/blob/474dfc273a094dbc2ca08fcc08a2858cd538c920/onyx-database-examples/performance-benchmarks/src/main/java/com/onyxdevtools/provider/manager/OnyxPersistenceManager.java#L105-L117
144,323
OnyxDevTools/onyx-database-parent
onyx-database-examples/performance-benchmarks/src/main/java/com/onyxdevtools/provider/manager/JPAPersistenceManager.java
JPAPersistenceManager.insert
public void insert(Object object) { EntityManager entityManager = null; try { entityManager = entityManagers.poll(); entityManager.getTransaction().begin(); try { entityManager.persist(object); entityManager.getTransaction().commit(); } catch (Exception e) { e.printStackTrace(); entityManager.getTransaction().rollback(); } } finally { if(entityManager != null) entityManagers.add(entityManager); } }
java
public void insert(Object object) { EntityManager entityManager = null; try { entityManager = entityManagers.poll(); entityManager.getTransaction().begin(); try { entityManager.persist(object); entityManager.getTransaction().commit(); } catch (Exception e) { e.printStackTrace(); entityManager.getTransaction().rollback(); } } finally { if(entityManager != null) entityManagers.add(entityManager); } }
[ "public", "void", "insert", "(", "Object", "object", ")", "{", "EntityManager", "entityManager", "=", "null", ";", "try", "{", "entityManager", "=", "entityManagers", ".", "poll", "(", ")", ";", "entityManager", ".", "getTransaction", "(", ")", ".", "begin", "(", ")", ";", "try", "{", "entityManager", ".", "persist", "(", "object", ")", ";", "entityManager", ".", "getTransaction", "(", ")", ".", "commit", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "entityManager", ".", "getTransaction", "(", ")", ".", "rollback", "(", ")", ";", "}", "}", "finally", "{", "if", "(", "entityManager", "!=", "null", ")", "entityManagers", ".", "add", "(", "entityManager", ")", ";", "}", "}" ]
Insert an entity that must not already exist within the database. Within JPA this uses the persist method as opposed to the merge. @param object Object to insert
[ "Insert", "an", "entity", "that", "must", "not", "already", "exist", "within", "the", "database", ".", "Within", "JPA", "this", "uses", "the", "persist", "method", "as", "opposed", "to", "the", "merge", "." ]
474dfc273a094dbc2ca08fcc08a2858cd538c920
https://github.com/OnyxDevTools/onyx-database-parent/blob/474dfc273a094dbc2ca08fcc08a2858cd538c920/onyx-database-examples/performance-benchmarks/src/main/java/com/onyxdevtools/provider/manager/JPAPersistenceManager.java#L73-L90
144,324
OnyxDevTools/onyx-database-parent
onyx-database-examples/performance-benchmarks/src/main/java/com/onyxdevtools/provider/manager/JPAPersistenceManager.java
JPAPersistenceManager.list
public List list(Class clazz, String key, Object value) { EntityManager entityManager = null; try { entityManager = entityManagers.poll(); Query query = entityManager.createQuery("SELECT c FROM " + clazz.getCanonicalName() + " c where c." + key + " = :param"); query.setParameter("param", value); return query.getResultList(); } catch (Exception e) { e.printStackTrace(); } finally { if(entityManager != null) entityManagers.add(entityManager); } return null; }
java
public List list(Class clazz, String key, Object value) { EntityManager entityManager = null; try { entityManager = entityManagers.poll(); Query query = entityManager.createQuery("SELECT c FROM " + clazz.getCanonicalName() + " c where c." + key + " = :param"); query.setParameter("param", value); return query.getResultList(); } catch (Exception e) { e.printStackTrace(); } finally { if(entityManager != null) entityManagers.add(entityManager); } return null; }
[ "public", "List", "list", "(", "Class", "clazz", ",", "String", "key", ",", "Object", "value", ")", "{", "EntityManager", "entityManager", "=", "null", ";", "try", "{", "entityManager", "=", "entityManagers", ".", "poll", "(", ")", ";", "Query", "query", "=", "entityManager", ".", "createQuery", "(", "\"SELECT c FROM \"", "+", "clazz", ".", "getCanonicalName", "(", ")", "+", "\" c where c.\"", "+", "key", "+", "\" = :param\"", ")", ";", "query", ".", "setParameter", "(", "\"param\"", ",", "value", ")", ";", "return", "query", ".", "getResultList", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "finally", "{", "if", "(", "entityManager", "!=", "null", ")", "entityManagers", ".", "add", "(", "entityManager", ")", ";", "}", "return", "null", ";", "}" ]
Execute query with criteria of key = key. This will auto generate a sql statement. @param clazz Entity to query @param key Attribute to predicate upon @param value Attribute key to predicate upon @return List of entities that match the criteria
[ "Execute", "query", "with", "criteria", "of", "key", "=", "key", ".", "This", "will", "auto", "generate", "a", "sql", "statement", "." ]
474dfc273a094dbc2ca08fcc08a2858cd538c920
https://github.com/OnyxDevTools/onyx-database-parent/blob/474dfc273a094dbc2ca08fcc08a2858cd538c920/onyx-database-examples/performance-benchmarks/src/main/java/com/onyxdevtools/provider/manager/JPAPersistenceManager.java#L152-L171
144,325
OnyxDevTools/onyx-database-parent
onyx-database-examples/relationships/src/main/java/com/onyxdevtools/relationship/AbstractDemo.java
AbstractDemo.assertNotNull
static void assertNotNull(String message, Object nonNullObject) { if(nonNullObject == null) { System.err.println(message); } }
java
static void assertNotNull(String message, Object nonNullObject) { if(nonNullObject == null) { System.err.println(message); } }
[ "static", "void", "assertNotNull", "(", "String", "message", ",", "Object", "nonNullObject", ")", "{", "if", "(", "nonNullObject", "==", "null", ")", "{", "System", ".", "err", ".", "println", "(", "message", ")", ";", "}", "}" ]
Helper method to verify an the object is not null. @param message Message displayed if the object is null @param nonNullObject Object to assert
[ "Helper", "method", "to", "verify", "an", "the", "object", "is", "not", "null", "." ]
474dfc273a094dbc2ca08fcc08a2858cd538c920
https://github.com/OnyxDevTools/onyx-database-parent/blob/474dfc273a094dbc2ca08fcc08a2858cd538c920/onyx-database-examples/relationships/src/main/java/com/onyxdevtools/relationship/AbstractDemo.java#L12-L18
144,326
OnyxDevTools/onyx-database-parent
onyx-database-examples/relationships/src/main/java/com/onyxdevtools/relationship/AbstractDemo.java
AbstractDemo.assertEquals
static void assertEquals(String message, Object comparison1, Object comparison2) { if(comparison1 == comparison2) { return; } if(comparison1.equals(comparison2)) { return; } System.err.println(message); }
java
static void assertEquals(String message, Object comparison1, Object comparison2) { if(comparison1 == comparison2) { return; } if(comparison1.equals(comparison2)) { return; } System.err.println(message); }
[ "static", "void", "assertEquals", "(", "String", "message", ",", "Object", "comparison1", ",", "Object", "comparison2", ")", "{", "if", "(", "comparison1", "==", "comparison2", ")", "{", "return", ";", "}", "if", "(", "comparison1", ".", "equals", "(", "comparison2", ")", ")", "{", "return", ";", "}", "System", ".", "err", ".", "println", "(", "message", ")", ";", "}" ]
Helper method to verify 2 objects have the same key @param message Message to display if the assert fails @param comparison1 First object to compare @param comparison2 Second object to compare against
[ "Helper", "method", "to", "verify", "2", "objects", "have", "the", "same", "key" ]
474dfc273a094dbc2ca08fcc08a2858cd538c920
https://github.com/OnyxDevTools/onyx-database-parent/blob/474dfc273a094dbc2ca08fcc08a2858cd538c920/onyx-database-examples/relationships/src/main/java/com/onyxdevtools/relationship/AbstractDemo.java#L27-L39
144,327
OnyxDevTools/onyx-database-parent
onyx-database-examples/performance-benchmarks/src/main/java/BenchmarkRunner.java
BenchmarkRunner.deleteDirectory
@SuppressWarnings("ResultOfMethodCallIgnored") static private void deleteDirectory(File path) { if (path.exists()) { //noinspection ConstantConditions for (File f : path.listFiles()) { if (f.isDirectory()) { deleteDirectory(f); } f.delete(); } path.delete(); } }
java
@SuppressWarnings("ResultOfMethodCallIgnored") static private void deleteDirectory(File path) { if (path.exists()) { //noinspection ConstantConditions for (File f : path.listFiles()) { if (f.isDirectory()) { deleteDirectory(f); } f.delete(); } path.delete(); } }
[ "@", "SuppressWarnings", "(", "\"ResultOfMethodCallIgnored\"", ")", "static", "private", "void", "deleteDirectory", "(", "File", "path", ")", "{", "if", "(", "path", ".", "exists", "(", ")", ")", "{", "//noinspection ConstantConditions", "for", "(", "File", "f", ":", "path", ".", "listFiles", "(", ")", ")", "{", "if", "(", "f", ".", "isDirectory", "(", ")", ")", "{", "deleteDirectory", "(", "f", ")", ";", "}", "f", ".", "delete", "(", ")", ";", "}", "path", ".", "delete", "(", ")", ";", "}", "}" ]
Helper method for deleting the database directory @param path Directory path of database
[ "Helper", "method", "for", "deleting", "the", "database", "directory" ]
474dfc273a094dbc2ca08fcc08a2858cd538c920
https://github.com/OnyxDevTools/onyx-database-parent/blob/474dfc273a094dbc2ca08fcc08a2858cd538c920/onyx-database-examples/performance-benchmarks/src/main/java/BenchmarkRunner.java#L77-L89
144,328
OnyxDevTools/onyx-database-parent
onyx-database-examples/webservice-client/java-client/src/main/java/io/swagger/client/api/PersistenceApi.java
PersistenceApi.countPost
public Integer countPost(Query query) throws ApiException { ApiResponse<Integer> resp = countPostWithHttpInfo(query); return resp.getData(); }
java
public Integer countPost(Query query) throws ApiException { ApiResponse<Integer> resp = countPostWithHttpInfo(query); return resp.getData(); }
[ "public", "Integer", "countPost", "(", "Query", "query", ")", "throws", "ApiException", "{", "ApiResponse", "<", "Integer", ">", "resp", "=", "countPostWithHttpInfo", "(", "query", ")", ";", "return", "resp", ".", "getData", "(", ")", ";", "}" ]
Get count for query Get the number of items matching query criteria @param query Query defined with criteria (required) @return Integer @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
[ "Get", "count", "for", "query", "Get", "the", "number", "of", "items", "matching", "query", "criteria" ]
474dfc273a094dbc2ca08fcc08a2858cd538c920
https://github.com/OnyxDevTools/onyx-database-parent/blob/474dfc273a094dbc2ca08fcc08a2858cd538c920/onyx-database-examples/webservice-client/java-client/src/main/java/io/swagger/client/api/PersistenceApi.java#L140-L143
144,329
OnyxDevTools/onyx-database-parent
onyx-database-examples/webservice-client/java-client/src/main/java/io/swagger/client/api/PersistenceApi.java
PersistenceApi.deleteEntitiesPostWithHttpInfo
public ApiResponse<Void> deleteEntitiesPostWithHttpInfo(DeleteEntitiesRequest request) throws ApiException { com.squareup.okhttp.Call call = deleteEntitiesPostValidateBeforeCall(request, null, null); return apiClient.execute(call); }
java
public ApiResponse<Void> deleteEntitiesPostWithHttpInfo(DeleteEntitiesRequest request) throws ApiException { com.squareup.okhttp.Call call = deleteEntitiesPostValidateBeforeCall(request, null, null); return apiClient.execute(call); }
[ "public", "ApiResponse", "<", "Void", ">", "deleteEntitiesPostWithHttpInfo", "(", "DeleteEntitiesRequest", "request", ")", "throws", "ApiException", "{", "com", ".", "squareup", ".", "okhttp", ".", "Call", "call", "=", "deleteEntitiesPostValidateBeforeCall", "(", "request", ",", "null", ",", "null", ")", ";", "return", "apiClient", ".", "execute", "(", "call", ")", ";", "}" ]
Bulk Delete Managed Entities This is used to batch delete entities in order to provide optimized throughput. @param request Save Entities Request (required) @return ApiResponse&lt;Void&gt; @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
[ "Bulk", "Delete", "Managed", "Entities", "This", "is", "used", "to", "batch", "delete", "entities", "in", "order", "to", "provide", "optimized", "throughput", "." ]
474dfc273a094dbc2ca08fcc08a2858cd538c920
https://github.com/OnyxDevTools/onyx-database-parent/blob/474dfc273a094dbc2ca08fcc08a2858cd538c920/onyx-database-examples/webservice-client/java-client/src/main/java/io/swagger/client/api/PersistenceApi.java#L275-L278
144,330
OnyxDevTools/onyx-database-parent
onyx-database-examples/webservice-client/java-client/src/main/java/io/swagger/client/api/PersistenceApi.java
PersistenceApi.executeUpdatePost
public Integer executeUpdatePost(Query query) throws ApiException { ApiResponse<Integer> resp = executeUpdatePostWithHttpInfo(query); return resp.getData(); }
java
public Integer executeUpdatePost(Query query) throws ApiException { ApiResponse<Integer> resp = executeUpdatePostWithHttpInfo(query); return resp.getData(); }
[ "public", "Integer", "executeUpdatePost", "(", "Query", "query", ")", "throws", "ApiException", "{", "ApiResponse", "<", "Integer", ">", "resp", "=", "executeUpdatePostWithHttpInfo", "(", "query", ")", ";", "return", "resp", ".", "getData", "(", ")", ";", "}" ]
Execute Update Query Execute update query with defined criteria and update instructions @param query Query defined with criteria and update instructions (required) @return Integer @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
[ "Execute", "Update", "Query", "Execute", "update", "query", "with", "defined", "criteria", "and", "update", "instructions" ]
474dfc273a094dbc2ca08fcc08a2858cd538c920
https://github.com/OnyxDevTools/onyx-database-parent/blob/474dfc273a094dbc2ca08fcc08a2858cd538c920/onyx-database-examples/webservice-client/java-client/src/main/java/io/swagger/client/api/PersistenceApi.java#L761-L764
144,331
OnyxDevTools/onyx-database-parent
onyx-database-examples/webservice-client/java-client/src/main/java/io/swagger/client/api/PersistenceApi.java
PersistenceApi.saveEntitiesPostWithHttpInfo
public ApiResponse<Void> saveEntitiesPostWithHttpInfo(SaveEntitiesRequest request) throws ApiException { com.squareup.okhttp.Call call = saveEntitiesPostValidateBeforeCall(request, null, null); return apiClient.execute(call); }
java
public ApiResponse<Void> saveEntitiesPostWithHttpInfo(SaveEntitiesRequest request) throws ApiException { com.squareup.okhttp.Call call = saveEntitiesPostValidateBeforeCall(request, null, null); return apiClient.execute(call); }
[ "public", "ApiResponse", "<", "Void", ">", "saveEntitiesPostWithHttpInfo", "(", "SaveEntitiesRequest", "request", ")", "throws", "ApiException", "{", "com", ".", "squareup", ".", "okhttp", ".", "Call", "call", "=", "saveEntitiesPostValidateBeforeCall", "(", "request", ",", "null", ",", "null", ")", ";", "return", "apiClient", ".", "execute", "(", "call", ")", ";", "}" ]
Bulk Save Managed Entities This is used to batch save entities in order to provide optimized throughput. @param request Save Entities Request (required) @return ApiResponse&lt;Void&gt; @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
[ "Bulk", "Save", "Managed", "Entities", "This", "is", "used", "to", "batch", "save", "entities", "in", "order", "to", "provide", "optimized", "throughput", "." ]
474dfc273a094dbc2ca08fcc08a2858cd538c920
https://github.com/OnyxDevTools/onyx-database-parent/blob/474dfc273a094dbc2ca08fcc08a2858cd538c920/onyx-database-examples/webservice-client/java-client/src/main/java/io/swagger/client/api/PersistenceApi.java#L1271-L1274
144,332
OnyxDevTools/onyx-database-parent
onyx-database-examples/model-updates/model-before-update/src/main/java/com/onyxdevtools/modelUpdate/before/Main.java
Main.seedData
private static void seedData(PersistenceManager manager) throws OnyxException { Account account = new Account(); //noinspection SpellCheckingInspection account.setAccountName("Timbob's Lawn Care"); account.setBalanceDue(55.43f); Invoice marchLawnInvoice = new Invoice(); marchLawnInvoice.setDueDate(parseDate("04-01-2016")); marchLawnInvoice.setInvoiceDate(parseDate("03-01-2016")); marchLawnInvoice.setNotes("Why did we need to mow your lawn. Its basically a dirt field."); marchLawnInvoice.setInvoiceId(1L); marchLawnInvoice.setAmount(44.32); marchLawnInvoice.setAccount(account); Invoice aprilLawnInvoice = new Invoice(); aprilLawnInvoice.setDueDate(parseDate("04-01-2016")); aprilLawnInvoice.setInvoiceDate(parseDate("03-01-2016")); aprilLawnInvoice.setNotes("Its April, your lawn should be growing by now."); aprilLawnInvoice.setInvoiceId(2L); aprilLawnInvoice.setAmount(44.32); aprilLawnInvoice.setAccount(account); manager.saveEntity(account); manager.saveEntity(marchLawnInvoice); manager.saveEntity(aprilLawnInvoice); Payment marchLawnCarePayment = new Payment(); marchLawnCarePayment.setPaymentId(1L); marchLawnCarePayment.setInvoice(marchLawnInvoice); marchLawnCarePayment.setAmount(44.32); manager.saveEntity(marchLawnCarePayment); Account account1 = manager.findById(Account.class, 1); assert account1 != null; assert account1.getAccountId() == 1L; }
java
private static void seedData(PersistenceManager manager) throws OnyxException { Account account = new Account(); //noinspection SpellCheckingInspection account.setAccountName("Timbob's Lawn Care"); account.setBalanceDue(55.43f); Invoice marchLawnInvoice = new Invoice(); marchLawnInvoice.setDueDate(parseDate("04-01-2016")); marchLawnInvoice.setInvoiceDate(parseDate("03-01-2016")); marchLawnInvoice.setNotes("Why did we need to mow your lawn. Its basically a dirt field."); marchLawnInvoice.setInvoiceId(1L); marchLawnInvoice.setAmount(44.32); marchLawnInvoice.setAccount(account); Invoice aprilLawnInvoice = new Invoice(); aprilLawnInvoice.setDueDate(parseDate("04-01-2016")); aprilLawnInvoice.setInvoiceDate(parseDate("03-01-2016")); aprilLawnInvoice.setNotes("Its April, your lawn should be growing by now."); aprilLawnInvoice.setInvoiceId(2L); aprilLawnInvoice.setAmount(44.32); aprilLawnInvoice.setAccount(account); manager.saveEntity(account); manager.saveEntity(marchLawnInvoice); manager.saveEntity(aprilLawnInvoice); Payment marchLawnCarePayment = new Payment(); marchLawnCarePayment.setPaymentId(1L); marchLawnCarePayment.setInvoice(marchLawnInvoice); marchLawnCarePayment.setAmount(44.32); manager.saveEntity(marchLawnCarePayment); Account account1 = manager.findById(Account.class, 1); assert account1 != null; assert account1.getAccountId() == 1L; }
[ "private", "static", "void", "seedData", "(", "PersistenceManager", "manager", ")", "throws", "OnyxException", "{", "Account", "account", "=", "new", "Account", "(", ")", ";", "//noinspection SpellCheckingInspection", "account", ".", "setAccountName", "(", "\"Timbob's Lawn Care\"", ")", ";", "account", ".", "setBalanceDue", "(", "55.43f", ")", ";", "Invoice", "marchLawnInvoice", "=", "new", "Invoice", "(", ")", ";", "marchLawnInvoice", ".", "setDueDate", "(", "parseDate", "(", "\"04-01-2016\"", ")", ")", ";", "marchLawnInvoice", ".", "setInvoiceDate", "(", "parseDate", "(", "\"03-01-2016\"", ")", ")", ";", "marchLawnInvoice", ".", "setNotes", "(", "\"Why did we need to mow your lawn. Its basically a dirt field.\"", ")", ";", "marchLawnInvoice", ".", "setInvoiceId", "(", "1L", ")", ";", "marchLawnInvoice", ".", "setAmount", "(", "44.32", ")", ";", "marchLawnInvoice", ".", "setAccount", "(", "account", ")", ";", "Invoice", "aprilLawnInvoice", "=", "new", "Invoice", "(", ")", ";", "aprilLawnInvoice", ".", "setDueDate", "(", "parseDate", "(", "\"04-01-2016\"", ")", ")", ";", "aprilLawnInvoice", ".", "setInvoiceDate", "(", "parseDate", "(", "\"03-01-2016\"", ")", ")", ";", "aprilLawnInvoice", ".", "setNotes", "(", "\"Its April, your lawn should be growing by now.\"", ")", ";", "aprilLawnInvoice", ".", "setInvoiceId", "(", "2L", ")", ";", "aprilLawnInvoice", ".", "setAmount", "(", "44.32", ")", ";", "aprilLawnInvoice", ".", "setAccount", "(", "account", ")", ";", "manager", ".", "saveEntity", "(", "account", ")", ";", "manager", ".", "saveEntity", "(", "marchLawnInvoice", ")", ";", "manager", ".", "saveEntity", "(", "aprilLawnInvoice", ")", ";", "Payment", "marchLawnCarePayment", "=", "new", "Payment", "(", ")", ";", "marchLawnCarePayment", ".", "setPaymentId", "(", "1L", ")", ";", "marchLawnCarePayment", ".", "setInvoice", "(", "marchLawnInvoice", ")", ";", "marchLawnCarePayment", ".", "setAmount", "(", "44.32", ")", ";", "manager", ".", "saveEntity", "(", "marchLawnCarePayment", ")", ";", "Account", "account1", "=", "manager", ".", "findById", "(", "Account", ".", "class", ",", "1", ")", ";", "assert", "account1", "!=", "null", ";", "assert", "account1", ".", "getAccountId", "(", ")", "==", "1L", ";", "}" ]
Fill the database with some test data, so that we can show how the data model updates impact the changes to the values. @param manager Persistence Manager used to save the entities @throws OnyxException Failure to persist entities
[ "Fill", "the", "database", "with", "some", "test", "data", "so", "that", "we", "can", "show", "how", "the", "data", "model", "updates", "impact", "the", "changes", "to", "the", "values", "." ]
474dfc273a094dbc2ca08fcc08a2858cd538c920
https://github.com/OnyxDevTools/onyx-database-parent/blob/474dfc273a094dbc2ca08fcc08a2858cd538c920/onyx-database-examples/model-updates/model-before-update/src/main/java/com/onyxdevtools/modelUpdate/before/Main.java#L69-L106
144,333
OnyxDevTools/onyx-database-parent
onyx-database-examples/model-updates/model-before-update/src/main/java/com/onyxdevtools/modelUpdate/before/Main.java
Main.deleteDatabase
private static void deleteDatabase(String pathToDb) { File database = new File(pathToDb); if (database.exists()) { delete(database); } database.delete(); }
java
private static void deleteDatabase(String pathToDb) { File database = new File(pathToDb); if (database.exists()) { delete(database); } database.delete(); }
[ "private", "static", "void", "deleteDatabase", "(", "String", "pathToDb", ")", "{", "File", "database", "=", "new", "File", "(", "pathToDb", ")", ";", "if", "(", "database", ".", "exists", "(", ")", ")", "{", "delete", "(", "database", ")", ";", "}", "database", ".", "delete", "(", ")", ";", "}" ]
Delete a database so you have a clean slate prior to testing @param pathToDb Path to onyx database
[ "Delete", "a", "database", "so", "you", "have", "a", "clean", "slate", "prior", "to", "testing" ]
474dfc273a094dbc2ca08fcc08a2858cd538c920
https://github.com/OnyxDevTools/onyx-database-parent/blob/474dfc273a094dbc2ca08fcc08a2858cd538c920/onyx-database-examples/model-updates/model-before-update/src/main/java/com/onyxdevtools/modelUpdate/before/Main.java#L129-L136
144,334
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/api/artifact/MavenArtifactHelper.java
MavenArtifactHelper.setCoordinates
public static void setCoordinates(MavenArtifactDescriptor artifactDescriptor, Coordinates coordinates) { artifactDescriptor.setGroup(coordinates.getGroup()); artifactDescriptor.setName(coordinates.getName()); artifactDescriptor.setVersion(coordinates.getVersion()); artifactDescriptor.setClassifier(coordinates.getClassifier()); artifactDescriptor.setType(coordinates.getType()); }
java
public static void setCoordinates(MavenArtifactDescriptor artifactDescriptor, Coordinates coordinates) { artifactDescriptor.setGroup(coordinates.getGroup()); artifactDescriptor.setName(coordinates.getName()); artifactDescriptor.setVersion(coordinates.getVersion()); artifactDescriptor.setClassifier(coordinates.getClassifier()); artifactDescriptor.setType(coordinates.getType()); }
[ "public", "static", "void", "setCoordinates", "(", "MavenArtifactDescriptor", "artifactDescriptor", ",", "Coordinates", "coordinates", ")", "{", "artifactDescriptor", ".", "setGroup", "(", "coordinates", ".", "getGroup", "(", ")", ")", ";", "artifactDescriptor", ".", "setName", "(", "coordinates", ".", "getName", "(", ")", ")", ";", "artifactDescriptor", ".", "setVersion", "(", "coordinates", ".", "getVersion", "(", ")", ")", ";", "artifactDescriptor", ".", "setClassifier", "(", "coordinates", ".", "getClassifier", "(", ")", ")", ";", "artifactDescriptor", ".", "setType", "(", "coordinates", ".", "getType", "(", ")", ")", ";", "}" ]
Apply the given coordinates to an artifact descriptor. @param artifactDescriptor The artifact descriptor. @param coordinates The coordinates.
[ "Apply", "the", "given", "coordinates", "to", "an", "artifact", "descriptor", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/api/artifact/MavenArtifactHelper.java#L29-L35
144,335
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/api/artifact/MavenArtifactHelper.java
MavenArtifactHelper.setId
public static void setId(MavenArtifactDescriptor artifactDescriptor, Coordinates coordinates) { artifactDescriptor.setFullQualifiedName(MavenArtifactHelper.getId(coordinates)); }
java
public static void setId(MavenArtifactDescriptor artifactDescriptor, Coordinates coordinates) { artifactDescriptor.setFullQualifiedName(MavenArtifactHelper.getId(coordinates)); }
[ "public", "static", "void", "setId", "(", "MavenArtifactDescriptor", "artifactDescriptor", ",", "Coordinates", "coordinates", ")", "{", "artifactDescriptor", ".", "setFullQualifiedName", "(", "MavenArtifactHelper", ".", "getId", "(", "coordinates", ")", ")", ";", "}" ]
Set the fully qualified name of an artifact descriptor. @param artifactDescriptor The artifact descriptor. @param coordinates The coordinates.
[ "Set", "the", "fully", "qualified", "name", "of", "an", "artifact", "descriptor", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/api/artifact/MavenArtifactHelper.java#L45-L47
144,336
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/api/artifact/MavenArtifactHelper.java
MavenArtifactHelper.getId
public static String getId(Coordinates coordinates) { StringBuilder id = new StringBuilder(); if (StringUtils.isNotEmpty(coordinates.getGroup())) { id.append(coordinates.getGroup()); } id.append(':'); id.append(coordinates.getName()); id.append(':'); id.append(coordinates.getType()); String classifier = coordinates.getClassifier(); if (StringUtils.isNotEmpty(classifier)) { id.append(':'); id.append(classifier); } String version = coordinates.getVersion(); if (StringUtils.isNotEmpty(version)) { id.append(':'); id.append(version); } return id.toString(); }
java
public static String getId(Coordinates coordinates) { StringBuilder id = new StringBuilder(); if (StringUtils.isNotEmpty(coordinates.getGroup())) { id.append(coordinates.getGroup()); } id.append(':'); id.append(coordinates.getName()); id.append(':'); id.append(coordinates.getType()); String classifier = coordinates.getClassifier(); if (StringUtils.isNotEmpty(classifier)) { id.append(':'); id.append(classifier); } String version = coordinates.getVersion(); if (StringUtils.isNotEmpty(version)) { id.append(':'); id.append(version); } return id.toString(); }
[ "public", "static", "String", "getId", "(", "Coordinates", "coordinates", ")", "{", "StringBuilder", "id", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "coordinates", ".", "getGroup", "(", ")", ")", ")", "{", "id", ".", "append", "(", "coordinates", ".", "getGroup", "(", ")", ")", ";", "}", "id", ".", "append", "(", "'", "'", ")", ";", "id", ".", "append", "(", "coordinates", ".", "getName", "(", ")", ")", ";", "id", ".", "append", "(", "'", "'", ")", ";", "id", ".", "append", "(", "coordinates", ".", "getType", "(", ")", ")", ";", "String", "classifier", "=", "coordinates", ".", "getClassifier", "(", ")", ";", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "classifier", ")", ")", "{", "id", ".", "append", "(", "'", "'", ")", ";", "id", ".", "append", "(", "classifier", ")", ";", "}", "String", "version", "=", "coordinates", ".", "getVersion", "(", ")", ";", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "version", ")", ")", "{", "id", ".", "append", "(", "'", "'", ")", ";", "id", ".", "append", "(", "version", ")", ";", "}", "return", "id", ".", "toString", "(", ")", ";", "}" ]
Creates the id of an coordinates descriptor by the given items. @param coordinates The maven coordinates. @return The id.
[ "Creates", "the", "id", "of", "an", "coordinates", "descriptor", "by", "the", "given", "items", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/api/artifact/MavenArtifactHelper.java#L56-L76
144,337
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/utils/AuthUtils.java
AuthUtils.purgeOAuthAccessTokens
public static void purgeOAuthAccessTokens(RequestContext requestContext, String provider) { String key = String.format(PROVIDER_ACCESS_TOKENS, provider); HttpSession session = requestContext.getRequest().getSession(); OAuthAccessToken[] accessTokens = (OAuthAccessToken[]) session.getAttribute(key); if (accessTokens != null) { session.removeAttribute(key); } }
java
public static void purgeOAuthAccessTokens(RequestContext requestContext, String provider) { String key = String.format(PROVIDER_ACCESS_TOKENS, provider); HttpSession session = requestContext.getRequest().getSession(); OAuthAccessToken[] accessTokens = (OAuthAccessToken[]) session.getAttribute(key); if (accessTokens != null) { session.removeAttribute(key); } }
[ "public", "static", "void", "purgeOAuthAccessTokens", "(", "RequestContext", "requestContext", ",", "String", "provider", ")", "{", "String", "key", "=", "String", ".", "format", "(", "PROVIDER_ACCESS_TOKENS", ",", "provider", ")", ";", "HttpSession", "session", "=", "requestContext", ".", "getRequest", "(", ")", ".", "getSession", "(", ")", ";", "OAuthAccessToken", "[", "]", "accessTokens", "=", "(", "OAuthAccessToken", "[", "]", ")", "session", ".", "getAttribute", "(", "key", ")", ";", "if", "(", "accessTokens", "!=", "null", ")", "{", "session", ".", "removeAttribute", "(", "key", ")", ";", "}", "}" ]
Purges all OAuth tokens from given provider @param requestContext request context @param provider provider
[ "Purges", "all", "OAuth", "tokens", "from", "given", "provider" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/utils/AuthUtils.java#L138-L145
144,338
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/utils/AuthUtils.java
AuthUtils.getOAuthAccessToken
public static OAuthAccessToken getOAuthAccessToken(RequestContext requestContext, String provider, String... scopes) { HttpSession session = requestContext.getRequest().getSession(); OAuthAccessToken[] accessTokens = (OAuthAccessToken[]) session.getAttribute(String.format(PROVIDER_ACCESS_TOKENS, provider)); if (accessTokens != null) { for (OAuthAccessToken accessToken : accessTokens) { List<String> accessTokenScopes = accessToken.getScopes() != null ? Arrays.asList(accessToken.getScopes()) : Collections.emptyList(); if (scopes == null || accessTokenScopes.containsAll(Arrays.asList(scopes))) { if (isOAuthTokenExpired(accessToken)) { if ("Keycloak".equals(provider)) { return getKeycloakStrategy().refreshToken(requestContext, accessToken); } } else { return accessToken; } } } } return null; }
java
public static OAuthAccessToken getOAuthAccessToken(RequestContext requestContext, String provider, String... scopes) { HttpSession session = requestContext.getRequest().getSession(); OAuthAccessToken[] accessTokens = (OAuthAccessToken[]) session.getAttribute(String.format(PROVIDER_ACCESS_TOKENS, provider)); if (accessTokens != null) { for (OAuthAccessToken accessToken : accessTokens) { List<String> accessTokenScopes = accessToken.getScopes() != null ? Arrays.asList(accessToken.getScopes()) : Collections.emptyList(); if (scopes == null || accessTokenScopes.containsAll(Arrays.asList(scopes))) { if (isOAuthTokenExpired(accessToken)) { if ("Keycloak".equals(provider)) { return getKeycloakStrategy().refreshToken(requestContext, accessToken); } } else { return accessToken; } } } } return null; }
[ "public", "static", "OAuthAccessToken", "getOAuthAccessToken", "(", "RequestContext", "requestContext", ",", "String", "provider", ",", "String", "...", "scopes", ")", "{", "HttpSession", "session", "=", "requestContext", ".", "getRequest", "(", ")", ".", "getSession", "(", ")", ";", "OAuthAccessToken", "[", "]", "accessTokens", "=", "(", "OAuthAccessToken", "[", "]", ")", "session", ".", "getAttribute", "(", "String", ".", "format", "(", "PROVIDER_ACCESS_TOKENS", ",", "provider", ")", ")", ";", "if", "(", "accessTokens", "!=", "null", ")", "{", "for", "(", "OAuthAccessToken", "accessToken", ":", "accessTokens", ")", "{", "List", "<", "String", ">", "accessTokenScopes", "=", "accessToken", ".", "getScopes", "(", ")", "!=", "null", "?", "Arrays", ".", "asList", "(", "accessToken", ".", "getScopes", "(", ")", ")", ":", "Collections", ".", "emptyList", "(", ")", ";", "if", "(", "scopes", "==", "null", "||", "accessTokenScopes", ".", "containsAll", "(", "Arrays", ".", "asList", "(", "scopes", ")", ")", ")", "{", "if", "(", "isOAuthTokenExpired", "(", "accessToken", ")", ")", "{", "if", "(", "\"Keycloak\"", ".", "equals", "(", "provider", ")", ")", "{", "return", "getKeycloakStrategy", "(", ")", ".", "refreshToken", "(", "requestContext", ",", "accessToken", ")", ";", "}", "}", "else", "{", "return", "accessToken", ";", "}", "}", "}", "}", "return", "null", ";", "}" ]
Returns OAuth previously stored access token from HTTP session Null is returned if token is present but does not have requested scopes or the token has been expired @param requestContext request context @param provider token provider @param scopes required scopes @return OAuth previously stored access token from HTTP session
[ "Returns", "OAuth", "previously", "stored", "access", "token", "from", "HTTP", "session" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/utils/AuthUtils.java#L173-L193
144,339
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/auth/KeycloakAuthenticationStrategy.java
KeycloakAuthenticationStrategy.getRefreshToken
private String getRefreshToken(Token accessToken) { JSONObject rawJson = JSONObject.fromObject(accessToken.getRawResponse()); return rawJson.getString("refresh_token"); }
java
private String getRefreshToken(Token accessToken) { JSONObject rawJson = JSONObject.fromObject(accessToken.getRawResponse()); return rawJson.getString("refresh_token"); }
[ "private", "String", "getRefreshToken", "(", "Token", "accessToken", ")", "{", "JSONObject", "rawJson", "=", "JSONObject", ".", "fromObject", "(", "accessToken", ".", "getRawResponse", "(", ")", ")", ";", "return", "rawJson", ".", "getString", "(", "\"refresh_token\"", ")", ";", "}" ]
Parses refresh token from the access token @param accessToken access token @return refresh token
[ "Parses", "refresh", "token", "from", "the", "access", "token" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/auth/KeycloakAuthenticationStrategy.java#L310-L313
144,340
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/auth/OAuthAuthenticationStrategy.java
OAuthAuthenticationStrategy.extractLastName
protected String extractLastName(String name) { if (StringUtils.isBlank(name)) { return null; } int lastIndexOf = name.lastIndexOf(' '); if (lastIndexOf == -1) return null; else return name.substring(lastIndexOf + 1); }
java
protected String extractLastName(String name) { if (StringUtils.isBlank(name)) { return null; } int lastIndexOf = name.lastIndexOf(' '); if (lastIndexOf == -1) return null; else return name.substring(lastIndexOf + 1); }
[ "protected", "String", "extractLastName", "(", "String", "name", ")", "{", "if", "(", "StringUtils", ".", "isBlank", "(", "name", ")", ")", "{", "return", "null", ";", "}", "int", "lastIndexOf", "=", "name", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "lastIndexOf", "==", "-", "1", ")", "return", "null", ";", "else", "return", "name", ".", "substring", "(", "lastIndexOf", "+", "1", ")", ";", "}" ]
Extracts a last name of full name string @param name full name @return last name if it could be extracted
[ "Extracts", "a", "last", "name", "of", "full", "name", "string" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/auth/OAuthAuthenticationStrategy.java#L124-L135
144,341
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/auth/OAuthAuthenticationStrategy.java
OAuthAuthenticationStrategy.extractFirstName
protected String extractFirstName(String name) { if (StringUtils.isBlank(name)) { return null; } int lastIndexOf = name.lastIndexOf(' '); if (lastIndexOf == -1) return null; else return name.substring(0, lastIndexOf); }
java
protected String extractFirstName(String name) { if (StringUtils.isBlank(name)) { return null; } int lastIndexOf = name.lastIndexOf(' '); if (lastIndexOf == -1) return null; else return name.substring(0, lastIndexOf); }
[ "protected", "String", "extractFirstName", "(", "String", "name", ")", "{", "if", "(", "StringUtils", ".", "isBlank", "(", "name", ")", ")", "{", "return", "null", ";", "}", "int", "lastIndexOf", "=", "name", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "lastIndexOf", "==", "-", "1", ")", "return", "null", ";", "else", "return", "name", ".", "substring", "(", "0", ",", "lastIndexOf", ")", ";", "}" ]
Extracts a first name of full name string @param name full name @return first name if it could be extracted
[ "Extracts", "a", "first", "name", "of", "full", "name", "string" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/auth/OAuthAuthenticationStrategy.java#L143-L154
144,342
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/rest/AbstractApi.java
AbstractApi.createNotFound
protected Response createNotFound(String message) { ErrorResponse entity = new ErrorResponse(); entity.setMessage(message); return Response .status(Response.Status.NOT_FOUND) .entity(entity) .build(); }
java
protected Response createNotFound(String message) { ErrorResponse entity = new ErrorResponse(); entity.setMessage(message); return Response .status(Response.Status.NOT_FOUND) .entity(entity) .build(); }
[ "protected", "Response", "createNotFound", "(", "String", "message", ")", "{", "ErrorResponse", "entity", "=", "new", "ErrorResponse", "(", ")", ";", "entity", ".", "setMessage", "(", "message", ")", ";", "return", "Response", ".", "status", "(", "Response", ".", "Status", ".", "NOT_FOUND", ")", ".", "entity", "(", "entity", ")", ".", "build", "(", ")", ";", "}" ]
Constructs not found response @param message message @return response
[ "Constructs", "not", "found", "response" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/rest/AbstractApi.java#L72-L79
144,343
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/rest/AbstractApi.java
AbstractApi.createForbidden
protected Response createForbidden(String message) { ErrorResponse entity = new ErrorResponse(); entity.setMessage(message); return Response .status(Response.Status.FORBIDDEN) .entity(entity) .build(); }
java
protected Response createForbidden(String message) { ErrorResponse entity = new ErrorResponse(); entity.setMessage(message); return Response .status(Response.Status.FORBIDDEN) .entity(entity) .build(); }
[ "protected", "Response", "createForbidden", "(", "String", "message", ")", "{", "ErrorResponse", "entity", "=", "new", "ErrorResponse", "(", ")", ";", "entity", ".", "setMessage", "(", "message", ")", ";", "return", "Response", ".", "status", "(", "Response", ".", "Status", ".", "FORBIDDEN", ")", ".", "entity", "(", "entity", ")", ".", "build", "(", ")", ";", "}" ]
Constructs forbidden response @param message message @return response
[ "Constructs", "forbidden", "response" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/rest/AbstractApi.java#L87-L94
144,344
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/rest/AbstractApi.java
AbstractApi.createBadRequest
protected Response createBadRequest(String message) { ErrorResponse entity = new ErrorResponse(); entity.setMessage(message); return Response .status(Response.Status.BAD_REQUEST) .entity(entity) .build(); }
java
protected Response createBadRequest(String message) { ErrorResponse entity = new ErrorResponse(); entity.setMessage(message); return Response .status(Response.Status.BAD_REQUEST) .entity(entity) .build(); }
[ "protected", "Response", "createBadRequest", "(", "String", "message", ")", "{", "ErrorResponse", "entity", "=", "new", "ErrorResponse", "(", ")", ";", "entity", ".", "setMessage", "(", "message", ")", ";", "return", "Response", ".", "status", "(", "Response", ".", "Status", ".", "BAD_REQUEST", ")", ".", "entity", "(", "entity", ")", ".", "build", "(", ")", ";", "}" ]
Constructs bad request response @param message message @return response
[ "Constructs", "bad", "request", "response" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/rest/AbstractApi.java#L102-L109
144,345
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/rest/AbstractApi.java
AbstractApi.createInternalServerError
protected Response createInternalServerError(String message) { ErrorResponse entity = new ErrorResponse(); entity.setMessage(message); return Response .status(Response.Status.INTERNAL_SERVER_ERROR) .entity(entity) .build(); }
java
protected Response createInternalServerError(String message) { ErrorResponse entity = new ErrorResponse(); entity.setMessage(message); return Response .status(Response.Status.INTERNAL_SERVER_ERROR) .entity(entity) .build(); }
[ "protected", "Response", "createInternalServerError", "(", "String", "message", ")", "{", "ErrorResponse", "entity", "=", "new", "ErrorResponse", "(", ")", ";", "entity", ".", "setMessage", "(", "message", ")", ";", "return", "Response", ".", "status", "(", "Response", ".", "Status", ".", "INTERNAL_SERVER_ERROR", ")", ".", "entity", "(", "entity", ")", ".", "build", "(", ")", ";", "}" ]
Constructs internal server error response @param message message @return response
[ "Constructs", "internal", "server", "error", "response" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/rest/AbstractApi.java#L117-L124
144,346
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/rest/AbstractApi.java
AbstractApi.streamResponse
protected Response streamResponse(byte[] data, String type) { try (InputStream byteStream = new ByteArrayInputStream(data)) { return streamResponse(type, byteStream, data.length); } catch (IOException e) { logger.error("Failed to stream data to client", e); return createInternalServerError("Failed to stream data to client"); } }
java
protected Response streamResponse(byte[] data, String type) { try (InputStream byteStream = new ByteArrayInputStream(data)) { return streamResponse(type, byteStream, data.length); } catch (IOException e) { logger.error("Failed to stream data to client", e); return createInternalServerError("Failed to stream data to client"); } }
[ "protected", "Response", "streamResponse", "(", "byte", "[", "]", "data", ",", "String", "type", ")", "{", "try", "(", "InputStream", "byteStream", "=", "new", "ByteArrayInputStream", "(", "data", ")", ")", "{", "return", "streamResponse", "(", "type", ",", "byteStream", ",", "data", ".", "length", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "logger", ".", "error", "(", "\"Failed to stream data to client\"", ",", "e", ")", ";", "return", "createInternalServerError", "(", "\"Failed to stream data to client\"", ")", ";", "}", "}" ]
Creates streamed response from byte array @param data data @param type content type @return Response
[ "Creates", "streamed", "response", "from", "byte", "array" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/rest/AbstractApi.java#L160-L167
144,347
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/rest/AbstractApi.java
AbstractApi.streamResponse
protected Response streamResponse(String type, InputStream inputStream, int contentLength) { return Response.ok(new StreamingOutputImpl(inputStream), type) .header("Content-Length", contentLength) .build(); }
java
protected Response streamResponse(String type, InputStream inputStream, int contentLength) { return Response.ok(new StreamingOutputImpl(inputStream), type) .header("Content-Length", contentLength) .build(); }
[ "protected", "Response", "streamResponse", "(", "String", "type", ",", "InputStream", "inputStream", ",", "int", "contentLength", ")", "{", "return", "Response", ".", "ok", "(", "new", "StreamingOutputImpl", "(", "inputStream", ")", ",", "type", ")", ".", "header", "(", "\"Content-Length\"", ",", "contentLength", ")", ".", "build", "(", ")", ";", "}" ]
Creates streamed response from input stream @param inputStream data @param type content type @param contentLength content length @return Response
[ "Creates", "streamed", "response", "from", "input", "stream" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/rest/AbstractApi.java#L177-L181
144,348
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/rest/AbstractApi.java
AbstractApi.getLoggedUserId
protected UUID getLoggedUserId() { HttpServletRequest httpServletRequest = getHttpServletRequest(); String remoteUser = httpServletRequest.getRemoteUser(); if (remoteUser == null) { return null; } return UUID.fromString(remoteUser); }
java
protected UUID getLoggedUserId() { HttpServletRequest httpServletRequest = getHttpServletRequest(); String remoteUser = httpServletRequest.getRemoteUser(); if (remoteUser == null) { return null; } return UUID.fromString(remoteUser); }
[ "protected", "UUID", "getLoggedUserId", "(", ")", "{", "HttpServletRequest", "httpServletRequest", "=", "getHttpServletRequest", "(", ")", ";", "String", "remoteUser", "=", "httpServletRequest", ".", "getRemoteUser", "(", ")", ";", "if", "(", "remoteUser", "==", "null", ")", "{", "return", "null", ";", "}", "return", "UUID", ".", "fromString", "(", "remoteUser", ")", ";", "}" ]
Returns logged user id @return logged user id
[ "Returns", "logged", "user", "id" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/rest/AbstractApi.java#L188-L196
144,349
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/rest/AbstractApi.java
AbstractApi.getLoggedUser
protected User getLoggedUser() { UUID userId = getLoggedUserId(); if (userId == null) { return null; } return userController.findUserByKeycloakId(userId); }
java
protected User getLoggedUser() { UUID userId = getLoggedUserId(); if (userId == null) { return null; } return userController.findUserByKeycloakId(userId); }
[ "protected", "User", "getLoggedUser", "(", ")", "{", "UUID", "userId", "=", "getLoggedUserId", "(", ")", ";", "if", "(", "userId", "==", "null", ")", "{", "return", "null", ";", "}", "return", "userController", ".", "findUserByKeycloakId", "(", "userId", ")", ";", "}" ]
Returns logged user @return logged user or null if user is not logged in
[ "Returns", "logged", "user" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/rest/AbstractApi.java#L203-L210
144,350
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/utils/comments/TimelineReportPageCommentProcessor.java
TimelineReportPageCommentProcessor.getAnswerValue
private String getAnswerValue(QueryQuestionNumericAnswer answer) { return answer != null && answer.getData() != null ? String.valueOf(Math.round(answer.getData())) : null; }
java
private String getAnswerValue(QueryQuestionNumericAnswer answer) { return answer != null && answer.getData() != null ? String.valueOf(Math.round(answer.getData())) : null; }
[ "private", "String", "getAnswerValue", "(", "QueryQuestionNumericAnswer", "answer", ")", "{", "return", "answer", "!=", "null", "&&", "answer", ".", "getData", "(", ")", "!=", "null", "?", "String", ".", "valueOf", "(", "Math", ".", "round", "(", "answer", ".", "getData", "(", ")", ")", ")", ":", "null", ";", "}" ]
Returns answer value @param answer answer @return answer value
[ "Returns", "answer", "value" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/utils/comments/TimelineReportPageCommentProcessor.java#L79-L81
144,351
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/paytrail/PaytrailServiceFactory.java
PaytrailServiceFactory.createPaytrailService
public static PaytrailService createPaytrailService() { IOHandler ioHandler = new HttpClientIOHandler(); Marshaller marshaller = new JacksonMarshaller(); String merchantId = SystemUtils.getSettingValue("paytrail.merchantId"); String merchantSecret = SystemUtils.getSettingValue("paytrail.merchantSecret"); return new PaytrailService(ioHandler, marshaller, merchantId, merchantSecret); }
java
public static PaytrailService createPaytrailService() { IOHandler ioHandler = new HttpClientIOHandler(); Marshaller marshaller = new JacksonMarshaller(); String merchantId = SystemUtils.getSettingValue("paytrail.merchantId"); String merchantSecret = SystemUtils.getSettingValue("paytrail.merchantSecret"); return new PaytrailService(ioHandler, marshaller, merchantId, merchantSecret); }
[ "public", "static", "PaytrailService", "createPaytrailService", "(", ")", "{", "IOHandler", "ioHandler", "=", "new", "HttpClientIOHandler", "(", ")", ";", "Marshaller", "marshaller", "=", "new", "JacksonMarshaller", "(", ")", ";", "String", "merchantId", "=", "SystemUtils", ".", "getSettingValue", "(", "\"paytrail.merchantId\"", ")", ";", "String", "merchantSecret", "=", "SystemUtils", ".", "getSettingValue", "(", "\"paytrail.merchantSecret\"", ")", ";", "return", "new", "PaytrailService", "(", "ioHandler", ",", "marshaller", ",", "merchantId", ",", "merchantSecret", ")", ";", "}" ]
Creates a paytrail service instance @return created paytrail service instance
[ "Creates", "a", "paytrail", "service", "instance" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/paytrail/PaytrailServiceFactory.java#L18-L24
144,352
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/pages/panel/admin/report/util/ChartModelProvider.java
ChartModelProvider.createBubbleChart
@SuppressWarnings ("squid:S00107") public static Chart createBubbleChart(String chartCaption, String xLabel, List<String> xTickLabels, String yLabel, List<String> yTickLabels, int xAxisLabelRotation, int yAxisLabelRotation, Double[][] values) { return createBubbleChart(chartCaption, xLabel, xTickLabels, yLabel, yTickLabels, xAxisLabelRotation, yAxisLabelRotation, values, null, null, null, null, null, null, null, null, null, null); }
java
@SuppressWarnings ("squid:S00107") public static Chart createBubbleChart(String chartCaption, String xLabel, List<String> xTickLabels, String yLabel, List<String> yTickLabels, int xAxisLabelRotation, int yAxisLabelRotation, Double[][] values) { return createBubbleChart(chartCaption, xLabel, xTickLabels, yLabel, yTickLabels, xAxisLabelRotation, yAxisLabelRotation, values, null, null, null, null, null, null, null, null, null, null); }
[ "@", "SuppressWarnings", "(", "\"squid:S00107\"", ")", "public", "static", "Chart", "createBubbleChart", "(", "String", "chartCaption", ",", "String", "xLabel", ",", "List", "<", "String", ">", "xTickLabels", ",", "String", "yLabel", ",", "List", "<", "String", ">", "yTickLabels", ",", "int", "xAxisLabelRotation", ",", "int", "yAxisLabelRotation", ",", "Double", "[", "]", "[", "]", "values", ")", "{", "return", "createBubbleChart", "(", "chartCaption", ",", "xLabel", ",", "xTickLabels", ",", "yLabel", ",", "yTickLabels", ",", "xAxisLabelRotation", ",", "yAxisLabelRotation", ",", "values", ",", "null", ",", "null", ",", "null", ",", "null", ",", "null", ",", "null", ",", "null", ",", "null", ",", "null", ",", "null", ")", ";", "}" ]
Creates a bubble chart without averages and quartiles @param chartCaption chart caption @param xLabel x axis label @param xTickLabels x axis tick labels @param yLabel y axis label @param yTickLabels y axis tick labels @param xAxisLabelRotation x axis label rotation @param yAxisLabelRotation y axis label rotation @param values values @return created chart
[ "Creates", "a", "bubble", "chart", "without", "averages", "and", "quartiles" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/pages/panel/admin/report/util/ChartModelProvider.java#L598-L601
144,353
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/pages/panel/admin/report/util/ChartModelProvider.java
ChartModelProvider.addMarkerLine
private static void addMarkerLine(String label, Double value, Double offset, Axis axis) { if (value != null) { MarkerLine markerLine = MarkerLineImpl.create(axis, NumberDataElementImpl.create(value + (offset != null ? offset : 0d))); markerLine.getLineAttributes().setStyle(LineStyle.DASHED_LITERAL); markerLine.getLabel().getCaption().setValue(label); markerLine.setLabelAnchor(Anchor.NORTH_EAST_LITERAL); } }
java
private static void addMarkerLine(String label, Double value, Double offset, Axis axis) { if (value != null) { MarkerLine markerLine = MarkerLineImpl.create(axis, NumberDataElementImpl.create(value + (offset != null ? offset : 0d))); markerLine.getLineAttributes().setStyle(LineStyle.DASHED_LITERAL); markerLine.getLabel().getCaption().setValue(label); markerLine.setLabelAnchor(Anchor.NORTH_EAST_LITERAL); } }
[ "private", "static", "void", "addMarkerLine", "(", "String", "label", ",", "Double", "value", ",", "Double", "offset", ",", "Axis", "axis", ")", "{", "if", "(", "value", "!=", "null", ")", "{", "MarkerLine", "markerLine", "=", "MarkerLineImpl", ".", "create", "(", "axis", ",", "NumberDataElementImpl", ".", "create", "(", "value", "+", "(", "offset", "!=", "null", "?", "offset", ":", "0d", ")", ")", ")", ";", "markerLine", ".", "getLineAttributes", "(", ")", ".", "setStyle", "(", "LineStyle", ".", "DASHED_LITERAL", ")", ";", "markerLine", ".", "getLabel", "(", ")", ".", "getCaption", "(", ")", ".", "setValue", "(", "label", ")", ";", "markerLine", ".", "setLabelAnchor", "(", "Anchor", ".", "NORTH_EAST_LITERAL", ")", ";", "}", "}" ]
Creates a marker line into specified axis if value is not null. @param label line label @param value value @param offset value offset @param axis axis
[ "Creates", "a", "marker", "line", "into", "specified", "axis", "if", "value", "is", "not", "null", "." ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/pages/panel/admin/report/util/ChartModelProvider.java#L763-L770
144,354
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/pages/panel/admin/report/util/ChartModelProvider.java
ChartModelProvider.translateMarkerToRange
private static Double translateMarkerToRange(double size, Double min, Double max, Double value) { if (value != null && min != null && max != null) { return (size / (max - min)) * (value - min); } return value; }
java
private static Double translateMarkerToRange(double size, Double min, Double max, Double value) { if (value != null && min != null && max != null) { return (size / (max - min)) * (value - min); } return value; }
[ "private", "static", "Double", "translateMarkerToRange", "(", "double", "size", ",", "Double", "min", ",", "Double", "max", ",", "Double", "value", ")", "{", "if", "(", "value", "!=", "null", "&&", "min", "!=", "null", "&&", "max", "!=", "null", ")", "{", "return", "(", "size", "/", "(", "max", "-", "min", ")", ")", "*", "(", "value", "-", "min", ")", ";", "}", "return", "value", ";", "}" ]
Translates marker value to be correct in given range @param size size of the range @param min min value @param max max value @param value original value @return translated value
[ "Translates", "marker", "value", "to", "be", "correct", "in", "given", "range" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/pages/panel/admin/report/util/ChartModelProvider.java#L781-L787
144,355
Metatavu/edelphi
edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/querydata/QueryQuestionOptionAnswerDAO.java
QueryQuestionOptionAnswerDAO.findTextByQueryReplyAndQueryField
public String findTextByQueryReplyAndQueryField(QueryReply queryReply, QueryField queryField) { EntityManager entityManager = getEntityManager(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<String> criteria = criteriaBuilder.createQuery(String.class); Root<QueryQuestionOptionAnswer> root = criteria.from(QueryQuestionOptionAnswer.class); Join<QueryQuestionOptionAnswer, QueryOptionFieldOption> option = root.join(QueryQuestionOptionAnswer_.option); criteria.select(option.get(QueryOptionFieldOption_.text)); criteria.where( criteriaBuilder.and( criteriaBuilder.equal(root.get(QueryQuestionOptionAnswer_.queryField), queryField), criteriaBuilder.equal(root.get(QueryQuestionOptionAnswer_.queryReply), queryReply) ) ); return getSingleResult(entityManager.createQuery(criteria)); }
java
public String findTextByQueryReplyAndQueryField(QueryReply queryReply, QueryField queryField) { EntityManager entityManager = getEntityManager(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<String> criteria = criteriaBuilder.createQuery(String.class); Root<QueryQuestionOptionAnswer> root = criteria.from(QueryQuestionOptionAnswer.class); Join<QueryQuestionOptionAnswer, QueryOptionFieldOption> option = root.join(QueryQuestionOptionAnswer_.option); criteria.select(option.get(QueryOptionFieldOption_.text)); criteria.where( criteriaBuilder.and( criteriaBuilder.equal(root.get(QueryQuestionOptionAnswer_.queryField), queryField), criteriaBuilder.equal(root.get(QueryQuestionOptionAnswer_.queryReply), queryReply) ) ); return getSingleResult(entityManager.createQuery(criteria)); }
[ "public", "String", "findTextByQueryReplyAndQueryField", "(", "QueryReply", "queryReply", ",", "QueryField", "queryField", ")", "{", "EntityManager", "entityManager", "=", "getEntityManager", "(", ")", ";", "CriteriaBuilder", "criteriaBuilder", "=", "entityManager", ".", "getCriteriaBuilder", "(", ")", ";", "CriteriaQuery", "<", "String", ">", "criteria", "=", "criteriaBuilder", ".", "createQuery", "(", "String", ".", "class", ")", ";", "Root", "<", "QueryQuestionOptionAnswer", ">", "root", "=", "criteria", ".", "from", "(", "QueryQuestionOptionAnswer", ".", "class", ")", ";", "Join", "<", "QueryQuestionOptionAnswer", ",", "QueryOptionFieldOption", ">", "option", "=", "root", ".", "join", "(", "QueryQuestionOptionAnswer_", ".", "option", ")", ";", "criteria", ".", "select", "(", "option", ".", "get", "(", "QueryOptionFieldOption_", ".", "text", ")", ")", ";", "criteria", ".", "where", "(", "criteriaBuilder", ".", "and", "(", "criteriaBuilder", ".", "equal", "(", "root", ".", "get", "(", "QueryQuestionOptionAnswer_", ".", "queryField", ")", ",", "queryField", ")", ",", "criteriaBuilder", ".", "equal", "(", "root", ".", "get", "(", "QueryQuestionOptionAnswer_", ".", "queryReply", ")", ",", "queryReply", ")", ")", ")", ";", "return", "getSingleResult", "(", "entityManager", ".", "createQuery", "(", "criteria", ")", ")", ";", "}" ]
Finds answer text by query reply and query field @param queryReply reply @param queryField field @return answer text
[ "Finds", "answer", "text", "by", "query", "reply", "and", "query", "field" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/querydata/QueryQuestionOptionAnswerDAO.java#L45-L63
144,356
Metatavu/edelphi
edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/querydata/QueryQuestionNumericAnswerDAO.java
QueryQuestionNumericAnswerDAO.countByQueryFieldQueryRepliesInAndData
public Long countByQueryFieldQueryRepliesInAndData(QueryField queryField, Collection<QueryReply> queryReplies, Double data) { if (queryReplies == null || queryReplies.isEmpty()) { return 0l; } EntityManager entityManager = getEntityManager(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<Long> criteria = criteriaBuilder.createQuery(Long.class); Root<QueryQuestionNumericAnswer> root = criteria.from(QueryQuestionNumericAnswer.class); Join<QueryQuestionNumericAnswer, QueryReply> replyJoin = root.join(QueryQuestionNumericAnswer_.queryReply); criteria.select(criteriaBuilder.count(root)); criteria.where( criteriaBuilder.and( criteriaBuilder.equal(root.get(QueryQuestionNumericAnswer_.queryField), queryField), root.get(QueryQuestionNumericAnswer_.queryReply).in(queryReplies), criteriaBuilder.equal(root.get(QueryQuestionNumericAnswer_.data), data), criteriaBuilder.equal(replyJoin.get(QueryReply_.archived), Boolean.FALSE) ) ); return entityManager.createQuery(criteria).getSingleResult(); }
java
public Long countByQueryFieldQueryRepliesInAndData(QueryField queryField, Collection<QueryReply> queryReplies, Double data) { if (queryReplies == null || queryReplies.isEmpty()) { return 0l; } EntityManager entityManager = getEntityManager(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<Long> criteria = criteriaBuilder.createQuery(Long.class); Root<QueryQuestionNumericAnswer> root = criteria.from(QueryQuestionNumericAnswer.class); Join<QueryQuestionNumericAnswer, QueryReply> replyJoin = root.join(QueryQuestionNumericAnswer_.queryReply); criteria.select(criteriaBuilder.count(root)); criteria.where( criteriaBuilder.and( criteriaBuilder.equal(root.get(QueryQuestionNumericAnswer_.queryField), queryField), root.get(QueryQuestionNumericAnswer_.queryReply).in(queryReplies), criteriaBuilder.equal(root.get(QueryQuestionNumericAnswer_.data), data), criteriaBuilder.equal(replyJoin.get(QueryReply_.archived), Boolean.FALSE) ) ); return entityManager.createQuery(criteria).getSingleResult(); }
[ "public", "Long", "countByQueryFieldQueryRepliesInAndData", "(", "QueryField", "queryField", ",", "Collection", "<", "QueryReply", ">", "queryReplies", ",", "Double", "data", ")", "{", "if", "(", "queryReplies", "==", "null", "||", "queryReplies", ".", "isEmpty", "(", ")", ")", "{", "return", "0l", ";", "}", "EntityManager", "entityManager", "=", "getEntityManager", "(", ")", ";", "CriteriaBuilder", "criteriaBuilder", "=", "entityManager", ".", "getCriteriaBuilder", "(", ")", ";", "CriteriaQuery", "<", "Long", ">", "criteria", "=", "criteriaBuilder", ".", "createQuery", "(", "Long", ".", "class", ")", ";", "Root", "<", "QueryQuestionNumericAnswer", ">", "root", "=", "criteria", ".", "from", "(", "QueryQuestionNumericAnswer", ".", "class", ")", ";", "Join", "<", "QueryQuestionNumericAnswer", ",", "QueryReply", ">", "replyJoin", "=", "root", ".", "join", "(", "QueryQuestionNumericAnswer_", ".", "queryReply", ")", ";", "criteria", ".", "select", "(", "criteriaBuilder", ".", "count", "(", "root", ")", ")", ";", "criteria", ".", "where", "(", "criteriaBuilder", ".", "and", "(", "criteriaBuilder", ".", "equal", "(", "root", ".", "get", "(", "QueryQuestionNumericAnswer_", ".", "queryField", ")", ",", "queryField", ")", ",", "root", ".", "get", "(", "QueryQuestionNumericAnswer_", ".", "queryReply", ")", ".", "in", "(", "queryReplies", ")", ",", "criteriaBuilder", ".", "equal", "(", "root", ".", "get", "(", "QueryQuestionNumericAnswer_", ".", "data", ")", ",", "data", ")", ",", "criteriaBuilder", ".", "equal", "(", "replyJoin", ".", "get", "(", "QueryReply_", ".", "archived", ")", ",", "Boolean", ".", "FALSE", ")", ")", ")", ";", "return", "entityManager", ".", "createQuery", "(", "criteria", ")", ".", "getSingleResult", "(", ")", ";", "}" ]
Counts query question numeric answers @param queryField query field @param queryReplies query reply set must be in this set @param data data must equal this value @return count of query question numeric answers
[ "Counts", "query", "question", "numeric", "answers" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/querydata/QueryQuestionNumericAnswerDAO.java#L99-L122
144,357
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/users/UserController.java
UserController.findUserByKeycloakId
public User findUserByKeycloakId(UUID userId) { AuthSource authSource = authSourceDAO.findByStrategy(KEYCLOAK_AUTH_SOURCE); if (authSource == null) { logger.error("Could not find Keycloak auth source"); } UserIdentification userIdentification = userIdentificationDAO.findByExternalId(userId.toString(), authSource); if (userIdentification != null) { return userIdentification.getUser(); } return null; }
java
public User findUserByKeycloakId(UUID userId) { AuthSource authSource = authSourceDAO.findByStrategy(KEYCLOAK_AUTH_SOURCE); if (authSource == null) { logger.error("Could not find Keycloak auth source"); } UserIdentification userIdentification = userIdentificationDAO.findByExternalId(userId.toString(), authSource); if (userIdentification != null) { return userIdentification.getUser(); } return null; }
[ "public", "User", "findUserByKeycloakId", "(", "UUID", "userId", ")", "{", "AuthSource", "authSource", "=", "authSourceDAO", ".", "findByStrategy", "(", "KEYCLOAK_AUTH_SOURCE", ")", ";", "if", "(", "authSource", "==", "null", ")", "{", "logger", ".", "error", "(", "\"Could not find Keycloak auth source\"", ")", ";", "}", "UserIdentification", "userIdentification", "=", "userIdentificationDAO", ".", "findByExternalId", "(", "userId", ".", "toString", "(", ")", ",", "authSource", ")", ";", "if", "(", "userIdentification", "!=", "null", ")", "{", "return", "userIdentification", ".", "getUser", "(", ")", ";", "}", "return", "null", ";", "}" ]
Finds user by Keycloak id @param userId Keycloak user id @return user or null if not found
[ "Finds", "user", "by", "Keycloak", "id" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/users/UserController.java#L42-L54
144,358
Metatavu/edelphi
smvcj/src/main/java/fi/metatavu/edelphi/smvcj/controllers/BinaryRequestContext.java
BinaryRequestContext.writePostCommitResponse
@Override public void writePostCommitResponse(int statusCode) throws Exception { if (statusCode == StatusCode.OK) { if (fileName != null) { getResponse().setHeader("Content-Disposition", "attachment; filename=" + fileName); } if (contentType != null && content != null) { getResponse().setContentType(contentType); getResponse().getOutputStream().write(content); } else if (!StringUtils.isBlank(contentUrl)) { handleContentUrl(); } } else { // TODO Error handing switch (statusCode) { case StatusCode.UNAUTHORIZED: case StatusCode.NOT_LOGGED_IN: getResponse().setStatus(403); break; default: getResponse().setStatus(500); break; } } }
java
@Override public void writePostCommitResponse(int statusCode) throws Exception { if (statusCode == StatusCode.OK) { if (fileName != null) { getResponse().setHeader("Content-Disposition", "attachment; filename=" + fileName); } if (contentType != null && content != null) { getResponse().setContentType(contentType); getResponse().getOutputStream().write(content); } else if (!StringUtils.isBlank(contentUrl)) { handleContentUrl(); } } else { // TODO Error handing switch (statusCode) { case StatusCode.UNAUTHORIZED: case StatusCode.NOT_LOGGED_IN: getResponse().setStatus(403); break; default: getResponse().setStatus(500); break; } } }
[ "@", "Override", "public", "void", "writePostCommitResponse", "(", "int", "statusCode", ")", "throws", "Exception", "{", "if", "(", "statusCode", "==", "StatusCode", ".", "OK", ")", "{", "if", "(", "fileName", "!=", "null", ")", "{", "getResponse", "(", ")", ".", "setHeader", "(", "\"Content-Disposition\"", ",", "\"attachment; filename=\"", "+", "fileName", ")", ";", "}", "if", "(", "contentType", "!=", "null", "&&", "content", "!=", "null", ")", "{", "getResponse", "(", ")", ".", "setContentType", "(", "contentType", ")", ";", "getResponse", "(", ")", ".", "getOutputStream", "(", ")", ".", "write", "(", "content", ")", ";", "}", "else", "if", "(", "!", "StringUtils", ".", "isBlank", "(", "contentUrl", ")", ")", "{", "handleContentUrl", "(", ")", ";", "}", "}", "else", "{", "// TODO Error handing", "switch", "(", "statusCode", ")", "{", "case", "StatusCode", ".", "UNAUTHORIZED", ":", "case", "StatusCode", ".", "NOT_LOGGED_IN", ":", "getResponse", "(", ")", ".", "setStatus", "(", "403", ")", ";", "break", ";", "default", ":", "getResponse", "(", ")", ".", "setStatus", "(", "500", ")", ";", "break", ";", "}", "}", "}" ]
Writes the response to the binary request. @throws Exception If writing the response fails for any reason
[ "Writes", "the", "response", "to", "the", "binary", "request", "." ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/smvcj/src/main/java/fi/metatavu/edelphi/smvcj/controllers/BinaryRequestContext.java#L80-L106
144,359
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/pages/panel/admin/report/util/QueryReportPageController.java
QueryReportPageController.getRequestAnswerMap
protected Map<Long, Map<String, String>> getRequestAnswerMap(RequestContext requestContext) { @SuppressWarnings("unchecked") Map<Long,Map<String,String>> answers = (Map<Long,Map<String,String>>) requestContext.getRequest().getAttribute("commentAnswers"); if (answers == null) { answers = new HashMap<>(); requestContext.getRequest().setAttribute("commentAnswers", answers); } return answers; }
java
protected Map<Long, Map<String, String>> getRequestAnswerMap(RequestContext requestContext) { @SuppressWarnings("unchecked") Map<Long,Map<String,String>> answers = (Map<Long,Map<String,String>>) requestContext.getRequest().getAttribute("commentAnswers"); if (answers == null) { answers = new HashMap<>(); requestContext.getRequest().setAttribute("commentAnswers", answers); } return answers; }
[ "protected", "Map", "<", "Long", ",", "Map", "<", "String", ",", "String", ">", ">", "getRequestAnswerMap", "(", "RequestContext", "requestContext", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Map", "<", "Long", ",", "Map", "<", "String", ",", "String", ">", ">", "answers", "=", "(", "Map", "<", "Long", ",", "Map", "<", "String", ",", "String", ">", ">", ")", "requestContext", ".", "getRequest", "(", ")", ".", "getAttribute", "(", "\"commentAnswers\"", ")", ";", "if", "(", "answers", "==", "null", ")", "{", "answers", "=", "new", "HashMap", "<>", "(", ")", ";", "requestContext", ".", "getRequest", "(", ")", ".", "setAttribute", "(", "\"commentAnswers\"", ",", "answers", ")", ";", "}", "return", "answers", ";", "}" ]
Returns comment answers map from the request context. If map is not yet defined, new is created. @param requestContext request contract @return answer map
[ "Returns", "comment", "answers", "map", "from", "the", "request", "context", ".", "If", "map", "is", "not", "yet", "defined", "new", "is", "created", "." ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/pages/panel/admin/report/util/QueryReportPageController.java#L60-L69
144,360
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/languagedetect/TextLanguageDetector.java
TextLanguageDetector.getLanguage
public String getLanguage (String text) { String language = null; TextObject textObject = textObjectFactory.forText(text); com.google.common.base.Optional<LdLocale> lang = languageDetector.detect(textObject); if (lang.isPresent()) { language = lang.get().toString(); } return language; }
java
public String getLanguage (String text) { String language = null; TextObject textObject = textObjectFactory.forText(text); com.google.common.base.Optional<LdLocale> lang = languageDetector.detect(textObject); if (lang.isPresent()) { language = lang.get().toString(); } return language; }
[ "public", "String", "getLanguage", "(", "String", "text", ")", "{", "String", "language", "=", "null", ";", "TextObject", "textObject", "=", "textObjectFactory", ".", "forText", "(", "text", ")", ";", "com", ".", "google", ".", "common", ".", "base", ".", "Optional", "<", "LdLocale", ">", "lang", "=", "languageDetector", ".", "detect", "(", "textObject", ")", ";", "if", "(", "lang", ".", "isPresent", "(", ")", ")", "{", "language", "=", "lang", ".", "get", "(", ")", ".", "toString", "(", ")", ";", "}", "return", "language", ";", "}" ]
Get language from string @param text Detect language from this String @return String Detected language
[ "Get", "language", "from", "string" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/languagedetect/TextLanguageDetector.java#L51-L61
144,361
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/query/AbstractQueryPageHandler.java
AbstractQueryPageHandler.renderComments
protected void renderComments(PageRequestContext requestContext, QueryPage queryPage, QueryReply queryReply, boolean commentable, boolean viewDiscussion) { Query query = queryPage.getQuerySection().getQuery(); Panel panel = ResourceUtils.getResourcePanel(query); RequiredQueryFragment queryFragment = new RequiredQueryFragment("comments"); queryFragment.addAttribute("panelId", panel.getId().toString()); queryFragment.addAttribute("queryId", query.getId().toString()); queryFragment.addAttribute("pageId", queryPage.getId().toString()); if (queryReply != null) { queryFragment.addAttribute("queryReplyId", queryReply.getId().toString()); } queryFragment.addAttribute("queryPageCommentable", commentable ? "true" : "false"); queryFragment.addAttribute("queryViewDiscussion", viewDiscussion ? "true" : "false"); addRequiredFragment(requestContext, queryFragment); }
java
protected void renderComments(PageRequestContext requestContext, QueryPage queryPage, QueryReply queryReply, boolean commentable, boolean viewDiscussion) { Query query = queryPage.getQuerySection().getQuery(); Panel panel = ResourceUtils.getResourcePanel(query); RequiredQueryFragment queryFragment = new RequiredQueryFragment("comments"); queryFragment.addAttribute("panelId", panel.getId().toString()); queryFragment.addAttribute("queryId", query.getId().toString()); queryFragment.addAttribute("pageId", queryPage.getId().toString()); if (queryReply != null) { queryFragment.addAttribute("queryReplyId", queryReply.getId().toString()); } queryFragment.addAttribute("queryPageCommentable", commentable ? "true" : "false"); queryFragment.addAttribute("queryViewDiscussion", viewDiscussion ? "true" : "false"); addRequiredFragment(requestContext, queryFragment); }
[ "protected", "void", "renderComments", "(", "PageRequestContext", "requestContext", ",", "QueryPage", "queryPage", ",", "QueryReply", "queryReply", ",", "boolean", "commentable", ",", "boolean", "viewDiscussion", ")", "{", "Query", "query", "=", "queryPage", ".", "getQuerySection", "(", ")", ".", "getQuery", "(", ")", ";", "Panel", "panel", "=", "ResourceUtils", ".", "getResourcePanel", "(", "query", ")", ";", "RequiredQueryFragment", "queryFragment", "=", "new", "RequiredQueryFragment", "(", "\"comments\"", ")", ";", "queryFragment", ".", "addAttribute", "(", "\"panelId\"", ",", "panel", ".", "getId", "(", ")", ".", "toString", "(", ")", ")", ";", "queryFragment", ".", "addAttribute", "(", "\"queryId\"", ",", "query", ".", "getId", "(", ")", ".", "toString", "(", ")", ")", ";", "queryFragment", ".", "addAttribute", "(", "\"pageId\"", ",", "queryPage", ".", "getId", "(", ")", ".", "toString", "(", ")", ")", ";", "if", "(", "queryReply", "!=", "null", ")", "{", "queryFragment", ".", "addAttribute", "(", "\"queryReplyId\"", ",", "queryReply", ".", "getId", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "queryFragment", ".", "addAttribute", "(", "\"queryPageCommentable\"", ",", "commentable", "?", "\"true\"", ":", "\"false\"", ")", ";", "queryFragment", ".", "addAttribute", "(", "\"queryViewDiscussion\"", ",", "viewDiscussion", "?", "\"true\"", ":", "\"false\"", ")", ";", "addRequiredFragment", "(", "requestContext", ",", "queryFragment", ")", ";", "}" ]
Renders comment list and comment editor @param requestContext request context @param queryPage query page @param queryReply query reply @param commentable whether to render comment editor @param viewDiscussion whether to render comment list
[ "Renders", "comment", "list", "and", "comment", "editor" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/query/AbstractQueryPageHandler.java#L141-L157
144,362
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/permissions/PermissionController.java
PermissionController.hasDelfoiAccess
public boolean hasDelfoiAccess(User user, DelfoiActionName actionName) { if (isSuperUser(user)) { return true; } DelfoiAction action = delfoiActionDAO.findByActionName(actionName.toString()); if (action == null) { logger.info(String.format("ActionUtils.hasDelfoiAccess - undefined action: '%s'", actionName)); return false; } UserRole userRole = getDelfoiRole(user); return hasDelfoiAccess(action, userRole); }
java
public boolean hasDelfoiAccess(User user, DelfoiActionName actionName) { if (isSuperUser(user)) { return true; } DelfoiAction action = delfoiActionDAO.findByActionName(actionName.toString()); if (action == null) { logger.info(String.format("ActionUtils.hasDelfoiAccess - undefined action: '%s'", actionName)); return false; } UserRole userRole = getDelfoiRole(user); return hasDelfoiAccess(action, userRole); }
[ "public", "boolean", "hasDelfoiAccess", "(", "User", "user", ",", "DelfoiActionName", "actionName", ")", "{", "if", "(", "isSuperUser", "(", "user", ")", ")", "{", "return", "true", ";", "}", "DelfoiAction", "action", "=", "delfoiActionDAO", ".", "findByActionName", "(", "actionName", ".", "toString", "(", ")", ")", ";", "if", "(", "action", "==", "null", ")", "{", "logger", ".", "info", "(", "String", ".", "format", "(", "\"ActionUtils.hasDelfoiAccess - undefined action: '%s'\"", ",", "actionName", ")", ")", ";", "return", "false", ";", "}", "UserRole", "userRole", "=", "getDelfoiRole", "(", "user", ")", ";", "return", "hasDelfoiAccess", "(", "action", ",", "userRole", ")", ";", "}" ]
Returns whether user has required delfoi action access @param user user @param actionName action @return whether user role required action access
[ "Returns", "whether", "user", "has", "required", "delfoi", "action", "access" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/permissions/PermissionController.java#L62-L75
144,363
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/permissions/PermissionController.java
PermissionController.hasPanelAccess
public boolean hasPanelAccess(Panel panel, User user, DelfoiActionName actionName) { if (panel == null) { logger.warn("Panel was null when checking panel access"); return false; } if (user == null) { logger.warn("User was null when checking panel access"); return false; } if (isSuperUser(user)) { return true; } UserRole userRole = getPanelRole(user, panel); if (userRole == null) { return false; } DelfoiAction action = delfoiActionDAO.findByActionName(actionName.toString()); if (action == null) { logger.info(String.format("ActionUtils.hasDelfoiAccess - undefined action: '%s'", actionName)); return false; } return hasPanelAccess(panel, action, userRole); }
java
public boolean hasPanelAccess(Panel panel, User user, DelfoiActionName actionName) { if (panel == null) { logger.warn("Panel was null when checking panel access"); return false; } if (user == null) { logger.warn("User was null when checking panel access"); return false; } if (isSuperUser(user)) { return true; } UserRole userRole = getPanelRole(user, panel); if (userRole == null) { return false; } DelfoiAction action = delfoiActionDAO.findByActionName(actionName.toString()); if (action == null) { logger.info(String.format("ActionUtils.hasDelfoiAccess - undefined action: '%s'", actionName)); return false; } return hasPanelAccess(panel, action, userRole); }
[ "public", "boolean", "hasPanelAccess", "(", "Panel", "panel", ",", "User", "user", ",", "DelfoiActionName", "actionName", ")", "{", "if", "(", "panel", "==", "null", ")", "{", "logger", ".", "warn", "(", "\"Panel was null when checking panel access\"", ")", ";", "return", "false", ";", "}", "if", "(", "user", "==", "null", ")", "{", "logger", ".", "warn", "(", "\"User was null when checking panel access\"", ")", ";", "return", "false", ";", "}", "if", "(", "isSuperUser", "(", "user", ")", ")", "{", "return", "true", ";", "}", "UserRole", "userRole", "=", "getPanelRole", "(", "user", ",", "panel", ")", ";", "if", "(", "userRole", "==", "null", ")", "{", "return", "false", ";", "}", "DelfoiAction", "action", "=", "delfoiActionDAO", ".", "findByActionName", "(", "actionName", ".", "toString", "(", ")", ")", ";", "if", "(", "action", "==", "null", ")", "{", "logger", ".", "info", "(", "String", ".", "format", "(", "\"ActionUtils.hasDelfoiAccess - undefined action: '%s'\"", ",", "actionName", ")", ")", ";", "return", "false", ";", "}", "return", "hasPanelAccess", "(", "panel", ",", "action", ",", "userRole", ")", ";", "}" ]
Returns whether user has required panel action access @param panel panel @param user user @param actionName action @return whether user role required action access
[ "Returns", "whether", "user", "has", "required", "panel", "action", "access" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/permissions/PermissionController.java#L85-L113
144,364
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/permissions/PermissionController.java
PermissionController.getPanelRole
private UserRole getPanelRole(User user, Panel panel) { if (panel != null) { PanelUserDAO panelUserDAO = new PanelUserDAO(); PanelUser panelUser = panelUserDAO.findByPanelAndUserAndStamp(panel, user, panel.getCurrentStamp()); return panelUser == null ? getEveryoneRole() : panelUser.getRole(); } return getEveryoneRole(); }
java
private UserRole getPanelRole(User user, Panel panel) { if (panel != null) { PanelUserDAO panelUserDAO = new PanelUserDAO(); PanelUser panelUser = panelUserDAO.findByPanelAndUserAndStamp(panel, user, panel.getCurrentStamp()); return panelUser == null ? getEveryoneRole() : panelUser.getRole(); } return getEveryoneRole(); }
[ "private", "UserRole", "getPanelRole", "(", "User", "user", ",", "Panel", "panel", ")", "{", "if", "(", "panel", "!=", "null", ")", "{", "PanelUserDAO", "panelUserDAO", "=", "new", "PanelUserDAO", "(", ")", ";", "PanelUser", "panelUser", "=", "panelUserDAO", ".", "findByPanelAndUserAndStamp", "(", "panel", ",", "user", ",", "panel", ".", "getCurrentStamp", "(", ")", ")", ";", "return", "panelUser", "==", "null", "?", "getEveryoneRole", "(", ")", ":", "panelUser", ".", "getRole", "(", ")", ";", "}", "return", "getEveryoneRole", "(", ")", ";", "}" ]
Returns user's panel role @param user user @param panel panel @return user's panel role
[ "Returns", "user", "s", "panel", "role" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/permissions/PermissionController.java#L122-L130
144,365
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/permissions/PermissionController.java
PermissionController.getDelfoiRole
private UserRole getDelfoiRole(User user) { Delfoi delfoi = getDelfoi(); if (delfoi != null) { DelfoiUserDAO delfoiUserDAO = new DelfoiUserDAO(); DelfoiUser delfoiUser = delfoiUserDAO.findByDelfoiAndUser(delfoi, user); return delfoiUser == null ? getEveryoneRole() : delfoiUser.getRole(); } return getEveryoneRole(); }
java
private UserRole getDelfoiRole(User user) { Delfoi delfoi = getDelfoi(); if (delfoi != null) { DelfoiUserDAO delfoiUserDAO = new DelfoiUserDAO(); DelfoiUser delfoiUser = delfoiUserDAO.findByDelfoiAndUser(delfoi, user); return delfoiUser == null ? getEveryoneRole() : delfoiUser.getRole(); } return getEveryoneRole(); }
[ "private", "UserRole", "getDelfoiRole", "(", "User", "user", ")", "{", "Delfoi", "delfoi", "=", "getDelfoi", "(", ")", ";", "if", "(", "delfoi", "!=", "null", ")", "{", "DelfoiUserDAO", "delfoiUserDAO", "=", "new", "DelfoiUserDAO", "(", ")", ";", "DelfoiUser", "delfoiUser", "=", "delfoiUserDAO", ".", "findByDelfoiAndUser", "(", "delfoi", ",", "user", ")", ";", "return", "delfoiUser", "==", "null", "?", "getEveryoneRole", "(", ")", ":", "delfoiUser", ".", "getRole", "(", ")", ";", "}", "return", "getEveryoneRole", "(", ")", ";", "}" ]
Returns user's Delfoi role @param user user @return user's Delfoi role
[ "Returns", "user", "s", "Delfoi", "role" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/permissions/PermissionController.java#L138-L147
144,366
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/settings/SettingsController.java
SettingsController.getMqttSettings
public MqttSettings getMqttSettings() { MqttSettings settings = new MqttSettings(); settings.setServerUrl(getSettingValue("mqtt.serverUrl")); settings.setClientUrl(getSettingValue("mqtt.clientUrl")); settings.setTopic(getSettingValue("mqtt.topic")); settings.setWildcard(getSettingValue("mqtt.wildcard")); return settings; }
java
public MqttSettings getMqttSettings() { MqttSettings settings = new MqttSettings(); settings.setServerUrl(getSettingValue("mqtt.serverUrl")); settings.setClientUrl(getSettingValue("mqtt.clientUrl")); settings.setTopic(getSettingValue("mqtt.topic")); settings.setWildcard(getSettingValue("mqtt.wildcard")); return settings; }
[ "public", "MqttSettings", "getMqttSettings", "(", ")", "{", "MqttSettings", "settings", "=", "new", "MqttSettings", "(", ")", ";", "settings", ".", "setServerUrl", "(", "getSettingValue", "(", "\"mqtt.serverUrl\"", ")", ")", ";", "settings", ".", "setClientUrl", "(", "getSettingValue", "(", "\"mqtt.clientUrl\"", ")", ")", ";", "settings", ".", "setTopic", "(", "getSettingValue", "(", "\"mqtt.topic\"", ")", ")", ";", "settings", ".", "setWildcard", "(", "getSettingValue", "(", "\"mqtt.wildcard\"", ")", ")", ";", "return", "settings", ";", "}" ]
Returns MQTT settings @return MQTT settings
[ "Returns", "MQTT", "settings" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/settings/SettingsController.java#L30-L37
144,367
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/settings/SettingsController.java
SettingsController.getSettingValue
private String getSettingValue(String key) { SettingKey settingKey = settingKeyDAO.findByName(key); if (settingKey == null) { return null; } Setting setting = settingDAO.findByKey(settingKey); return setting != null ? setting.getValue() : null; }
java
private String getSettingValue(String key) { SettingKey settingKey = settingKeyDAO.findByName(key); if (settingKey == null) { return null; } Setting setting = settingDAO.findByKey(settingKey); return setting != null ? setting.getValue() : null; }
[ "private", "String", "getSettingValue", "(", "String", "key", ")", "{", "SettingKey", "settingKey", "=", "settingKeyDAO", ".", "findByName", "(", "key", ")", ";", "if", "(", "settingKey", "==", "null", ")", "{", "return", "null", ";", "}", "Setting", "setting", "=", "settingDAO", ".", "findByKey", "(", "settingKey", ")", ";", "return", "setting", "!=", "null", "?", "setting", ".", "getValue", "(", ")", ":", "null", ";", "}" ]
Returns a setting value for given key @param key key @return setting value
[ "Returns", "a", "setting", "value", "for", "given", "key" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/settings/SettingsController.java#L45-L53
144,368
Metatavu/edelphi
edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/users/UserIdentificationDAO.java
UserIdentificationDAO.listByUserAndAuthSource
public List<UserIdentification> listByUserAndAuthSource(User user, AuthSource authSource) { EntityManager entityManager = getEntityManager(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<UserIdentification> criteria = criteriaBuilder.createQuery(UserIdentification.class); Root<UserIdentification> root = criteria.from(UserIdentification.class); criteria.select(root); criteria.where( criteriaBuilder.and( criteriaBuilder.equal(root.get(UserIdentification_.user), user), criteriaBuilder.equal(root.get(UserIdentification_.authSource), authSource) ) ); return entityManager.createQuery(criteria).getResultList(); }
java
public List<UserIdentification> listByUserAndAuthSource(User user, AuthSource authSource) { EntityManager entityManager = getEntityManager(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<UserIdentification> criteria = criteriaBuilder.createQuery(UserIdentification.class); Root<UserIdentification> root = criteria.from(UserIdentification.class); criteria.select(root); criteria.where( criteriaBuilder.and( criteriaBuilder.equal(root.get(UserIdentification_.user), user), criteriaBuilder.equal(root.get(UserIdentification_.authSource), authSource) ) ); return entityManager.createQuery(criteria).getResultList(); }
[ "public", "List", "<", "UserIdentification", ">", "listByUserAndAuthSource", "(", "User", "user", ",", "AuthSource", "authSource", ")", "{", "EntityManager", "entityManager", "=", "getEntityManager", "(", ")", ";", "CriteriaBuilder", "criteriaBuilder", "=", "entityManager", ".", "getCriteriaBuilder", "(", ")", ";", "CriteriaQuery", "<", "UserIdentification", ">", "criteria", "=", "criteriaBuilder", ".", "createQuery", "(", "UserIdentification", ".", "class", ")", ";", "Root", "<", "UserIdentification", ">", "root", "=", "criteria", ".", "from", "(", "UserIdentification", ".", "class", ")", ";", "criteria", ".", "select", "(", "root", ")", ";", "criteria", ".", "where", "(", "criteriaBuilder", ".", "and", "(", "criteriaBuilder", ".", "equal", "(", "root", ".", "get", "(", "UserIdentification_", ".", "user", ")", ",", "user", ")", ",", "criteriaBuilder", ".", "equal", "(", "root", ".", "get", "(", "UserIdentification_", ".", "authSource", ")", ",", "authSource", ")", ")", ")", ";", "return", "entityManager", ".", "createQuery", "(", "criteria", ")", ".", "getResultList", "(", ")", ";", "}" ]
Lists user identifications by user and auth source @param user user @param authSource auth source @return user identification
[ "Lists", "user", "identifications", "by", "user", "and", "auth", "source" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/users/UserIdentificationDAO.java#L57-L72
144,369
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/auth/AbstractAuthenticationStrategy.java
AbstractAuthenticationStrategy.initialize
public void initialize(AuthSource authSource) { this.authSource = authSource; AuthSourceSettingDAO authSourceSettingDAO = new AuthSourceSettingDAO(); List<AuthSourceSetting> authSourceSettings = authSourceSettingDAO.listByAuthSource(authSource); this.settings = new HashMap<>(); for (AuthSourceSetting setting : authSourceSettings) { settings.put(setting.getKey(), setting.getValue()); } }
java
public void initialize(AuthSource authSource) { this.authSource = authSource; AuthSourceSettingDAO authSourceSettingDAO = new AuthSourceSettingDAO(); List<AuthSourceSetting> authSourceSettings = authSourceSettingDAO.listByAuthSource(authSource); this.settings = new HashMap<>(); for (AuthSourceSetting setting : authSourceSettings) { settings.put(setting.getKey(), setting.getValue()); } }
[ "public", "void", "initialize", "(", "AuthSource", "authSource", ")", "{", "this", ".", "authSource", "=", "authSource", ";", "AuthSourceSettingDAO", "authSourceSettingDAO", "=", "new", "AuthSourceSettingDAO", "(", ")", ";", "List", "<", "AuthSourceSetting", ">", "authSourceSettings", "=", "authSourceSettingDAO", ".", "listByAuthSource", "(", "authSource", ")", ";", "this", ".", "settings", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "AuthSourceSetting", "setting", ":", "authSourceSettings", ")", "{", "settings", ".", "put", "(", "setting", ".", "getKey", "(", ")", ",", "setting", ".", "getValue", "(", ")", ")", ";", "}", "}" ]
Initializes this authentication strategy to work as per the given authentication source. @param authSource The authentication source
[ "Initializes", "this", "authentication", "strategy", "to", "work", "as", "per", "the", "given", "authentication", "source", "." ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/auth/AbstractAuthenticationStrategy.java#L35-L43
144,370
Metatavu/edelphi
edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/base/AuthSourceDAO.java
AuthSourceDAO.findByStrategy
public AuthSource findByStrategy(String strategy) { EntityManager entityManager = getEntityManager(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<AuthSource> criteria = criteriaBuilder.createQuery(AuthSource.class); Root<AuthSource> root = criteria.from(AuthSource.class); criteria.select(root); criteria.where( criteriaBuilder.equal(root.get(AuthSource_.strategy), strategy) ); return getSingleResult(entityManager.createQuery(criteria)); }
java
public AuthSource findByStrategy(String strategy) { EntityManager entityManager = getEntityManager(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<AuthSource> criteria = criteriaBuilder.createQuery(AuthSource.class); Root<AuthSource> root = criteria.from(AuthSource.class); criteria.select(root); criteria.where( criteriaBuilder.equal(root.get(AuthSource_.strategy), strategy) ); return getSingleResult(entityManager.createQuery(criteria)); }
[ "public", "AuthSource", "findByStrategy", "(", "String", "strategy", ")", "{", "EntityManager", "entityManager", "=", "getEntityManager", "(", ")", ";", "CriteriaBuilder", "criteriaBuilder", "=", "entityManager", ".", "getCriteriaBuilder", "(", ")", ";", "CriteriaQuery", "<", "AuthSource", ">", "criteria", "=", "criteriaBuilder", ".", "createQuery", "(", "AuthSource", ".", "class", ")", ";", "Root", "<", "AuthSource", ">", "root", "=", "criteria", ".", "from", "(", "AuthSource", ".", "class", ")", ";", "criteria", ".", "select", "(", "root", ")", ";", "criteria", ".", "where", "(", "criteriaBuilder", ".", "equal", "(", "root", ".", "get", "(", "AuthSource_", ".", "strategy", ")", ",", "strategy", ")", ")", ";", "return", "getSingleResult", "(", "entityManager", ".", "createQuery", "(", "criteria", ")", ")", ";", "}" ]
Finds an auth source by strategy @param strategy strategy @return auth source or null if not found
[ "Finds", "an", "auth", "source", "by", "strategy" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/base/AuthSourceDAO.java#L22-L34
144,371
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/mqtt/MqttConnection.java
MqttConnection.publish
private static void publish(MqttSettings settings, String subtopic, byte[] payload, int qos, boolean retained) throws MqttException { getClient(settings).publish(String.format("%s/%s", settings.getTopic(), subtopic), payload, qos, retained); }
java
private static void publish(MqttSettings settings, String subtopic, byte[] payload, int qos, boolean retained) throws MqttException { getClient(settings).publish(String.format("%s/%s", settings.getTopic(), subtopic), payload, qos, retained); }
[ "private", "static", "void", "publish", "(", "MqttSettings", "settings", ",", "String", "subtopic", ",", "byte", "[", "]", "payload", ",", "int", "qos", ",", "boolean", "retained", ")", "throws", "MqttException", "{", "getClient", "(", "settings", ")", ".", "publish", "(", "String", ".", "format", "(", "\"%s/%s\"", ",", "settings", ".", "getTopic", "(", ")", ",", "subtopic", ")", ",", "payload", ",", "qos", ",", "retained", ")", ";", "}" ]
Publishes message into given MQTT topic @param settings MQTT settings @param subtopic subtopic to deliver the message to. @param payload the byte array to use as the payload @param qos the Quality of Service to deliver the message at. Valid values are 0, 1 or 2. @param retained whether or not this message should be retained by the server. @throws MqttException thrown when MQTT client construction fails
[ "Publishes", "message", "into", "given", "MQTT", "topic" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/mqtt/MqttConnection.java#L49-L51
144,372
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/mqtt/MqttConnection.java
MqttConnection.getClient
private static synchronized IMqttClient getClient(MqttSettings settings) throws MqttException { if (CLIENT == null) { CLIENT = new MqttClient(settings.getServerUrl(), PUBLISHER_ID); MqttConnectOptions options = new MqttConnectOptions(); options.setAutomaticReconnect(true); options.setCleanSession(true); options.setConnectionTimeout(10); CLIENT.connect(options); } return CLIENT; }
java
private static synchronized IMqttClient getClient(MqttSettings settings) throws MqttException { if (CLIENT == null) { CLIENT = new MqttClient(settings.getServerUrl(), PUBLISHER_ID); MqttConnectOptions options = new MqttConnectOptions(); options.setAutomaticReconnect(true); options.setCleanSession(true); options.setConnectionTimeout(10); CLIENT.connect(options); } return CLIENT; }
[ "private", "static", "synchronized", "IMqttClient", "getClient", "(", "MqttSettings", "settings", ")", "throws", "MqttException", "{", "if", "(", "CLIENT", "==", "null", ")", "{", "CLIENT", "=", "new", "MqttClient", "(", "settings", ".", "getServerUrl", "(", ")", ",", "PUBLISHER_ID", ")", ";", "MqttConnectOptions", "options", "=", "new", "MqttConnectOptions", "(", ")", ";", "options", ".", "setAutomaticReconnect", "(", "true", ")", ";", "options", ".", "setCleanSession", "(", "true", ")", ";", "options", ".", "setConnectionTimeout", "(", "10", ")", ";", "CLIENT", ".", "connect", "(", "options", ")", ";", "}", "return", "CLIENT", ";", "}" ]
Returns client instance @param settings settings @return client instance @throws MqttException thrown when MQTT client construction fails
[ "Returns", "client", "instance" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/mqtt/MqttConnection.java#L60-L71
144,373
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/jsons/panel/admin/CreateInvitationJSONRequestController.java
CreateInvitationJSONRequestController.getUserEmail
private String getUserEmail(Long userId) { UserDAO userDAO = new UserDAO(); User user = userDAO.findById(userId); return user.getDefaultEmailAsString(); }
java
private String getUserEmail(Long userId) { UserDAO userDAO = new UserDAO(); User user = userDAO.findById(userId); return user.getDefaultEmailAsString(); }
[ "private", "String", "getUserEmail", "(", "Long", "userId", ")", "{", "UserDAO", "userDAO", "=", "new", "UserDAO", "(", ")", ";", "User", "user", "=", "userDAO", ".", "findById", "(", "userId", ")", ";", "return", "user", ".", "getDefaultEmailAsString", "(", ")", ";", "}" ]
Returns user's default email address by user id @param userId user id @return user's default email address
[ "Returns", "user", "s", "default", "email", "address", "by", "user", "id" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/jsons/panel/admin/CreateInvitationJSONRequestController.java#L97-L101
144,374
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/comments/QueryQuestionCommentController.java
QueryQuestionCommentController.createQueryQuestionComment
public QueryQuestionComment createQueryQuestionComment(QueryReply queryReply, QueryPage queryPage, QueryQuestionComment parentComment, String comment, Boolean hidden, User creator, Date created) { return queryQuestionCommentDAO.create(queryReply, queryPage, parentComment, comment, hidden, creator, created, creator, created); }
java
public QueryQuestionComment createQueryQuestionComment(QueryReply queryReply, QueryPage queryPage, QueryQuestionComment parentComment, String comment, Boolean hidden, User creator, Date created) { return queryQuestionCommentDAO.create(queryReply, queryPage, parentComment, comment, hidden, creator, created, creator, created); }
[ "public", "QueryQuestionComment", "createQueryQuestionComment", "(", "QueryReply", "queryReply", ",", "QueryPage", "queryPage", ",", "QueryQuestionComment", "parentComment", ",", "String", "comment", ",", "Boolean", "hidden", ",", "User", "creator", ",", "Date", "created", ")", "{", "return", "queryQuestionCommentDAO", ".", "create", "(", "queryReply", ",", "queryPage", ",", "parentComment", ",", "comment", ",", "hidden", ",", "creator", ",", "created", ",", "creator", ",", "created", ")", ";", "}" ]
Creates new query question comment @param queryReply query reply @param queryPage query page @param parentComment parent comment @param comment comment contents @param hidden whether comment should be hidden @param creator creator @param created create time @return created comment
[ "Creates", "new", "query", "question", "comment" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/comments/QueryQuestionCommentController.java#L49-L51
144,375
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/comments/QueryQuestionCommentController.java
QueryQuestionCommentController.listQueryQuestionComments
public List<QueryQuestionComment> listQueryQuestionComments(Panel panel, PanelStamp stamp, QueryPage queryPage, Query query, QueryQuestionComment parentComment, User user, boolean onlyRootComments) { if (stamp == null) { stamp = panel.getCurrentStamp(); } return queryQuestionCommentDAO.list(queryPage, stamp, query, panel.getRootFolder(), parentComment, onlyRootComments, user, Boolean.FALSE); }
java
public List<QueryQuestionComment> listQueryQuestionComments(Panel panel, PanelStamp stamp, QueryPage queryPage, Query query, QueryQuestionComment parentComment, User user, boolean onlyRootComments) { if (stamp == null) { stamp = panel.getCurrentStamp(); } return queryQuestionCommentDAO.list(queryPage, stamp, query, panel.getRootFolder(), parentComment, onlyRootComments, user, Boolean.FALSE); }
[ "public", "List", "<", "QueryQuestionComment", ">", "listQueryQuestionComments", "(", "Panel", "panel", ",", "PanelStamp", "stamp", ",", "QueryPage", "queryPage", ",", "Query", "query", ",", "QueryQuestionComment", "parentComment", ",", "User", "user", ",", "boolean", "onlyRootComments", ")", "{", "if", "(", "stamp", "==", "null", ")", "{", "stamp", "=", "panel", ".", "getCurrentStamp", "(", ")", ";", "}", "return", "queryQuestionCommentDAO", ".", "list", "(", "queryPage", ",", "stamp", ",", "query", ",", "panel", ".", "getRootFolder", "(", ")", ",", "parentComment", ",", "onlyRootComments", ",", "user", ",", "Boolean", ".", "FALSE", ")", ";", "}" ]
Lists not archived comments by given parameters. @param panel panel. Required @param stamp filter by panel stamp. Defaults to panel's current stamp @param queryPage filter by comment's query page. Ignored if null @param query filter by query. Ignored if null @param parentComment filter by parent comment. Ignored if null @param user filter by user. Ignored if null. @param onlyRootComments return only root comments. @return a list of comments
[ "Lists", "not", "archived", "comments", "by", "given", "parameters", "." ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/comments/QueryQuestionCommentController.java#L75-L81
144,376
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/comments/QueryQuestionCommentController.java
QueryQuestionCommentController.updateQueryQuestionComment
public QueryQuestionComment updateQueryQuestionComment(QueryQuestionComment queryQuestionComment, String comment, Boolean hidden, User modifier, Date modified) { queryQuestionCommentDAO.updateHidden(queryQuestionComment, hidden, modifier); return queryQuestionCommentDAO.updateComment(queryQuestionComment, comment, modifier, modified); }
java
public QueryQuestionComment updateQueryQuestionComment(QueryQuestionComment queryQuestionComment, String comment, Boolean hidden, User modifier, Date modified) { queryQuestionCommentDAO.updateHidden(queryQuestionComment, hidden, modifier); return queryQuestionCommentDAO.updateComment(queryQuestionComment, comment, modifier, modified); }
[ "public", "QueryQuestionComment", "updateQueryQuestionComment", "(", "QueryQuestionComment", "queryQuestionComment", ",", "String", "comment", ",", "Boolean", "hidden", ",", "User", "modifier", ",", "Date", "modified", ")", "{", "queryQuestionCommentDAO", ".", "updateHidden", "(", "queryQuestionComment", ",", "hidden", ",", "modifier", ")", ";", "return", "queryQuestionCommentDAO", ".", "updateComment", "(", "queryQuestionComment", ",", "comment", ",", "modifier", ",", "modified", ")", ";", "}" ]
Updates query question comment @param queryQuestionComment comment to be updated @param comment comment contents @param hidden whether comment should be hidden @param modifier modifier @param modified modification time @return
[ "Updates", "query", "question", "comment" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/comments/QueryQuestionCommentController.java#L93-L96
144,377
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/comments/QueryQuestionCommentController.java
QueryQuestionCommentController.isQueryQuestionCommentArchived
public boolean isQueryQuestionCommentArchived(QueryQuestionComment comment) { if (comment == null || comment.getArchived()) { return true; } if (comment.getParentComment() != null && isQueryQuestionCommentArchived(comment.getParentComment())) { return true; } if (comment.getQueryReply().getArchived()) { return true; } return queryController.isQueryPageArchived(comment.getQueryPage()); }
java
public boolean isQueryQuestionCommentArchived(QueryQuestionComment comment) { if (comment == null || comment.getArchived()) { return true; } if (comment.getParentComment() != null && isQueryQuestionCommentArchived(comment.getParentComment())) { return true; } if (comment.getQueryReply().getArchived()) { return true; } return queryController.isQueryPageArchived(comment.getQueryPage()); }
[ "public", "boolean", "isQueryQuestionCommentArchived", "(", "QueryQuestionComment", "comment", ")", "{", "if", "(", "comment", "==", "null", "||", "comment", ".", "getArchived", "(", ")", ")", "{", "return", "true", ";", "}", "if", "(", "comment", ".", "getParentComment", "(", ")", "!=", "null", "&&", "isQueryQuestionCommentArchived", "(", "comment", ".", "getParentComment", "(", ")", ")", ")", "{", "return", "true", ";", "}", "if", "(", "comment", ".", "getQueryReply", "(", ")", ".", "getArchived", "(", ")", ")", "{", "return", "true", ";", "}", "return", "queryController", ".", "isQueryPageArchived", "(", "comment", ".", "getQueryPage", "(", ")", ")", ";", "}" ]
Returns whether query question comment is archived or not @param comment comment @return whether query question comment is archived or not
[ "Returns", "whether", "query", "question", "comment", "is", "archived", "or", "not" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/comments/QueryQuestionCommentController.java#L122-L136
144,378
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/comments/QueryQuestionCommentController.java
QueryQuestionCommentController.isPanelsComment
public boolean isPanelsComment(QueryQuestionComment comment, Panel panel) { Panel queryPanel = resourceController.getResourcePanel(comment.getQueryPage().getQuerySection().getQuery()); if (queryPanel == null || panel == null) { return false; } return queryPanel.getId().equals(panel.getId()); }
java
public boolean isPanelsComment(QueryQuestionComment comment, Panel panel) { Panel queryPanel = resourceController.getResourcePanel(comment.getQueryPage().getQuerySection().getQuery()); if (queryPanel == null || panel == null) { return false; } return queryPanel.getId().equals(panel.getId()); }
[ "public", "boolean", "isPanelsComment", "(", "QueryQuestionComment", "comment", ",", "Panel", "panel", ")", "{", "Panel", "queryPanel", "=", "resourceController", ".", "getResourcePanel", "(", "comment", ".", "getQueryPage", "(", ")", ".", "getQuerySection", "(", ")", ".", "getQuery", "(", ")", ")", ";", "if", "(", "queryPanel", "==", "null", "||", "panel", "==", "null", ")", "{", "return", "false", ";", "}", "return", "queryPanel", ".", "getId", "(", ")", ".", "equals", "(", "panel", ".", "getId", "(", ")", ")", ";", "}" ]
Returns whether comment belongs to given panel @param comment comment @param panel panel @return whether comment belongs to given panel
[ "Returns", "whether", "comment", "belongs", "to", "given", "panel" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/comments/QueryQuestionCommentController.java#L145-L152
144,379
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/query/thesis/AbstractScaleThesisQueryPageHandler.java
AbstractScaleThesisQueryPageHandler.synchronizeFieldCaption
protected void synchronizeFieldCaption(QueryPage queryPage, String fieldName, String fieldCaption) { QueryFieldDAO queryFieldDAO = new QueryFieldDAO(); QueryOptionField queryField = (QueryOptionField) queryFieldDAO.findByQueryPageAndName(queryPage, fieldName); if (queryField != null) queryFieldDAO.updateCaption(queryField, fieldCaption); }
java
protected void synchronizeFieldCaption(QueryPage queryPage, String fieldName, String fieldCaption) { QueryFieldDAO queryFieldDAO = new QueryFieldDAO(); QueryOptionField queryField = (QueryOptionField) queryFieldDAO.findByQueryPageAndName(queryPage, fieldName); if (queryField != null) queryFieldDAO.updateCaption(queryField, fieldCaption); }
[ "protected", "void", "synchronizeFieldCaption", "(", "QueryPage", "queryPage", ",", "String", "fieldName", ",", "String", "fieldCaption", ")", "{", "QueryFieldDAO", "queryFieldDAO", "=", "new", "QueryFieldDAO", "(", ")", ";", "QueryOptionField", "queryField", "=", "(", "QueryOptionField", ")", "queryFieldDAO", ".", "findByQueryPageAndName", "(", "queryPage", ",", "fieldName", ")", ";", "if", "(", "queryField", "!=", "null", ")", "queryFieldDAO", ".", "updateCaption", "(", "queryField", ",", "fieldCaption", ")", ";", "}" ]
Updates field caption if field can be found. Used only when query already contains replies. @param queryPage query page @param fieldName field name @param fieldCaption field caption
[ "Updates", "field", "caption", "if", "field", "can", "be", "found", ".", "Used", "only", "when", "query", "already", "contains", "replies", "." ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/query/thesis/AbstractScaleThesisQueryPageHandler.java#L113-L119
144,380
Metatavu/edelphi
edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/querydata/QueryQuestionCommentDAO.java
QueryQuestionCommentDAO.listByQueryPageAndStamp
public List<QueryQuestionComment> listByQueryPageAndStamp(QueryPage queryPage, PanelStamp stamp) { EntityManager entityManager = getEntityManager(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<QueryQuestionComment> criteria = criteriaBuilder.createQuery(QueryQuestionComment.class); Root<QueryQuestionComment> root = criteria.from(QueryQuestionComment.class); Join<QueryQuestionComment, QueryReply> qqJoin = root.join(QueryQuestionComment_.queryReply); criteria.select(root); criteria.where( criteriaBuilder.and( criteriaBuilder.equal(qqJoin.get(QueryReply_.stamp), stamp), criteriaBuilder.equal(root.get(QueryQuestionComment_.queryPage), queryPage), criteriaBuilder.equal(root.get(QueryQuestionComment_.archived), Boolean.FALSE) ) ); return entityManager.createQuery(criteria).getResultList(); }
java
public List<QueryQuestionComment> listByQueryPageAndStamp(QueryPage queryPage, PanelStamp stamp) { EntityManager entityManager = getEntityManager(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<QueryQuestionComment> criteria = criteriaBuilder.createQuery(QueryQuestionComment.class); Root<QueryQuestionComment> root = criteria.from(QueryQuestionComment.class); Join<QueryQuestionComment, QueryReply> qqJoin = root.join(QueryQuestionComment_.queryReply); criteria.select(root); criteria.where( criteriaBuilder.and( criteriaBuilder.equal(qqJoin.get(QueryReply_.stamp), stamp), criteriaBuilder.equal(root.get(QueryQuestionComment_.queryPage), queryPage), criteriaBuilder.equal(root.get(QueryQuestionComment_.archived), Boolean.FALSE) ) ); return entityManager.createQuery(criteria).getResultList(); }
[ "public", "List", "<", "QueryQuestionComment", ">", "listByQueryPageAndStamp", "(", "QueryPage", "queryPage", ",", "PanelStamp", "stamp", ")", "{", "EntityManager", "entityManager", "=", "getEntityManager", "(", ")", ";", "CriteriaBuilder", "criteriaBuilder", "=", "entityManager", ".", "getCriteriaBuilder", "(", ")", ";", "CriteriaQuery", "<", "QueryQuestionComment", ">", "criteria", "=", "criteriaBuilder", ".", "createQuery", "(", "QueryQuestionComment", ".", "class", ")", ";", "Root", "<", "QueryQuestionComment", ">", "root", "=", "criteria", ".", "from", "(", "QueryQuestionComment", ".", "class", ")", ";", "Join", "<", "QueryQuestionComment", ",", "QueryReply", ">", "qqJoin", "=", "root", ".", "join", "(", "QueryQuestionComment_", ".", "queryReply", ")", ";", "criteria", ".", "select", "(", "root", ")", ";", "criteria", ".", "where", "(", "criteriaBuilder", ".", "and", "(", "criteriaBuilder", ".", "equal", "(", "qqJoin", ".", "get", "(", "QueryReply_", ".", "stamp", ")", ",", "stamp", ")", ",", "criteriaBuilder", ".", "equal", "(", "root", ".", "get", "(", "QueryQuestionComment_", ".", "queryPage", ")", ",", "queryPage", ")", ",", "criteriaBuilder", ".", "equal", "(", "root", ".", "get", "(", "QueryQuestionComment_", ".", "archived", ")", ",", "Boolean", ".", "FALSE", ")", ")", ")", ";", "return", "entityManager", ".", "createQuery", "(", "criteria", ")", ".", "getResultList", "(", ")", ";", "}" ]
Lists all nonarchived comments left on the given query page in the given panel stamp. @param queryPage the comments' query page @param stamp the panel stamp @return a list of all nonarchived comments left on the given query page in the given panel stamp
[ "Lists", "all", "nonarchived", "comments", "left", "on", "the", "given", "query", "page", "in", "the", "given", "panel", "stamp", "." ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/querydata/QueryQuestionCommentDAO.java#L200-L217
144,381
Metatavu/edelphi
edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/querydata/QueryQuestionCommentDAO.java
QueryQuestionCommentDAO.listTreesByQueryPage
public Map<Long, List<QueryQuestionComment>> listTreesByQueryPage(QueryPage queryPage) { Map<Long, List<QueryQuestionComment>> result = new HashMap<>(); EntityManager entityManager = getEntityManager(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<QueryQuestionComment> criteria = criteriaBuilder.createQuery(QueryQuestionComment.class); Root<QueryQuestionComment> root = criteria.from(QueryQuestionComment.class); criteria.select(root); criteria.where( criteriaBuilder.and( criteriaBuilder.equal(root.get(QueryQuestionComment_.queryPage), queryPage), criteriaBuilder.equal(root.get(QueryQuestionComment_.archived), Boolean.FALSE), criteriaBuilder.isNotNull(root.get(QueryQuestionComment_.parentComment)) ) ); List<QueryQuestionComment> allChildren = entityManager.createQuery(criteria).getResultList(); for (QueryQuestionComment comment : allChildren) { Long parentCommentId = comment.getParentComment().getId(); List<QueryQuestionComment> children = result.get(parentCommentId); if (children == null) { children = new ArrayList<>(); result.put(parentCommentId, children); } children.add(comment); } return result; }
java
public Map<Long, List<QueryQuestionComment>> listTreesByQueryPage(QueryPage queryPage) { Map<Long, List<QueryQuestionComment>> result = new HashMap<>(); EntityManager entityManager = getEntityManager(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<QueryQuestionComment> criteria = criteriaBuilder.createQuery(QueryQuestionComment.class); Root<QueryQuestionComment> root = criteria.from(QueryQuestionComment.class); criteria.select(root); criteria.where( criteriaBuilder.and( criteriaBuilder.equal(root.get(QueryQuestionComment_.queryPage), queryPage), criteriaBuilder.equal(root.get(QueryQuestionComment_.archived), Boolean.FALSE), criteriaBuilder.isNotNull(root.get(QueryQuestionComment_.parentComment)) ) ); List<QueryQuestionComment> allChildren = entityManager.createQuery(criteria).getResultList(); for (QueryQuestionComment comment : allChildren) { Long parentCommentId = comment.getParentComment().getId(); List<QueryQuestionComment> children = result.get(parentCommentId); if (children == null) { children = new ArrayList<>(); result.put(parentCommentId, children); } children.add(comment); } return result; }
[ "public", "Map", "<", "Long", ",", "List", "<", "QueryQuestionComment", ">", ">", "listTreesByQueryPage", "(", "QueryPage", "queryPage", ")", "{", "Map", "<", "Long", ",", "List", "<", "QueryQuestionComment", ">", ">", "result", "=", "new", "HashMap", "<>", "(", ")", ";", "EntityManager", "entityManager", "=", "getEntityManager", "(", ")", ";", "CriteriaBuilder", "criteriaBuilder", "=", "entityManager", ".", "getCriteriaBuilder", "(", ")", ";", "CriteriaQuery", "<", "QueryQuestionComment", ">", "criteria", "=", "criteriaBuilder", ".", "createQuery", "(", "QueryQuestionComment", ".", "class", ")", ";", "Root", "<", "QueryQuestionComment", ">", "root", "=", "criteria", ".", "from", "(", "QueryQuestionComment", ".", "class", ")", ";", "criteria", ".", "select", "(", "root", ")", ";", "criteria", ".", "where", "(", "criteriaBuilder", ".", "and", "(", "criteriaBuilder", ".", "equal", "(", "root", ".", "get", "(", "QueryQuestionComment_", ".", "queryPage", ")", ",", "queryPage", ")", ",", "criteriaBuilder", ".", "equal", "(", "root", ".", "get", "(", "QueryQuestionComment_", ".", "archived", ")", ",", "Boolean", ".", "FALSE", ")", ",", "criteriaBuilder", ".", "isNotNull", "(", "root", ".", "get", "(", "QueryQuestionComment_", ".", "parentComment", ")", ")", ")", ")", ";", "List", "<", "QueryQuestionComment", ">", "allChildren", "=", "entityManager", ".", "createQuery", "(", "criteria", ")", ".", "getResultList", "(", ")", ";", "for", "(", "QueryQuestionComment", "comment", ":", "allChildren", ")", "{", "Long", "parentCommentId", "=", "comment", ".", "getParentComment", "(", ")", ".", "getId", "(", ")", ";", "List", "<", "QueryQuestionComment", ">", "children", "=", "result", ".", "get", "(", "parentCommentId", ")", ";", "if", "(", "children", "==", "null", ")", "{", "children", "=", "new", "ArrayList", "<>", "(", ")", ";", "result", ".", "put", "(", "parentCommentId", ",", "children", ")", ";", "}", "children", ".", "add", "(", "comment", ")", ";", "}", "return", "result", ";", "}" ]
Lists all non-root comments on page and orders them to map with parentComment.id as key and list of comments directly below parentComment as value. @param queryPage page where to list the comments from @return list of non-root comments on page and orders to mapped by parentComment.id
[ "Lists", "all", "non", "-", "root", "comments", "on", "page", "and", "orders", "them", "to", "map", "with", "parentComment", ".", "id", "as", "key", "and", "list", "of", "comments", "directly", "below", "parentComment", "as", "value", "." ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/querydata/QueryQuestionCommentDAO.java#L282-L314
144,382
Metatavu/edelphi
smvcj/src/main/java/fi/metatavu/edelphi/smvcj/dispatcher/Servlet.java
Servlet.service
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { if (sessionSynchronization) { String syncKey = getSyncKey(request); synchronized (getSyncObject(syncKey)) { try { doService(request, response); } finally { removeSyncObject(syncKey); } } } else { doService(request, response); } }
java
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { if (sessionSynchronization) { String syncKey = getSyncKey(request); synchronized (getSyncObject(syncKey)) { try { doService(request, response); } finally { removeSyncObject(syncKey); } } } else { doService(request, response); } }
[ "@", "Override", "protected", "void", "service", "(", "HttpServletRequest", "request", ",", "HttpServletResponse", "response", ")", "throws", "ServletException", ",", "java", ".", "io", ".", "IOException", "{", "if", "(", "sessionSynchronization", ")", "{", "String", "syncKey", "=", "getSyncKey", "(", "request", ")", ";", "synchronized", "(", "getSyncObject", "(", "syncKey", ")", ")", "{", "try", "{", "doService", "(", "request", ",", "response", ")", ";", "}", "finally", "{", "removeSyncObject", "(", "syncKey", ")", ";", "}", "}", "}", "else", "{", "doService", "(", "request", ",", "response", ")", ";", "}", "}" ]
Processes all application requests, delegating them to their corresponding page, binary and JSON controllers.
[ "Processes", "all", "application", "requests", "delegating", "them", "to", "their", "corresponding", "page", "binary", "and", "JSON", "controllers", "." ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/smvcj/src/main/java/fi/metatavu/edelphi/smvcj/dispatcher/Servlet.java#L81-L97
144,383
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/queries/QueryController.java
QueryController.isQueryPageArchived
public boolean isQueryPageArchived(QueryPage queryPage) { if (queryPage.getArchived()) { return true; } QuerySection querySection = queryPage.getQuerySection(); if (querySection.getArchived()) { return true; } return isQueryArchived(querySection.getQuery()); }
java
public boolean isQueryPageArchived(QueryPage queryPage) { if (queryPage.getArchived()) { return true; } QuerySection querySection = queryPage.getQuerySection(); if (querySection.getArchived()) { return true; } return isQueryArchived(querySection.getQuery()); }
[ "public", "boolean", "isQueryPageArchived", "(", "QueryPage", "queryPage", ")", "{", "if", "(", "queryPage", ".", "getArchived", "(", ")", ")", "{", "return", "true", ";", "}", "QuerySection", "querySection", "=", "queryPage", ".", "getQuerySection", "(", ")", ";", "if", "(", "querySection", ".", "getArchived", "(", ")", ")", "{", "return", "true", ";", "}", "return", "isQueryArchived", "(", "querySection", ".", "getQuery", "(", ")", ")", ";", "}" ]
Returns whether query page is archived or not @param queryPage query page @return whether query page is archived or not
[ "Returns", "whether", "query", "page", "is", "archived", "or", "not" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/queries/QueryController.java#L72-L83
144,384
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/queries/QueryController.java
QueryController.isQueryArchived
public boolean isQueryArchived(Query query) { if (query.getArchived()) { return true; } return resourceController.isFolderArchived(query.getParentFolder()); }
java
public boolean isQueryArchived(Query query) { if (query.getArchived()) { return true; } return resourceController.isFolderArchived(query.getParentFolder()); }
[ "public", "boolean", "isQueryArchived", "(", "Query", "query", ")", "{", "if", "(", "query", ".", "getArchived", "(", ")", ")", "{", "return", "true", ";", "}", "return", "resourceController", ".", "isFolderArchived", "(", "query", ".", "getParentFolder", "(", ")", ")", ";", "}" ]
Returns whether query is archived @param query query @return whether query is archived
[ "Returns", "whether", "query", "is", "archived" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/queries/QueryController.java#L91-L97
144,385
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/queries/QueryController.java
QueryController.isPanelsQuery
public boolean isPanelsQuery(Query query, Panel panel) { Panel queryPanel = resourceController.getResourcePanel(query); if (queryPanel == null || panel == null) { return false; } return queryPanel.getId().equals(panel.getId()); }
java
public boolean isPanelsQuery(Query query, Panel panel) { Panel queryPanel = resourceController.getResourcePanel(query); if (queryPanel == null || panel == null) { return false; } return queryPanel.getId().equals(panel.getId()); }
[ "public", "boolean", "isPanelsQuery", "(", "Query", "query", ",", "Panel", "panel", ")", "{", "Panel", "queryPanel", "=", "resourceController", ".", "getResourcePanel", "(", "query", ")", ";", "if", "(", "queryPanel", "==", "null", "||", "panel", "==", "null", ")", "{", "return", "false", ";", "}", "return", "queryPanel", ".", "getId", "(", ")", ".", "equals", "(", "panel", ".", "getId", "(", ")", ")", ";", "}" ]
Returns whether query belongs to given panel @param query query @param panel panel @return whether query belongs to given panel
[ "Returns", "whether", "query", "belongs", "to", "given", "panel" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/queries/QueryController.java#L106-L113
144,386
Metatavu/edelphi
edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/panels/PanelUserDAO.java
PanelUserDAO.create
public PanelUser create(Panel panel, User user, PanelUserRole role, PanelUserJoinType joinType, PanelStamp stamp, User creator) { Date now = new Date(); PanelUser panelUser = new PanelUser(); panelUser.setPanel(panel); panelUser.setUser(user); panelUser.setRole(role); panelUser.setJoinType(joinType); panelUser.setStamp(stamp); panelUser.setCreated(now); panelUser.setCreator(creator); panelUser.setLastModified(now); panelUser.setLastModifier(creator); panelUser.setArchived(Boolean.FALSE); return persist(panelUser); }
java
public PanelUser create(Panel panel, User user, PanelUserRole role, PanelUserJoinType joinType, PanelStamp stamp, User creator) { Date now = new Date(); PanelUser panelUser = new PanelUser(); panelUser.setPanel(panel); panelUser.setUser(user); panelUser.setRole(role); panelUser.setJoinType(joinType); panelUser.setStamp(stamp); panelUser.setCreated(now); panelUser.setCreator(creator); panelUser.setLastModified(now); panelUser.setLastModifier(creator); panelUser.setArchived(Boolean.FALSE); return persist(panelUser); }
[ "public", "PanelUser", "create", "(", "Panel", "panel", ",", "User", "user", ",", "PanelUserRole", "role", ",", "PanelUserJoinType", "joinType", ",", "PanelStamp", "stamp", ",", "User", "creator", ")", "{", "Date", "now", "=", "new", "Date", "(", ")", ";", "PanelUser", "panelUser", "=", "new", "PanelUser", "(", ")", ";", "panelUser", ".", "setPanel", "(", "panel", ")", ";", "panelUser", ".", "setUser", "(", "user", ")", ";", "panelUser", ".", "setRole", "(", "role", ")", ";", "panelUser", ".", "setJoinType", "(", "joinType", ")", ";", "panelUser", ".", "setStamp", "(", "stamp", ")", ";", "panelUser", ".", "setCreated", "(", "now", ")", ";", "panelUser", ".", "setCreator", "(", "creator", ")", ";", "panelUser", ".", "setLastModified", "(", "now", ")", ";", "panelUser", ".", "setLastModifier", "(", "creator", ")", ";", "panelUser", ".", "setArchived", "(", "Boolean", ".", "FALSE", ")", ";", "return", "persist", "(", "panelUser", ")", ";", "}" ]
Creates new panel user @param panel panel @param user user @param role user's role in panel @param joinType join type @param stamp panel stamp @param creator creator user @return new panelist
[ "Creates", "new", "panel", "user" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/panels/PanelUserDAO.java#L41-L57
144,387
Metatavu/edelphi
edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/panels/PanelUserDAO.java
PanelUserDAO.updateJoinType
public PanelUser updateJoinType(PanelUser panelUser, PanelUserJoinType joinType, User modifier) { panelUser.setJoinType(joinType); panelUser.setLastModified(new Date()); panelUser.setLastModifier(modifier); return persist(panelUser); }
java
public PanelUser updateJoinType(PanelUser panelUser, PanelUserJoinType joinType, User modifier) { panelUser.setJoinType(joinType); panelUser.setLastModified(new Date()); panelUser.setLastModifier(modifier); return persist(panelUser); }
[ "public", "PanelUser", "updateJoinType", "(", "PanelUser", "panelUser", ",", "PanelUserJoinType", "joinType", ",", "User", "modifier", ")", "{", "panelUser", ".", "setJoinType", "(", "joinType", ")", ";", "panelUser", ".", "setLastModified", "(", "new", "Date", "(", ")", ")", ";", "panelUser", ".", "setLastModifier", "(", "modifier", ")", ";", "return", "persist", "(", "panelUser", ")", ";", "}" ]
Updates panel user's join type @param panelUser panel user @param joinType new join type @param modifier modifier @return updated user
[ "Updates", "panel", "user", "s", "join", "type" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/panels/PanelUserDAO.java#L180-L186
144,388
Metatavu/edelphi
edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/panels/PanelUserDAO.java
PanelUserDAO.updateRole
public PanelUser updateRole(PanelUser panelUser, PanelUserRole panelUserRole, User modifier) { panelUser.setRole(panelUserRole); panelUser.setLastModified(new Date()); panelUser.setLastModifier(modifier); return persist(panelUser); }
java
public PanelUser updateRole(PanelUser panelUser, PanelUserRole panelUserRole, User modifier) { panelUser.setRole(panelUserRole); panelUser.setLastModified(new Date()); panelUser.setLastModifier(modifier); return persist(panelUser); }
[ "public", "PanelUser", "updateRole", "(", "PanelUser", "panelUser", ",", "PanelUserRole", "panelUserRole", ",", "User", "modifier", ")", "{", "panelUser", ".", "setRole", "(", "panelUserRole", ")", ";", "panelUser", ".", "setLastModified", "(", "new", "Date", "(", ")", ")", ";", "panelUser", ".", "setLastModifier", "(", "modifier", ")", ";", "return", "persist", "(", "panelUser", ")", ";", "}" ]
Updates panel user's role @param panelUser panel user @param panelUserRole new role @param modifier modifier @return updated user
[ "Updates", "panel", "user", "s", "role" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/panels/PanelUserDAO.java#L196-L202
144,389
Metatavu/edelphi
edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/panels/PanelUserDAO.java
PanelUserDAO.countByPanelStateUserAndRole
public Long countByPanelStateUserAndRole(User user, DelfoiAction action, PanelState state) { EntityManager entityManager = getEntityManager(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<Long> criteria = criteriaBuilder.createQuery(Long.class); Root<PanelUser> panelUserRoot = criteria.from(PanelUser.class); Root<PanelUserRoleAction> roleActionRoot = criteria.from(PanelUserRoleAction.class); Join<PanelUser, Panel> panelJoin = panelUserRoot.join(PanelUser_.panel); criteria.select(criteriaBuilder.countDistinct(panelJoin)); criteria.where( criteriaBuilder.and( criteriaBuilder.equal(panelJoin, roleActionRoot.get(PanelUserRoleAction_.panel)), criteriaBuilder.equal(roleActionRoot.get(PanelUserRoleAction_.delfoiAction), action), criteriaBuilder.equal(panelUserRoot.get(PanelUser_.role), roleActionRoot.get(PanelUserRoleAction_.userRole)), criteriaBuilder.equal(panelJoin.get(Panel_.state), state), criteriaBuilder.equal(panelUserRoot.get(PanelUser_.user), user), criteriaBuilder.equal(panelUserRoot.get(PanelUser_.archived), Boolean.FALSE), criteriaBuilder.equal(panelJoin.get(Panel_.archived), Boolean.FALSE) ) ); return entityManager.createQuery(criteria).getSingleResult(); }
java
public Long countByPanelStateUserAndRole(User user, DelfoiAction action, PanelState state) { EntityManager entityManager = getEntityManager(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<Long> criteria = criteriaBuilder.createQuery(Long.class); Root<PanelUser> panelUserRoot = criteria.from(PanelUser.class); Root<PanelUserRoleAction> roleActionRoot = criteria.from(PanelUserRoleAction.class); Join<PanelUser, Panel> panelJoin = panelUserRoot.join(PanelUser_.panel); criteria.select(criteriaBuilder.countDistinct(panelJoin)); criteria.where( criteriaBuilder.and( criteriaBuilder.equal(panelJoin, roleActionRoot.get(PanelUserRoleAction_.panel)), criteriaBuilder.equal(roleActionRoot.get(PanelUserRoleAction_.delfoiAction), action), criteriaBuilder.equal(panelUserRoot.get(PanelUser_.role), roleActionRoot.get(PanelUserRoleAction_.userRole)), criteriaBuilder.equal(panelJoin.get(Panel_.state), state), criteriaBuilder.equal(panelUserRoot.get(PanelUser_.user), user), criteriaBuilder.equal(panelUserRoot.get(PanelUser_.archived), Boolean.FALSE), criteriaBuilder.equal(panelJoin.get(Panel_.archived), Boolean.FALSE) ) ); return entityManager.createQuery(criteria).getSingleResult(); }
[ "public", "Long", "countByPanelStateUserAndRole", "(", "User", "user", ",", "DelfoiAction", "action", ",", "PanelState", "state", ")", "{", "EntityManager", "entityManager", "=", "getEntityManager", "(", ")", ";", "CriteriaBuilder", "criteriaBuilder", "=", "entityManager", ".", "getCriteriaBuilder", "(", ")", ";", "CriteriaQuery", "<", "Long", ">", "criteria", "=", "criteriaBuilder", ".", "createQuery", "(", "Long", ".", "class", ")", ";", "Root", "<", "PanelUser", ">", "panelUserRoot", "=", "criteria", ".", "from", "(", "PanelUser", ".", "class", ")", ";", "Root", "<", "PanelUserRoleAction", ">", "roleActionRoot", "=", "criteria", ".", "from", "(", "PanelUserRoleAction", ".", "class", ")", ";", "Join", "<", "PanelUser", ",", "Panel", ">", "panelJoin", "=", "panelUserRoot", ".", "join", "(", "PanelUser_", ".", "panel", ")", ";", "criteria", ".", "select", "(", "criteriaBuilder", ".", "countDistinct", "(", "panelJoin", ")", ")", ";", "criteria", ".", "where", "(", "criteriaBuilder", ".", "and", "(", "criteriaBuilder", ".", "equal", "(", "panelJoin", ",", "roleActionRoot", ".", "get", "(", "PanelUserRoleAction_", ".", "panel", ")", ")", ",", "criteriaBuilder", ".", "equal", "(", "roleActionRoot", ".", "get", "(", "PanelUserRoleAction_", ".", "delfoiAction", ")", ",", "action", ")", ",", "criteriaBuilder", ".", "equal", "(", "panelUserRoot", ".", "get", "(", "PanelUser_", ".", "role", ")", ",", "roleActionRoot", ".", "get", "(", "PanelUserRoleAction_", ".", "userRole", ")", ")", ",", "criteriaBuilder", ".", "equal", "(", "panelJoin", ".", "get", "(", "Panel_", ".", "state", ")", ",", "state", ")", ",", "criteriaBuilder", ".", "equal", "(", "panelUserRoot", ".", "get", "(", "PanelUser_", ".", "user", ")", ",", "user", ")", ",", "criteriaBuilder", ".", "equal", "(", "panelUserRoot", ".", "get", "(", "PanelUser_", ".", "archived", ")", ",", "Boolean", ".", "FALSE", ")", ",", "criteriaBuilder", ".", "equal", "(", "panelJoin", ".", "get", "(", "Panel_", ".", "archived", ")", ",", "Boolean", ".", "FALSE", ")", ")", ")", ";", "return", "entityManager", ".", "createQuery", "(", "criteria", ")", ".", "getSingleResult", "(", ")", ";", "}" ]
Returns count of panels in specific state where user has permission to perform specific action @param user user @param action action @param state panel state @return count of panels in specific state where user has permission to perform specific action
[ "Returns", "count", "of", "panels", "in", "specific", "state", "where", "user", "has", "permission", "to", "perform", "specific", "action" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/panels/PanelUserDAO.java#L260-L284
144,390
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/resources/ResourceController.java
ResourceController.getResourcePanel
public Panel getResourcePanel(Resource resource) { List<Folder> resourceFolders = new ArrayList<Folder>(); Resource current = resource; Folder folder = current instanceof Folder ? (Folder) current : current == null ? null : current.getParentFolder(); while (folder != null) { resourceFolders.add(folder); current = folder; folder = current.getParentFolder(); } Folder panelFolder = null; int panelIndex = resourceFolders.size() - 2; if (panelIndex >= 0) { panelFolder = resourceFolders.get(panelIndex); } if (panelFolder != null) { return panelDAO.findByRootFolder(panelFolder); } return null; }
java
public Panel getResourcePanel(Resource resource) { List<Folder> resourceFolders = new ArrayList<Folder>(); Resource current = resource; Folder folder = current instanceof Folder ? (Folder) current : current == null ? null : current.getParentFolder(); while (folder != null) { resourceFolders.add(folder); current = folder; folder = current.getParentFolder(); } Folder panelFolder = null; int panelIndex = resourceFolders.size() - 2; if (panelIndex >= 0) { panelFolder = resourceFolders.get(panelIndex); } if (panelFolder != null) { return panelDAO.findByRootFolder(panelFolder); } return null; }
[ "public", "Panel", "getResourcePanel", "(", "Resource", "resource", ")", "{", "List", "<", "Folder", ">", "resourceFolders", "=", "new", "ArrayList", "<", "Folder", ">", "(", ")", ";", "Resource", "current", "=", "resource", ";", "Folder", "folder", "=", "current", "instanceof", "Folder", "?", "(", "Folder", ")", "current", ":", "current", "==", "null", "?", "null", ":", "current", ".", "getParentFolder", "(", ")", ";", "while", "(", "folder", "!=", "null", ")", "{", "resourceFolders", ".", "add", "(", "folder", ")", ";", "current", "=", "folder", ";", "folder", "=", "current", ".", "getParentFolder", "(", ")", ";", "}", "Folder", "panelFolder", "=", "null", ";", "int", "panelIndex", "=", "resourceFolders", ".", "size", "(", ")", "-", "2", ";", "if", "(", "panelIndex", ">=", "0", ")", "{", "panelFolder", "=", "resourceFolders", ".", "get", "(", "panelIndex", ")", ";", "}", "if", "(", "panelFolder", "!=", "null", ")", "{", "return", "panelDAO", ".", "findByRootFolder", "(", "panelFolder", ")", ";", "}", "return", "null", ";", "}" ]
Returns a panel for given resource @param resource resource @return panel or null if not found
[ "Returns", "a", "panel", "for", "given", "resource" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/resources/ResourceController.java#L34-L56
144,391
Metatavu/edelphi
rest/src/main/java/fi/metatavu/edelphi/resources/ResourceController.java
ResourceController.isFolderArchived
public boolean isFolderArchived(Folder folder) { if (folder.getArchived()) { return true; } Folder parentFolder = folder.getParentFolder(); if (parentFolder != null) { return isFolderArchived(parentFolder); } else { Panel panel = panelDAO.findByRootFolder(parentFolder); if (panel != null) { return panelController.isPanelArchived(panel); } } return false; }
java
public boolean isFolderArchived(Folder folder) { if (folder.getArchived()) { return true; } Folder parentFolder = folder.getParentFolder(); if (parentFolder != null) { return isFolderArchived(parentFolder); } else { Panel panel = panelDAO.findByRootFolder(parentFolder); if (panel != null) { return panelController.isPanelArchived(panel); } } return false; }
[ "public", "boolean", "isFolderArchived", "(", "Folder", "folder", ")", "{", "if", "(", "folder", ".", "getArchived", "(", ")", ")", "{", "return", "true", ";", "}", "Folder", "parentFolder", "=", "folder", ".", "getParentFolder", "(", ")", ";", "if", "(", "parentFolder", "!=", "null", ")", "{", "return", "isFolderArchived", "(", "parentFolder", ")", ";", "}", "else", "{", "Panel", "panel", "=", "panelDAO", ".", "findByRootFolder", "(", "parentFolder", ")", ";", "if", "(", "panel", "!=", "null", ")", "{", "return", "panelController", ".", "isPanelArchived", "(", "panel", ")", ";", "}", "}", "return", "false", ";", "}" ]
Returns whether folder is archived @param folder folder @return whether folder is archived
[ "Returns", "whether", "folder", "is", "archived" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/rest/src/main/java/fi/metatavu/edelphi/resources/ResourceController.java#L64-L80
144,392
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/auth/AuthenticationProviderFactory.java
AuthenticationProviderFactory.registerAuthenticationProvider
public void registerAuthenticationProvider(Class<? extends AuthenticationProvider> providerClass) { AuthenticationProvider provider = instantiateProvider(providerClass); authenticationProviders.put(provider.getName(), providerClass); credentialAuths.put(provider.getName(), provider.requiresCredentials()); }
java
public void registerAuthenticationProvider(Class<? extends AuthenticationProvider> providerClass) { AuthenticationProvider provider = instantiateProvider(providerClass); authenticationProviders.put(provider.getName(), providerClass); credentialAuths.put(provider.getName(), provider.requiresCredentials()); }
[ "public", "void", "registerAuthenticationProvider", "(", "Class", "<", "?", "extends", "AuthenticationProvider", ">", "providerClass", ")", "{", "AuthenticationProvider", "provider", "=", "instantiateProvider", "(", "providerClass", ")", ";", "authenticationProviders", ".", "put", "(", "provider", ".", "getName", "(", ")", ",", "providerClass", ")", ";", "credentialAuths", ".", "put", "(", "provider", ".", "getName", "(", ")", ",", "provider", ".", "requiresCredentials", "(", ")", ")", ";", "}" ]
Registers an authentication provider to this class. @param providerClass The authentication provider to be registered
[ "Registers", "an", "authentication", "provider", "to", "this", "class", "." ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/auth/AuthenticationProviderFactory.java#L44-L48
144,393
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/taglib/chartutil/ChartWebHelper.java
ChartWebHelper.isChartInRuntime
public static boolean isChartInRuntime(Chart cm) { if (cm instanceof ChartWithAxes) { Axis bAxis = ((ChartWithAxes) cm).getAxes().get(0); EList<Axis> oAxes = bAxis.getAssociatedAxes(); for (int i = 0; i < oAxes.size(); i++) { Axis oAxis = oAxes.get(i); EList<SeriesDefinition> oSeries = oAxis.getSeriesDefinitions(); for (int j = 0; j < oSeries.size(); j++) { SeriesDefinition sd = oSeries.get(j); if (sd.getRunTimeSeries().size() > 0) { return true; } } } } else if (cm instanceof ChartWithoutAxes) { SeriesDefinition bsd = ((ChartWithoutAxes) cm).getSeriesDefinitions().get(0); EList<SeriesDefinition> osds = bsd.getSeriesDefinitions(); for (int i = 0; i < osds.size(); i++) { SeriesDefinition osd = osds.get(i); if (osd.getRunTimeSeries().size() > 0) { return true; } } } return false; }
java
public static boolean isChartInRuntime(Chart cm) { if (cm instanceof ChartWithAxes) { Axis bAxis = ((ChartWithAxes) cm).getAxes().get(0); EList<Axis> oAxes = bAxis.getAssociatedAxes(); for (int i = 0; i < oAxes.size(); i++) { Axis oAxis = oAxes.get(i); EList<SeriesDefinition> oSeries = oAxis.getSeriesDefinitions(); for (int j = 0; j < oSeries.size(); j++) { SeriesDefinition sd = oSeries.get(j); if (sd.getRunTimeSeries().size() > 0) { return true; } } } } else if (cm instanceof ChartWithoutAxes) { SeriesDefinition bsd = ((ChartWithoutAxes) cm).getSeriesDefinitions().get(0); EList<SeriesDefinition> osds = bsd.getSeriesDefinitions(); for (int i = 0; i < osds.size(); i++) { SeriesDefinition osd = osds.get(i); if (osd.getRunTimeSeries().size() > 0) { return true; } } } return false; }
[ "public", "static", "boolean", "isChartInRuntime", "(", "Chart", "cm", ")", "{", "if", "(", "cm", "instanceof", "ChartWithAxes", ")", "{", "Axis", "bAxis", "=", "(", "(", "ChartWithAxes", ")", "cm", ")", ".", "getAxes", "(", ")", ".", "get", "(", "0", ")", ";", "EList", "<", "Axis", ">", "oAxes", "=", "bAxis", ".", "getAssociatedAxes", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "oAxes", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Axis", "oAxis", "=", "oAxes", ".", "get", "(", "i", ")", ";", "EList", "<", "SeriesDefinition", ">", "oSeries", "=", "oAxis", ".", "getSeriesDefinitions", "(", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "oSeries", ".", "size", "(", ")", ";", "j", "++", ")", "{", "SeriesDefinition", "sd", "=", "oSeries", ".", "get", "(", "j", ")", ";", "if", "(", "sd", ".", "getRunTimeSeries", "(", ")", ".", "size", "(", ")", ">", "0", ")", "{", "return", "true", ";", "}", "}", "}", "}", "else", "if", "(", "cm", "instanceof", "ChartWithoutAxes", ")", "{", "SeriesDefinition", "bsd", "=", "(", "(", "ChartWithoutAxes", ")", "cm", ")", ".", "getSeriesDefinitions", "(", ")", ".", "get", "(", "0", ")", ";", "EList", "<", "SeriesDefinition", ">", "osds", "=", "bsd", ".", "getSeriesDefinitions", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "osds", ".", "size", "(", ")", ";", "i", "++", ")", "{", "SeriesDefinition", "osd", "=", "osds", ".", "get", "(", "i", ")", ";", "if", "(", "osd", ".", "getRunTimeSeries", "(", ")", ".", "size", "(", ")", ">", "0", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Checks if current chart has runtime data sets. @param cm chart model @return has runtime data or not
[ "Checks", "if", "current", "chart", "has", "runtime", "data", "sets", "." ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/taglib/chartutil/ChartWebHelper.java#L51-L76
144,394
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/utils/QueryDataUtils.java
QueryDataUtils.exportQueryCommentsAsCsv
public static byte[] exportQueryCommentsAsCsv(Locale locale, ReplierExportStrategy replierExportStrategy, List<QueryReply> replies, Query query, PanelStamp stamp) throws IOException { QueryPageDAO queryPageDAO = new QueryPageDAO(); List<QueryPage> queryPages = queryPageDAO.listByQuery(query); Collections.sort(queryPages, new QueryPageNumberComparator()); String[] columnHeaders = new String[] { getReplierExportStrategyLabel(locale, replierExportStrategy), Messages.getInstance().getText(locale, "panelAdmin.query.export.csvCommentAnswerColumn"), Messages.getInstance().getText(locale, "panelAdmin.query.export.csvCommentCommentColumn"), Messages.getInstance().getText(locale, "panelAdmin.query.export.csvCommentReplyColumn"), }; List<String[]> rows = new ArrayList<>(); for (QueryPage queryPage : queryPages) { List<String[]> pageRows = exportQueryPageCommentsAsCsv(replierExportStrategy, replies, stamp, queryPage); if (!pageRows.isEmpty()) { rows.add(new String[] { "", "", "", "" }); rows.add(new String[] { queryPage.getTitle(), "", "", "" }); rows.add(new String[] { "", "", "", "" }); rows.addAll(pageRows); } } return writeCsv(columnHeaders, rows); }
java
public static byte[] exportQueryCommentsAsCsv(Locale locale, ReplierExportStrategy replierExportStrategy, List<QueryReply> replies, Query query, PanelStamp stamp) throws IOException { QueryPageDAO queryPageDAO = new QueryPageDAO(); List<QueryPage> queryPages = queryPageDAO.listByQuery(query); Collections.sort(queryPages, new QueryPageNumberComparator()); String[] columnHeaders = new String[] { getReplierExportStrategyLabel(locale, replierExportStrategy), Messages.getInstance().getText(locale, "panelAdmin.query.export.csvCommentAnswerColumn"), Messages.getInstance().getText(locale, "panelAdmin.query.export.csvCommentCommentColumn"), Messages.getInstance().getText(locale, "panelAdmin.query.export.csvCommentReplyColumn"), }; List<String[]> rows = new ArrayList<>(); for (QueryPage queryPage : queryPages) { List<String[]> pageRows = exportQueryPageCommentsAsCsv(replierExportStrategy, replies, stamp, queryPage); if (!pageRows.isEmpty()) { rows.add(new String[] { "", "", "", "" }); rows.add(new String[] { queryPage.getTitle(), "", "", "" }); rows.add(new String[] { "", "", "", "" }); rows.addAll(pageRows); } } return writeCsv(columnHeaders, rows); }
[ "public", "static", "byte", "[", "]", "exportQueryCommentsAsCsv", "(", "Locale", "locale", ",", "ReplierExportStrategy", "replierExportStrategy", ",", "List", "<", "QueryReply", ">", "replies", ",", "Query", "query", ",", "PanelStamp", "stamp", ")", "throws", "IOException", "{", "QueryPageDAO", "queryPageDAO", "=", "new", "QueryPageDAO", "(", ")", ";", "List", "<", "QueryPage", ">", "queryPages", "=", "queryPageDAO", ".", "listByQuery", "(", "query", ")", ";", "Collections", ".", "sort", "(", "queryPages", ",", "new", "QueryPageNumberComparator", "(", ")", ")", ";", "String", "[", "]", "columnHeaders", "=", "new", "String", "[", "]", "{", "getReplierExportStrategyLabel", "(", "locale", ",", "replierExportStrategy", ")", ",", "Messages", ".", "getInstance", "(", ")", ".", "getText", "(", "locale", ",", "\"panelAdmin.query.export.csvCommentAnswerColumn\"", ")", ",", "Messages", ".", "getInstance", "(", ")", ".", "getText", "(", "locale", ",", "\"panelAdmin.query.export.csvCommentCommentColumn\"", ")", ",", "Messages", ".", "getInstance", "(", ")", ".", "getText", "(", "locale", ",", "\"panelAdmin.query.export.csvCommentReplyColumn\"", ")", ",", "}", ";", "List", "<", "String", "[", "]", ">", "rows", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "QueryPage", "queryPage", ":", "queryPages", ")", "{", "List", "<", "String", "[", "]", ">", "pageRows", "=", "exportQueryPageCommentsAsCsv", "(", "replierExportStrategy", ",", "replies", ",", "stamp", ",", "queryPage", ")", ";", "if", "(", "!", "pageRows", ".", "isEmpty", "(", ")", ")", "{", "rows", ".", "add", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"\"", ",", "\"\"", ",", "\"\"", "}", ")", ";", "rows", ".", "add", "(", "new", "String", "[", "]", "{", "queryPage", ".", "getTitle", "(", ")", ",", "\"\"", ",", "\"\"", ",", "\"\"", "}", ")", ";", "rows", ".", "add", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"\"", ",", "\"\"", ",", "\"\"", "}", ")", ";", "rows", ".", "addAll", "(", "pageRows", ")", ";", "}", "}", "return", "writeCsv", "(", "columnHeaders", ",", "rows", ")", ";", "}" ]
Export query comments into CSV byte array @param locale locale @param replierExportStrategy replies export strategy @param replies replies to be exported @param query query @param stamp stamp @return query comments in CSV byte array @throws IOException throws IOException when CSV writing fails
[ "Export", "query", "comments", "into", "CSV", "byte", "array" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/utils/QueryDataUtils.java#L121-L148
144,395
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/utils/QueryDataUtils.java
QueryDataUtils.exportQueryPageCommentsAsCsv
private static List<String[]> exportQueryPageCommentsAsCsv(ReplierExportStrategy replierExportStrategy, List<QueryReply> replies, PanelStamp stamp, QueryPage queryPage) { QueryPageHandler queryPageHandler = QueryPageHandlerFactory.getInstance().buildPageHandler(queryPage.getPageType()); if (queryPageHandler != null) { ReportPageCommentProcessor processor = queryPageHandler.exportComments(queryPage, stamp, replies); if (processor != null) { return exportQueryPageCommentsAsCsv(replierExportStrategy, queryPage, processor); } } return Collections.emptyList(); }
java
private static List<String[]> exportQueryPageCommentsAsCsv(ReplierExportStrategy replierExportStrategy, List<QueryReply> replies, PanelStamp stamp, QueryPage queryPage) { QueryPageHandler queryPageHandler = QueryPageHandlerFactory.getInstance().buildPageHandler(queryPage.getPageType()); if (queryPageHandler != null) { ReportPageCommentProcessor processor = queryPageHandler.exportComments(queryPage, stamp, replies); if (processor != null) { return exportQueryPageCommentsAsCsv(replierExportStrategy, queryPage, processor); } } return Collections.emptyList(); }
[ "private", "static", "List", "<", "String", "[", "]", ">", "exportQueryPageCommentsAsCsv", "(", "ReplierExportStrategy", "replierExportStrategy", ",", "List", "<", "QueryReply", ">", "replies", ",", "PanelStamp", "stamp", ",", "QueryPage", "queryPage", ")", "{", "QueryPageHandler", "queryPageHandler", "=", "QueryPageHandlerFactory", ".", "getInstance", "(", ")", ".", "buildPageHandler", "(", "queryPage", ".", "getPageType", "(", ")", ")", ";", "if", "(", "queryPageHandler", "!=", "null", ")", "{", "ReportPageCommentProcessor", "processor", "=", "queryPageHandler", ".", "exportComments", "(", "queryPage", ",", "stamp", ",", "replies", ")", ";", "if", "(", "processor", "!=", "null", ")", "{", "return", "exportQueryPageCommentsAsCsv", "(", "replierExportStrategy", ",", "queryPage", ",", "processor", ")", ";", "}", "}", "return", "Collections", ".", "emptyList", "(", ")", ";", "}" ]
Exports single query page into CSV rows @param replierExportStrategy replier export strategy @param replies replies to be exported @param stamp stamp @param queryPage query page to be exported @return CSV rows
[ "Exports", "single", "query", "page", "into", "CSV", "rows" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/utils/QueryDataUtils.java#L189-L199
144,396
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/utils/QueryDataUtils.java
QueryDataUtils.exportQueryPageCommentsAsCsv
private static List<String[]> exportQueryPageCommentsAsCsv(ReplierExportStrategy replierExportStrategy, QueryPage queryPage, ReportPageCommentProcessor processor) { QueryQuestionCommentDAO queryQuestionCommentDAO = new QueryQuestionCommentDAO(); List<String[]> rows = new ArrayList<>(); processor.processComments(); List<QueryQuestionComment> rootComments = processor.getRootComments(); if (rootComments != null && !rootComments.isEmpty()) { Map<Long, List<QueryQuestionComment>> childCommentMap = queryQuestionCommentDAO.listTreesByQueryPage(queryPage); for (QueryQuestionComment rootComment : rootComments) { String rootUser = getReplierExportStrategyValue(replierExportStrategy, rootComment.getQueryReply()); String rootLabel = processor.getCommentLabel(rootComment.getId()); rows.add(new String[] { rootUser, rootLabel, rootComment.getComment(), "" }); List<QueryQuestionComment> childComments = childCommentMap.get(rootComment.getId()); if (childComments != null) { childComments.forEach(childComment -> { String childUser = getReplierExportStrategyValue(replierExportStrategy, childComment.getQueryReply()); rows.add(new String[] { childUser, "", "", childComment.getComment() }); }); } } } return rows; }
java
private static List<String[]> exportQueryPageCommentsAsCsv(ReplierExportStrategy replierExportStrategy, QueryPage queryPage, ReportPageCommentProcessor processor) { QueryQuestionCommentDAO queryQuestionCommentDAO = new QueryQuestionCommentDAO(); List<String[]> rows = new ArrayList<>(); processor.processComments(); List<QueryQuestionComment> rootComments = processor.getRootComments(); if (rootComments != null && !rootComments.isEmpty()) { Map<Long, List<QueryQuestionComment>> childCommentMap = queryQuestionCommentDAO.listTreesByQueryPage(queryPage); for (QueryQuestionComment rootComment : rootComments) { String rootUser = getReplierExportStrategyValue(replierExportStrategy, rootComment.getQueryReply()); String rootLabel = processor.getCommentLabel(rootComment.getId()); rows.add(new String[] { rootUser, rootLabel, rootComment.getComment(), "" }); List<QueryQuestionComment> childComments = childCommentMap.get(rootComment.getId()); if (childComments != null) { childComments.forEach(childComment -> { String childUser = getReplierExportStrategyValue(replierExportStrategy, childComment.getQueryReply()); rows.add(new String[] { childUser, "", "", childComment.getComment() }); }); } } } return rows; }
[ "private", "static", "List", "<", "String", "[", "]", ">", "exportQueryPageCommentsAsCsv", "(", "ReplierExportStrategy", "replierExportStrategy", ",", "QueryPage", "queryPage", ",", "ReportPageCommentProcessor", "processor", ")", "{", "QueryQuestionCommentDAO", "queryQuestionCommentDAO", "=", "new", "QueryQuestionCommentDAO", "(", ")", ";", "List", "<", "String", "[", "]", ">", "rows", "=", "new", "ArrayList", "<>", "(", ")", ";", "processor", ".", "processComments", "(", ")", ";", "List", "<", "QueryQuestionComment", ">", "rootComments", "=", "processor", ".", "getRootComments", "(", ")", ";", "if", "(", "rootComments", "!=", "null", "&&", "!", "rootComments", ".", "isEmpty", "(", ")", ")", "{", "Map", "<", "Long", ",", "List", "<", "QueryQuestionComment", ">", ">", "childCommentMap", "=", "queryQuestionCommentDAO", ".", "listTreesByQueryPage", "(", "queryPage", ")", ";", "for", "(", "QueryQuestionComment", "rootComment", ":", "rootComments", ")", "{", "String", "rootUser", "=", "getReplierExportStrategyValue", "(", "replierExportStrategy", ",", "rootComment", ".", "getQueryReply", "(", ")", ")", ";", "String", "rootLabel", "=", "processor", ".", "getCommentLabel", "(", "rootComment", ".", "getId", "(", ")", ")", ";", "rows", ".", "add", "(", "new", "String", "[", "]", "{", "rootUser", ",", "rootLabel", ",", "rootComment", ".", "getComment", "(", ")", ",", "\"\"", "}", ")", ";", "List", "<", "QueryQuestionComment", ">", "childComments", "=", "childCommentMap", ".", "get", "(", "rootComment", ".", "getId", "(", ")", ")", ";", "if", "(", "childComments", "!=", "null", ")", "{", "childComments", ".", "forEach", "(", "childComment", "->", "{", "String", "childUser", "=", "getReplierExportStrategyValue", "(", "replierExportStrategy", ",", "childComment", ".", "getQueryReply", "(", ")", ")", ";", "rows", ".", "add", "(", "new", "String", "[", "]", "{", "childUser", ",", "\"\"", ",", "\"\"", ",", "childComment", ".", "getComment", "(", ")", "}", ")", ";", "}", ")", ";", "}", "}", "}", "return", "rows", ";", "}" ]
Exports single query page into CSV rows using comment processor @param replierExportStrategy replier export strategy @param queryPage query page to be exported @param processor comment processor @return CSV rows
[ "Exports", "single", "query", "page", "into", "CSV", "rows", "using", "comment", "processor" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/utils/QueryDataUtils.java#L209-L234
144,397
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/utils/QueryDataUtils.java
QueryDataUtils.getReplierExportStrategyLabel
private static String getReplierExportStrategyLabel(Locale locale, ReplierExportStrategy replierExportStrategy) { switch (replierExportStrategy) { case NONE: break; case HASH: return Messages.getInstance().getText(locale, "panelAdmin.query.export.csvReplierIdColumn"); case NAME: return Messages.getInstance().getText(locale, "panelAdmin.query.export.csvReplierNameColumn"); case EMAIL: return Messages.getInstance().getText(locale, "panelAdmin.query.export.csvReplierEmailColumn"); } return null; }
java
private static String getReplierExportStrategyLabel(Locale locale, ReplierExportStrategy replierExportStrategy) { switch (replierExportStrategy) { case NONE: break; case HASH: return Messages.getInstance().getText(locale, "panelAdmin.query.export.csvReplierIdColumn"); case NAME: return Messages.getInstance().getText(locale, "panelAdmin.query.export.csvReplierNameColumn"); case EMAIL: return Messages.getInstance().getText(locale, "panelAdmin.query.export.csvReplierEmailColumn"); } return null; }
[ "private", "static", "String", "getReplierExportStrategyLabel", "(", "Locale", "locale", ",", "ReplierExportStrategy", "replierExportStrategy", ")", "{", "switch", "(", "replierExportStrategy", ")", "{", "case", "NONE", ":", "break", ";", "case", "HASH", ":", "return", "Messages", ".", "getInstance", "(", ")", ".", "getText", "(", "locale", ",", "\"panelAdmin.query.export.csvReplierIdColumn\"", ")", ";", "case", "NAME", ":", "return", "Messages", ".", "getInstance", "(", ")", ".", "getText", "(", "locale", ",", "\"panelAdmin.query.export.csvReplierNameColumn\"", ")", ";", "case", "EMAIL", ":", "return", "Messages", ".", "getInstance", "(", ")", ".", "getText", "(", "locale", ",", "\"panelAdmin.query.export.csvReplierEmailColumn\"", ")", ";", "}", "return", "null", ";", "}" ]
Returns label for given replier export strategy @param locale locale @param replierExportStrategy replier export strategy @return label
[ "Returns", "label", "for", "given", "replier", "export", "strategy" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/utils/QueryDataUtils.java#L279-L292
144,398
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/utils/QueryDataUtils.java
QueryDataUtils.getReplierExportStrategyValue
private static String getReplierExportStrategyValue(ReplierExportStrategy replierExportStrategy, QueryReply queryReply) { if (queryReply != null) { User user = queryReply.getUser(); if (user != null) { switch (replierExportStrategy) { case NONE: break; case HASH: return RequestUtils.md5EncodeString(String.valueOf(user.getId())); case NAME: return user.getFullName(true, false); case EMAIL: return user.getDefaultEmailAsString(); } } } return "-"; }
java
private static String getReplierExportStrategyValue(ReplierExportStrategy replierExportStrategy, QueryReply queryReply) { if (queryReply != null) { User user = queryReply.getUser(); if (user != null) { switch (replierExportStrategy) { case NONE: break; case HASH: return RequestUtils.md5EncodeString(String.valueOf(user.getId())); case NAME: return user.getFullName(true, false); case EMAIL: return user.getDefaultEmailAsString(); } } } return "-"; }
[ "private", "static", "String", "getReplierExportStrategyValue", "(", "ReplierExportStrategy", "replierExportStrategy", ",", "QueryReply", "queryReply", ")", "{", "if", "(", "queryReply", "!=", "null", ")", "{", "User", "user", "=", "queryReply", ".", "getUser", "(", ")", ";", "if", "(", "user", "!=", "null", ")", "{", "switch", "(", "replierExportStrategy", ")", "{", "case", "NONE", ":", "break", ";", "case", "HASH", ":", "return", "RequestUtils", ".", "md5EncodeString", "(", "String", ".", "valueOf", "(", "user", ".", "getId", "(", ")", ")", ")", ";", "case", "NAME", ":", "return", "user", ".", "getFullName", "(", "true", ",", "false", ")", ";", "case", "EMAIL", ":", "return", "user", ".", "getDefaultEmailAsString", "(", ")", ";", "}", "}", "}", "return", "\"-\"", ";", "}" ]
Returns user identifier for given replier export strategy @param replierExportStrategy replier export strategy @param queryReply reply @return user identifier
[ "Returns", "user", "identifier", "for", "given", "replier", "export", "strategy" ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/utils/QueryDataUtils.java#L301-L319
144,399
Metatavu/edelphi
edelphi/src/main/java/fi/metatavu/edelphi/utils/QueryUtils.java
QueryUtils.appendQueryPageComments
public static void appendQueryPageComments(RequestContext requestContext, QueryPage queryPage) { QueryQuestionCommentDAO queryQuestionCommentDAO = new QueryQuestionCommentDAO(); PanelStamp activeStamp = RequestUtils.getActiveStamp(requestContext); List<QueryQuestionComment> rootComments = queryQuestionCommentDAO.listRootCommentsByQueryPageAndStampOrderByCreated(queryPage, activeStamp); Map<Long, List<QueryQuestionComment>> childComments = queryQuestionCommentDAO.listTreesByQueryPageAndStampOrderByCreated(queryPage, activeStamp); QueryUtils.appendQueryPageRootComments(requestContext, queryPage.getId(), rootComments); QueryUtils.appendQueryPageChildComments(requestContext, childComments); int commentCount = rootComments.size(); for (Object key : childComments.keySet()) { List<QueryQuestionComment> childCommentList = childComments.get(key); if (childCommentList != null) commentCount += childCommentList.size(); } requestContext.getRequest().setAttribute("queryPageCommentCount", commentCount); }
java
public static void appendQueryPageComments(RequestContext requestContext, QueryPage queryPage) { QueryQuestionCommentDAO queryQuestionCommentDAO = new QueryQuestionCommentDAO(); PanelStamp activeStamp = RequestUtils.getActiveStamp(requestContext); List<QueryQuestionComment> rootComments = queryQuestionCommentDAO.listRootCommentsByQueryPageAndStampOrderByCreated(queryPage, activeStamp); Map<Long, List<QueryQuestionComment>> childComments = queryQuestionCommentDAO.listTreesByQueryPageAndStampOrderByCreated(queryPage, activeStamp); QueryUtils.appendQueryPageRootComments(requestContext, queryPage.getId(), rootComments); QueryUtils.appendQueryPageChildComments(requestContext, childComments); int commentCount = rootComments.size(); for (Object key : childComments.keySet()) { List<QueryQuestionComment> childCommentList = childComments.get(key); if (childCommentList != null) commentCount += childCommentList.size(); } requestContext.getRequest().setAttribute("queryPageCommentCount", commentCount); }
[ "public", "static", "void", "appendQueryPageComments", "(", "RequestContext", "requestContext", ",", "QueryPage", "queryPage", ")", "{", "QueryQuestionCommentDAO", "queryQuestionCommentDAO", "=", "new", "QueryQuestionCommentDAO", "(", ")", ";", "PanelStamp", "activeStamp", "=", "RequestUtils", ".", "getActiveStamp", "(", "requestContext", ")", ";", "List", "<", "QueryQuestionComment", ">", "rootComments", "=", "queryQuestionCommentDAO", ".", "listRootCommentsByQueryPageAndStampOrderByCreated", "(", "queryPage", ",", "activeStamp", ")", ";", "Map", "<", "Long", ",", "List", "<", "QueryQuestionComment", ">", ">", "childComments", "=", "queryQuestionCommentDAO", ".", "listTreesByQueryPageAndStampOrderByCreated", "(", "queryPage", ",", "activeStamp", ")", ";", "QueryUtils", ".", "appendQueryPageRootComments", "(", "requestContext", ",", "queryPage", ".", "getId", "(", ")", ",", "rootComments", ")", ";", "QueryUtils", ".", "appendQueryPageChildComments", "(", "requestContext", ",", "childComments", ")", ";", "int", "commentCount", "=", "rootComments", ".", "size", "(", ")", ";", "for", "(", "Object", "key", ":", "childComments", ".", "keySet", "(", ")", ")", "{", "List", "<", "QueryQuestionComment", ">", "childCommentList", "=", "childComments", ".", "get", "(", "key", ")", ";", "if", "(", "childCommentList", "!=", "null", ")", "commentCount", "+=", "childCommentList", ".", "size", "(", ")", ";", "}", "requestContext", ".", "getRequest", "(", ")", ".", "setAttribute", "(", "\"queryPageCommentCount\"", ",", "commentCount", ")", ";", "}" ]
Loads the whole comment tree and appends it to requestContext for JSP to read. @param requestContext Smvcj request context @param queryPage query page
[ "Loads", "the", "whole", "comment", "tree", "and", "appends", "it", "to", "requestContext", "for", "JSP", "to", "read", "." ]
d91a0b54f954b33b4ee674a1bdf03612d76c3305
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/utils/QueryUtils.java#L137-L155