How to sync to a label with p4java - perforce

I've seen examples online of using Perforce's p4java api to sync a client workspace with the latest files. Eg:
public List<IFileSpec> sync(List<IFileSpec> fileSpecs,
boolean forceUpdate,
boolean noUpdate,
boolean clientBypass,
boolean serverBypass)
But how do I specify it to sync to a specific label? Eg, the equivalent of this at the command-line:
p4 sync #labelname
Is it perhaps via the alternate method that uses SyncOptions?
public List<IFileSpec> sync(List<IFileSpec> fileSpecs,
SyncOptions syncOpts)
I had a look at SyncOptions, but didn't see any way to specify a label in there.

FileSpec which is an implementation of IFileSpec has a label field :
protected String label
and the following method :
void setLabel(String label)
Set the label associated with this file spec.
taken from the following link :
https://www.perforce.com/perforce/r15.1/manuals/p4java-javadoc/com/perforce/p4java/impl/generic/core/file/FileSpec.html

After advice above to look into the fileSpecs parameter, I discovered that this method worked for me:
List<IFileSpec> fileSpecsSet =
FileSpecBuilder.makeFileSpecList("//path/to/project/...#labelname");
client.sync(fileSpecsSet, true, false, false, false);

Related

How to pass PageObject for cucumber step definition

I see the following step in noraUI sources
#And("I expect to have {page-element} with the text {string}(\\?)")
public void expectText(Page.PageElement pageElement, String textOrKey, List<GherkinStepCondition> conditions) throws FailureException, TechnicalException {
this.expectText(pageElement, textOrKey, new Object[0]);
}
I would like to use this step but I can't pass {page-element} for this step. How it should look like?
According to doc I see that it should starts with $, but this step keeps undefined from feature file
What about something like this?
#And('I expect to have $pageElement with the text $string
public void expectText(String pageElement, String string) {
// code to check if the pageElement exists and if it matches the string
}
After reading the doc I've got the solution
We still can't pass object inside of cucumber file because step will be marked as "undefined"
As it is, noraUI has it's own step parser and if I write this step inside of my feature file:
When I click on $google.GoogleHomePage-searchButton
This step will be defined inside of noraUi and this pageObject will be resolved from .ini file of nora configs

How do you set the value of 'DocumentShowInSiteMap' property in Kentico?

How do you set the value of DocumentShowInSiteMap property in Kentico?
I've tried:
Using the DocumentHelper and TreeHelper apis but with both, this property doesn't give you access to the setter.
Tried running a SQL Query setting the value of dbo.CMS_Document.DocumentShowInSiteMap to 1 and 0. These queries run fine but when I go to the pages app, there is no change in the 'Show in sitemap' property checkbox, ie. setting the database field to 0 doesn't 'untick' this checkbox.
I'm trying to run a scheduled task which will set this property for documents at a specified location automatically. What is the proper way to do this? Any help appreciated.
Have you tried this?
int TheDocumentToModify = 1221;
var PageItem = DocumentHelper.GetDocument(TheDocumentToModify , new TreeProvider());
foreach(var culturePage in PageItem.CultureVersions)
{
culturePage.SetValue("DocumentShowInSiteMap", true);
// May need to apply Workflow check in / check out, see Kentico API examples based on your need.
culturePage.Update();
}
Within code, there is no simple way. Setter should be available within special class DocumentCultureDataInfo and it should be saved with SetObject. This class contains all of culture DB fields and is manipulated by DocumentCultureDataInfoProvider.
This class is an internal property of TreeNode. However I have not tried doing this arbitrary in code and mentioned classes are part of innner API.
Your second approach should work, but documents and their properties are cached and you will need to refresh cache so that new DB value is actually picked up Loading of this property goes through simple GetData in LoadDefaultValues for each TreeNode.
Trevor J Fayas's answer would probably work. I figured this out yesterday and just leaving my solution here just in case:
TreeHelper
.GetDocuments(task.CurrentSiteName, aliaspath, null, false, "", "", "", -1, false, -1)
.Where(doc => doc.DocumentShowInSiteMap)
.ToList()
.ForEach(node =>
{
node.SetValue("DocumentShowInSiteMap", false);
node.Update();
});
Obviously replace aliaspath with the one you need or use DocumentHelper.GetDocuments which takes different parameters.

Jenkins boolean parameter is always true in groovy

I have a Jenkins job that calls a groovy script and the groovy script uses Jenkins parameters to do it's work. I can retrieve all the parameters without a problem except for a boolean parameter. The boolean parameter is a checkbox in Jenkins
I read the jenkins parameter into Groovy as follows:
boolean libraryBranch = config.get('library_branch_feature');
Now when I print the 'libraryBranch' variable
out.println "-- Library branch feature?: " + libraryBranch.toString();
I get the following printed line:
-- Library branch feature ?: true
So it doesn't matter if the boolean Jenkins parameter is selected or not I always have a boolean value 'true' in Groovy. All other (string) parameters inside the same job are read without a problem.
Can someone help me with this issue?
EDIT
Ok I've decided to try and retrieve the code in a couple of other ways and tyring to find a good solution:
Boolean libraryBranch = build.buildVariableResolver.resolve("library_branch_feature");
String libraryBranchString = build.buildVariableResolver.resolve("library_branch_feature").toString();
Boolean libraryBranchStringAsBoolean = build.buildVariableResolver.resolve("library_branch_feature") as Boolean;
The above variables are then printed:
out.println "-- Library branch feature?: " + libraryBranch;
out.println "-- Library branch feature to String: " + libraryBranch.toString();
out.println "-- Library branch feature to String: " + libraryBranch.toString();
out.println "-- Library branch feature as String: " + libraryBranchString;
out.println "-- Library branch feature String as Boolean: " + libraryBranchStringAsBoolean;
The output of the above prints are posted below:
-- Library branch feature?: true
-- Library branch feature to String: true
-- Library branch feature to String: true
-- Library branch feature as String: false
-- Library branch feature String as Boolean: true
So the only way thus far to have the boolean value read correctly as a false is by not turning it into a boolean at all but just reading it as a string and use it as a string.
I would rather use it as a boolean though so any suggestions on the matter is still appreciated.
The answer is to read the Jenkins parameter as String and then convert it to a boolean using the method .toBoolean(); So my libraryBranch is now set as follows:
boolean libraryBranch = build.buildVariableResolver.resolve("library_branch_feature").toString().toBoolean();
Just out of curiosity, I tried the following:
Set the variable 'testmode' as a boolean in the pipeline setup.
Start the job, with testmode set false (unchecked).
In the pipeline script, run the following code immediately upon entry:
testmode=testmode.toBoolean()
if (testmode==false) { print "testmode tests true"}else{print "testmode tests false"}
you will see the result 'testmode tests false'.
To verify my claim that the 'boolean' variable testmode is ACTUALLY a string when it comes in, I tried:
testmode=testmode.toBoolean()
testmode=testmode.toBoolean()
and it blew up on the 2nd 'toBoolean'. I'll spare you the error message...
So, I claim that testmode comes in as the string "false" instead of as a boolean (whether because of promotion, demotion, forcing, whatever).
So, if its a boolean parameter, and you really wanted to treat it like a boolean and not have to say 'if (booleanvar=="true")', then convert it to a boolean as above and you're done.
The question and the answers are a bit dated. The modern method to
consume a boolean parameter is to use the params. global values. params
properly exposes Boolean parameters such that the following both work and
require no string/boolean conversions.
if (params.library_branch_feature) {
// truth logic here
}
// or
if (params.library_branch_feature != false) {
// truth logic here
}
From the Pipeline Syntax for params.:
Exposes all parameters defined in the build as a read-only map with variously typed values. Example:
if (params.BOOLEAN_PARAM_NAME) {doSomething()}
or to supply a nontrivial default value:
if (params.getOrDefault('BOOLEAN_PARAM_NAME', true)) {doSomething()}
NOTE:
It may not make sense that a boolean parameter can have NO value,
but '.getOrDefault()' is useful to set default values for string parameters.
I encountered the same problem with reading java Properties - retrieved boolean values are always true. So, say I have a settings file with property debugging=false. This test will fail:
class ConfigurationTest extends GroovyTestCase {
void testProcessConfiguration() {
Properties properties=new Properties()
FileReader fileReader=new FileReader('settings')
properties.load(fileReader)
boolean debug=properties.getOrDefault('debugging',false)
assert !debug
fileReader.close()
}
}
But if you make it properties.getOrDefault('debugging',false).toString().toBoolean() it will return correct value. Probably this is because of coercion?

get back to lower level j2me

I have a textfield (lower level) a call a function that call a higher level form that contains a datafield to pick up a date and display it in my textfield lowerlevel.
The problem is I cannot get back to my textfield (lower level) since the datefield appears
public void formdatepicker() {
final javax.microedition.lcdui.Command CONFIRM_COMMAND
= new javax.microedition.lcdui.Command("OK",
javax.microedition.lcdui.Command.OK, 1);
javax.microedition.lcdui.Command CANCEL_COMMAND
= new javax.microedition.lcdui.Command("Cancel",
javax.microedition.lcdui.Command.CANCEL, 2);
final DateField datefield = new DateField("Pick a date", DateField.DATE);
form.append(datefield);
form.addCommand(CONFIRM_COMMAND);
form.addCommand(CANCEL_COMMAND);
form.setCommandListener(new CommandListener() {
public void commandAction(javax.microedition.lcdui.Command c, Displayable d) {
if (c == CONFIRM_COMMAND) {
Date date = datefield.getDate();
display.setCurrent(null);// try to hide the current form to get
}
}
});
Display.getInstance().getJ2MEDisplay().setCurrent(form);
Your mistake is wrong assumption about what setCurrent(null) does. Per your question and code snippet, it looks like you expect it to somehow show the screen that has been displayed prior to form. It doesn't, see the exaplanation in the API javadocs (available online):
The application may pass null as the argument to setCurrent(). This does not have the effect of setting the current Displayable to null; instead, the current Displayable remains unchanged. However, the application management software may interpret this call as a request from the application that it is requesting to be placed into the background...
If you want to use setCurrent(Displayable) to show some screen instead of current one, you need to pass this screen as an argument to setCurrent.
For the sake of completeness, note that there is another version of setCurrent that accepts two parameters, first of which is Alert, which works a bit differently, but it is not applicable in your case because you use Form not Alert.

Manager Bean do not returns when the project is online

I have a JSF project working with JPA, I do this : retrive some data from mysql database then plot the data in a chart.
Locally works pretty fine, as you can see here:
So I deploy the project in my GlassFish 3 Open Source, which is running in a EC2 instance, then I try to make the same operation again but it seems the ManagedBean do not returns to the page correctly:
This is my ManageBean :
#ManagedBean(name="reportc")
#SessionScoped
public class ReportControl implements Serializable {
private static final long serialVersionUID = 3269125738504434502L;
#EJB LogEAO logEAO;
private int quantity;
#NotNull(message="informe um intervalo")
private String time;
#NotNull(message="informe um ponto")
private String point;
private Map<String, Object> data = new HashMap<String, Object>();
#PostConstruct
public void init(){
quantity = 1;
}
public String getDataAsJson() {
return new Gson().toJson(data);
}
public String generateReport(){
this.setTitles();
this.getValues(getLog());
return "/showroom/report.xhtml?faces-redirect=true";
}
.. methods and get's and set's
I already look in into my server.log to see if there's something wron but it seems everything is alright.
[#|2012-03-31T14:30:06.594+0000|WARNING|glassfish3.1.1|javax.enterprise.resource.webcontainer.jsf.application|_ThreadID=25;_ThreadName=Thread-2;|JSF1064: Unable to find or serve resource, image/structure/pic-1.gif.|#]
[#|2012-03-31T14:30:15.558+0000|FINE|glassfish3.1.1|org.eclipse.persistence.session.file:/home/ec2-user/usr/local/glassfish3/glassfish3/glassfish/domains/domain1/applications/BrainSet/WEB-INF/classes/_BrainSet.sql|_ThreadID=24;_ThreadName=Thread-2;ClassName=null;MethodName=null;|SELECT ID, TIME, VALUE, id_point FROM log WHERE (((id_point = ?) AND (TIME >= ?)) AND (TIME <= ?))
bind => [3 parameters bound]|#]
[#|2012-03-31T14:30:15.585+0000|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=24;_ThreadName=Thread-2;|EXECUTION TIME:0:0|#]
[#|2012-03-31T14:30:15.585+0000|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=24;_ThreadName=Thread-2;|LOGS SIZE : 0|#]
[#|2012-03-31T14:30:16.690+0000|WARNING|glassfish3.1.1|javax.enterprise.resource.webcontainer.jsf.application|_ThreadID=24;_ThreadName=Thread-2;|JSF1064: Unable to find or serve resource, image/structure/pic-1.gif.|#]
[#|2012-03-31T14:35:53.578+0000|FINE|glassfish3.1.1|org.eclipse.persistence.session.file:/home/ec2-user/usr/local/glassfish3/glassfish3/glassfish/domains/domain1/applications/BrainSet/WEB-INF/classes/_BrainSet.sql|_ThreadID=28;_ThreadName=Thread-2;ClassName=null;MethodName=null;|SELECT ID, TIME, VALUE, id_point FROM log WHERE (((id_point = ?) AND (TIME >= ?)) AND (TIME <= ?))
bind => [3 parameters bound]|#]
[#|2012-03-31T14:35:53.605+0000|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=28;_ThreadName=Thread-2;|EXECUTION TIME:0:0|#]
[#|2012-03-31T14:35:53.605+0000|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=28;_ThreadName=Thread-2;|LOGS SIZE : 0|#]
I really don't know why this is happening, besides is my first time trying to deploy a project which use JPA and JSF together.
What could be doing this ?
EDIT:
Just one more thing, in local mode when I click to generate the report it takes some seconds to go to the database, make the maths and return to my page, but when it's in production mode when I click to generate the report it just refresh the page, why is that happening ?
I really need to know why ... help me out guys, please.
EDIT 2:
You guys can see it online here:
http://50.19.242.172:8080/BrainSet/showroom/report.xhtml
Just played with the chart again...
I do get charts properly... could it be that you had no data gathered in the production in the beginning...? Cause now there is
Also i'm getting alerts saying
serverError: class javax.faces.el.EvaluationException For input string: "true"
check you EL expressions related to the "drop downs" of the chart....
b.t.w here another successful screenshot :
So it seems like working... you might need to redefine your question...
The solution was :
I had to give permissions to some user in MySQL, enable the remote connection in MySQL, put JDBC driver in glassfish_installation\glassfish\modules\ and restart it, initialize the logEAO and put the annotation #Table(name="table_name") because it depends of each file system in operationals system as can be seen here:
JPA: MySQL says table don't exist, but it exist actually.
Did you try Ctrl + F5 in the browser to force reload page ?

Resources