list of vaadin's special path variables #JavaScript(value = { "vaadin://...", "???://..." } - java

I try to add js file to output html code in vaadin7.4.13+maven project.
I know that it is possible to use vaadin://... protocol which is translated to /VAADIN/ directory.
Now I know that this isn't the only one trick it can be used there because I've seen some other protocols being used in #JavaScript annotation but I cannot recall them. Please help me with this.
vaadin://
???://
???://
...

Looking at vaadin's source code of com.vaadin.shared.ApplicationConstants I found out these:
APP_PATH = "APP";
UIDL_PATH = "UIDL";
HEARTBEAT_PATH = "HEARTBEAT";
PUSH_PATH = "PUSH";
PUBLISHED_FILE_PATH = APP_PATH + '/' + "PUBLISHED";
APP_PROTOCOL_PREFIX = "app://";
VAADIN_PROTOCOL_PREFIX = "vaadin://";
FONTICON_PROTOCOL_PREFIX = "fonticon://";
PUBLISHED_PROTOCOL_NAME = "published";
PUBLISHED_PROTOCOL_PREFIX = PUBLISHED_PROTOCOL_NAME + "://";

Related

Accessing data in an object array with Java

I'm currently working with Cucumber and Java. I would like to retrieve that path of a file from ITestResult.
I'm currently retrieving the parameters with:
Object[] test = testResult.getParameters();
However the only thing I can access would seem the be the first objects name and nothing else.
test = {Object[1]#1492}
0 = {CucumberFeatureWrapper#1493} "Links at EDM Documents View,"
cucumberFeature = {CucumberFeature#1516}
path = "test/01-automation.feature"
feature = {Feature#1518}
cucumberBackground = null
currentStepContainer = {CucumberScenario#1519}
cucumberTagStatements = {ArrayList#1520} size = 1
i18n = {I18n#1521}
currentScenarioOutline = null
I cannot see anyway of retrieving path = "test/01-automation.feature" under cucumber feature.
Have you tried something like ((CucumberFeatureWrapper)test[0]).getCucumberFeature().getPath()?

Replacing a string in Google Protocol Data Buffers

I've succesfully built the following .proto file:
package JervisStorage;
option java_package = "TextBase";
option java_outer_classname = "JervisStorage";
message Owner {
optional string name = 1;
optional string sex = 2;
optional string profession = 3;
optional string email = 4;
}
Now, I managed to build the Owner:
private static Owner owner;
private static FileOutputStream serialOutput;
Owner pusheen= Owner.newBuilder()
.setName("Siema")
.setSex(" ")
.setProfession(" ")
.setEmail(" ")
.build();
I wrote the object to the file and successfully read the object from the file:
serialOutput = new FileOutputStream("JervisStorage.ser");
pusheen.writeTo(serialOutput);
serialOutput.close();
owner = Owner.parseFrom(new FileInputStream("JervisStorage.ser"));
System.out.println(owner.getName());
The problem is that I am unable to replace a signle record, write it back to the file and read the whole updated object. I have been trying to do this:
owner.toBuilder().setName("newName").build();
System.out.println(owner.getName());
serialOutput = new FileOutputStream("JervisStorage.ser");
owner.writeTo(serialOutput);
serialOutput.close();
owner = Owner.parseFrom(new FileInputStream("JervisStorage.ser"));
System.out.println(owner.getName());
Unfortunately, this approach does not seem to work... Can anyone help?
why not do
editedOwner = Owner.newBuilder()
.mergeFrom(new FileInputStream("JervisStorage.ser"))
.setName("new name")
.build();
alternatively you could do
editedOwner = owner.toBuilder()
.setName("new name")
.build();
Ok, I managed to find a solution to this problem. I hate extending the computation time when unnecessary, but this is the best I can think of so far. I've got two Owner objects: owner and editedOwner:
Owner owner;//for reading the records from the file
Owner editedOwner;// for addidng to the file
owner = Owner.parseFrom(new FileInputStream("JervisStorage.ser"));
editedOwner = Owner.newBuilder()
.setName("new name")
.setSex(owner.getSex())
.setProfession(owner.getProfession())
.setEmail(owner.getEmail())
.build();
serialOutput = new FileOutputStream("JervisStorage.ser");
editedOwner.writeTo(serialOutput);
serialOutput.close();
Fortunately, this little messy approach solves my problem for now. Thank you.

Splitting blackslash-path using jsp

I'm currently working on a jsp script that gets a path which I want split at the backslashes. Now my code doesn't seem to work. I think it's connected to the single backslashes in the path. The problem is I can't change them as the jsp will retrieve them from somewhere else...
Any suggestions what might be the reason?
<Property>
<% String testsetPath = "..\test\subfolder\version\folder\folder2";
String field = "testset";
String container[] = testsetPath.split("\\\\");
int sub = 0;
if(field.equals("testset")){
sub = 2;
}
else if (field.equals("testplan")){
sub = 1;
}
String output = container[container.length - sub];
%>
<availableValues>
<value><%= output%></value>
<displayName>Test</displayName>
<description>Test</description>
</availableValues>
Is it because you have not escaped the slashes in "testsetPath"?
String testsetPath = "..\\test\\subfolder\\version\\folder\\folder2";
String container[] = testsetPath.split("\\");
If want this to work cross-platform, you might want to do...
String container[] = testsetPath.split(File.separator);

How to convert a string to camel case in phpstorms (velocity based) file tempates?

What I've tried so far is:
## $NAME is something like 'my_controller_c'
#set($NAME = $NAME.removeAndHump($NAME))
#set($NAME = $NAME.underscoresToCamelCase(String)
But that does not work. The first one does nothing, the second one throws an java error.
I also tried using regular expressions and to loop through the string, but my java knowledge is very basic.
The following works in PhpStorm 9 (and probably all of the other JetBrains IDEs, I would guess):
#set($new_name = ${StringUtils.removeAndHump(${NAME}, "-")})
class $new_name {
}
This is, what I ended up doing:
#set($ctrlName = $NAME.replaceAll("-c$", ""))
#set($ctrlNewName = "")
#foreach($str in $ctrlName.split("-"))
#set($str = $str.substring(0,1).toUpperCase()+$str.substring(1))
#set($ctrlNewName = $ctrlNewName + $str)
#end
#set ( $ctrlNewName = $ctrlNewName + "Ctrl" )

Is it possible to get a list of workflows the document is attached to in Alfresco

I'm trying to get a list of workflows the document is attached to in an Alfresco webscript, but I am kind of stuck.
My original problem is that I have a list of files, and the current user may have workflows assigned to him with these documents. So, now I want to create a webscript that will look in a folder, take all the documents there, and assemble a list of documents together with task references, if there are any for the current user.
I know about the "workflow" object that gives me the list of workflows for the current user, but this is not a solution for my problem.
So, can I get a list of workflows a specific document is attached to?
Well, for future reference, I've found a way to get all the active workflows on a document from javascript:
var nodeR = search.findNode('workspace://SpacesStore/'+doc.nodeRef);
for each ( wf in nodeR.activeWorkflows )
{
// Do whatever here.
}
I used packageContains association to find workflows for document.
Below i posted code in Alfresco JavaScript for active workflows (as zladuric answered) and also for all workflows:
/*global search, logger, workflow*/
var getWorkflowsForDocument, getActiveWorkflowsForDocument;
getWorkflowsForDocument = function () {
"use strict";
var doc, parentAssocs, packages, packagesLen, i, pack, props, workflowId, instance, isActive;
//
doc = search.findNode("workspace://SpacesStore/8847ea95-108d-4e08-90ab-34114e7b3977");
parentAssocs = doc.getParentAssocs();
packages = parentAssocs["{http://www.alfresco.org/model/bpm/1.0}packageContains"];
//
if (packages) {
packagesLen = packages.length;
//
for (i = 0; i < packagesLen; i += 1) {
pack = packages[i];
props = pack.getProperties();
workflowId = props["{http://www.alfresco.org/model/bpm/1.0}workflowInstanceId"];
instance = workflow.getInstance(workflowId);
/* instance is org.alfresco.repo.workflow.jscript.JscriptWorkflowInstance */
isActive = instance.isActive();
logger.log(" + instance: " + workflowId + " (active: " + isActive + ")");
}
}
};
getActiveWorkflowsForDocument = function () {
"use strict";
var doc, activeWorkflows, activeWorkflowsLen, i, instance;
//
doc = search.findNode("workspace://SpacesStore/8847ea95-108d-4e08-90ab-34114e7b3977");
activeWorkflows = doc.activeWorkflows;
activeWorkflowsLen = activeWorkflows.length;
for (i = 0; i < activeWorkflowsLen; i += 1) {
instance = activeWorkflows[i];
/* instance is org.alfresco.repo.workflow.jscript.JscriptWorkflowInstance */
logger.log(" - instance: " + instance.getId() + " (active: " + instance.isActive() + ")");
}
}
getWorkflowsForDocument();
getActiveWorkflowsForDocument();
Unfortunately the javascript API doesn't expose all the workflow functions. It look like getting the list of workflow instances that are attached to a document only works in Java (or Java backed webscripts).
List<WorkflowInstance> workflows = workflowService.getWorkflowsForContent(node.getNodeRef(), true);
A usage of this can be found in the workflow list in the document details: http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/web-client/source/java/org/alfresco/web/ui/repo/component/UINodeWorkflowInfo.java
To get to the users who have tasks assigned you would then need to use getWorkflowPaths and getTasksForWorkflowPath methods of the WorkflowService.

Categories

Resources