ClearCase config spec selection based on element attribute - clearcase

In a ClearCase config spec, is it possible to select versions based on element attributres (not version attributes)? For instance:
element * ...{SOME_ELEM_ATTR==SOME_VALUE&&lbtype(MY_LABEL1)}
This doesn't work because the last part of the "element" spec is a version-selector, which only looks at version attributes.
What I'm trying to do is partition my files into two or more classes, and have different "element" lines apply to different classes of files. I tried tagging all the elements in one class with an attribute, but hit a dead end with trying to base the selection on that in the config spec. The only way I can see to do this sort of thing is to put all the files of one class in one place and use the second construct (the "pattern") to differentiate:
element .../all_class1_files/... MY_LABEL1
but this is really ugly because you have to move all the files of one class into one place, or have a giantic config spec listing all the individual directories and/or files.
Thanks in advance...
Ray

One first solution would be to replace the attribute criteria by a branch.
That way, you would more easily be able to label all files from one branch or another, instead of "all files with a given attribute".
Other than this workaround, you will find some find command based on attribute here (or in the man page).
You could then combine a find query with an "-exec" directive to put the label that you want.
That way, you don't have to mess with the config spec syntax (which may not support the exact selection criteria you are after).
I didn't test it, but you could try
element * ...{SOME_ELEM_ATTR==SOME_VALUE && lbtype_sub(MY_LABEL1)}
, because lbtype_sub is an element, branch and version selector (whereas lbtype is just a version selector).
However, since lbtype doesn't seem to be part of the config spec criteria, I doubt it can work in said config spec.

I think I've up with a good solution using "trtype" as a selection criterion (appears to be the only query function that inherits from the element to the version). If the Class1 and Class2 elements have dummy triggers Class1Files andClass2Files attached to them, respectively, then something like
element * .../{trtype(Class1Files)&&lbtype(MY_LABEL1)}
element * .../{trtype(Class2Files)&&lbtype(MY_LABEL2)}
should do the trick. This selects files in Class1 with MY_LABEL1 and in Class2 with MY_LABEL2. I haven't actually tried this out yet, but I'll let you know how this works out.

Related

Grails 3 "show" view with Fields plugin 2.1.0-SNAPSHOT

Stuck at a trivial problem in Grails 3.1.5: Show the fields of a domain object, excluding one of them, including a transient property. Yes, this is my first Grails 3 project after many years with previous versions.
The generated show.gsp contains
<f:display bean="rfaPdffile"/>
This will include a field that may contain megabytes of XML. It should never be shown interactively. The display: false constraint is no longer in the docs, and seems to be silenty ignored.
Next I tried explicitly naming the fields:
<f:with bean="rfaPdffile">
<f:display property='fileName'/>
<f:display property='pageCount'/>
...
</f:with>
This version suprisingly displays the values without any markup whatsoever. Changing display to field,
<f:with bean="rfaPdffile">
<f:field property='fileName'/>
<f:field property='pageCount'/>
...
</f:with>
sort of works, but shows editable values. So does f:all.
In addition I tried adding other attributes to f:display: properties (like in f:table), except (like in f:all). I note in passing that those two attributes have different syntax for similar purposes.
In the Field plugin docs my use case is explicitly mentioned as a design goal. I must have missed something obvious.
My aim is to quickly throw together a prototype gui, postponing the details until later. Clues are greatly appreciated
If I understood you correctly, you want to have all bean properties included in the gsp but the one with the "megabytes of XML" should not be displayed to the user?
If that is the case you can do:
f:with bean="beanName"
f:field property="firstPropertyName"
f:field property="secondPropertyName"
And the one you don't wish to display:
g:hiddenField name="propertyName" value="${beanName.propertyName?}"
f:with
So list all the properties as f:field or f:display and put the one you don't wish to display in a g:hiddenField Grails tag
You can also try:
f:field property="propertyName"
widget-hidden="true"
but the Label is not hidden in this case.
Hope it helps
My own answer: "use the force, read the source". The f:display tag has two rather obvious bugs. I will submit a pull request as soon as I can.
Bugs aside, the documentation does not mention that the plugin may pick up the "scaffold" static property from the domain, if it has one. Its value should be a map. Its "exclude" key may define a list of property names (List of String) to be excluded. This probably works already for the "f:all" tag; bug correction is needed for the "f:display" tag.
My subjective impression is that the fields plugin is in a tight spot. It is intertwined with the Grails architecture, making it sensitive to changes in Grails internals. It is also required by the standard scaffolding plugin, making it very visible. Thus it needs constant attention from maintainers, a position not to be envied. Even now conventions for default constraints seem to have changed somewhere between Grails 3.0.9 and 3.1.7.
Performance of the fields plugin is sensitive to the total number of plugins in the app where it is used. It searches all plugins dynamically for templates.
For the wish list I would prefer stricter tag naming. The main tags should be verbs. There are two main actions, show and edit. For each action there are two main variants, single bean or multiple beans.
My answer is that at present (2 March 2017) there is no answer. I have searched the Net high and low. For the index (list) and create and edit views, the fields plugin works well enough. A certain field can be easily excluded from the create and edit views, relatively easily from the list view (by listing those that should show), and in no way I could find from the show view. This is such a common need that one would suspect it will be addressed soon. Also, easily showing derived values in the show view, like 'total' for an invoice. One can do that by adding an ordered list with a list item showing the value below the generated ordered list of values, but that is kind of a hack.
In some ways, the old way was easier. Yes, it generated long views, but they were generated and didn't have to be done by the programmer - just custom touches here and there.

Are there any tools for recording web browser events for seleniumn2?

I am looking for something very simple. It can use the Selenium IDE recording tool, but it does not allow me to pick what kind of locators I get.
I want to use:
driver.findElement(By.className(str))
to locate things. All I need is something which watches which UI elements on a web page get clicked and writes out the class attributes of those tags.
If I use the Selenium IDE recording (and export to the right type of thing), I get:
#Test
public void testNav() throws Exception {
driver.get(baseUrl + "/");
driver.findElement(By.name("3.1.1.5.1.1")).clear();
driver.findElement(By.name("3.1.1.5.1.1")).sendKeys("dan");
driver.findElement(By.name("3.1.1.5.1.5")).click();
driver.findElement(By.linkText("Products")).click();
driver.findElement(By.linkText("Categories")).click();
driver.findElement(By.linkText("Create a Category")).click();
driver.findElement(By.linkText("Cancel")).click();
driver.findElement(By.linkText("Products")).click();
driver.findElement(By.cssSelector("a.DisplayAdminProductsLink")).click();
driver.findElement(By.linkText("Product1")).click();
There are problems with this. First, it is not give me any By.className() calls. Why? Those first 3 calls will not help me. The framework I am using puts arbitrary things into the name. How can I get it to see the class attribute?
There actually are unique words in the class attribute of all of the above tags. I design my apps so that this is so. Yet it will not use them.
Earlier I asked:
Why is it doing a "driver.findElement().click()"? This is fragile and does not
end up working.
What I need is:
elt = driver.waitFor(By.className("c")); elt.click();
This will work reproducibly.....
I am considering to be removed from the question, as the findElement() code does work. You need to set a general time-out on the driver. It is not very obvious that this can be done, but it can.
So, continuing on....
I can go to the "Options" and change the order of the "Locator Builders" in eclipse. I can put "css" at the top. Then I get:
driver.findElement(By.cssSelector("input[name=\"3.1.1.5.1.1\"]")).clear();
driver.findElement(By.cssSelector("input[name=\"3.1.1.5.1.1\"]")).sendKeys("dan");
driver.findElement(By.cssSelector("input[name=\"3.1.1.5.1.5\"]")).click();
The tags are like:
<input class="form-control LoginUsernameField" ... />
But it does not see the class attribute.... Or I can do this manually.
Selenium looks for a unique identifier to identify elements in a webpage. classNames are a very less desired option for this purpose as they are generally not unique. Ids and names on the other hand are generally unique. This might be the reason why Selenium IDE is not selecting classNames and going for other identifiers.
Selenium IDE records user actions. You would have clicked on the element for Selenium IDE to identify it and that is why you are getting driver.findElement().click().
If you want to wait for element to wait you can try implicit wait.
When you want to use driver.findElement(By.className(str)), are you sure that there is one and only one element in the webpage that is associated with a className? If that is the case you can modify the webdriver code manually to use className.

ClearCase Symbolick Link Issue

I have created a symbolic link for folder1 to make it available in vob2\rootdir from vob1\rootdir.
And I labeled the whole directory folder1 recursively in vob1.
But when I modified the configspec of dynamic view to load folder1, it was loaded under vob1; But I couldn't see that folder in vob2\rootdir. Pls help.
First you don't modify a config spec to load anything in a dynamic view: you only modify selection rules, there is no load rules (as opposed to snapshot view).
If you were actually using a snapshot view (with a path different from M:\ or /views), then beware of symlink resolution issue like this one.
Finally, if your config spec doesn't select vob2/rootdir, or if it doesn't select the version which recorded the symlink, you wouldn't be able to see said symlink.
That means, labelling vob1/folder1 isn't enough: you need to make sure that:
/vob2 is labelled
/vobs2/rootdir is labelled as well
In other words, the parent folders of your final selection target (target being '/vobs/rootdir/folder1) must be selected.

Drupal: D7 rewriting values returned by views

I have a requirement to perform an indexed search across content which must include a couple of tags in the result. The tags must be a random selection. The platform is Drupal 7.12
I have created a view that manages the results of a SOLR search through the search_api. The view returns the required content and seems to work as intended. I have included a couple of Global: custom text fields as placeholders for the tag entries.
I am now looking for a solution to manage the requirement to randomise the tag values. The randomisation is not the issue, the issue is how to include the random values into the view result.
My current approach is to write a views_pre_render hook to intercept the placeholders which appear as fields ([nothing] and [nothing_1]). The test code looks like the following
function MODULE_views_pre_render( &$view )
{
$view_display = $view->display['default'];
$display_option = $view_display->display_options;
$fields = $display_option['fields'];
foreach( $view->result as $result )
{
$fields['nothing']['alter']['text'] = sprintf("test %d", rand(1,9));
}
}
I am currently not seeing any change in the placeholder when the view is rendered.
Any pointers to approach, alternate solutions etc would be gratefully received as this is consuming a lot of scarce time at the moment. Calling print_r( $view ) from within the hook dumps over 46M into a log file for a result set of 2 items.
There are two possible solutions for your task.
First approach is do everything on the template level. Define a template for the view field you want to randomize. In advanced settings of your display go to Theme: Information. Make sure that the proper theme is selected and find the template suggestions for your field. They are listed starting from most general to the most specific and you can choose whatever suits you better.
I guess the most specific template suggestion for your field would be something like this: views-view-field--[YOR VIEW NAME]--[YOUR DISPLAY NAME]--nothing.tpl.php. Create the file with that name in the theme templates directory and in this template you can render what ever you want.
By default this template has only one line:
print $output;
you can change this to:
print sprintf("test %d", rand(1,9));
or to anything else, whatsoever :)
Second approach is to go with Views PHP module. WIth this module you can add a custom PHP field in which you can do whatever you want. Even though the module hasn't been released it seems to work quite well for the most of the tasks and most certainly for such a simple task as randomizing numbers it will work out for sure.
I stumbled upon this while searching for another issue and thought I would contribute.
Instead of adding another module or modifying a template, just add a views "sort criteria" of "Global: Random".

Contains an element with the target?

Is there any way only using CSS (no script) to check if an element such as a table contains another element such as with the target? I know that you can use the :target pseudo class for elements with the target, but I need the ability to select an element which contains the element with the target. If there's any way to using the :contains pseudo class to check if an element contains the target that'd be useful, however I've tried it a few different ways with no success. I know there isn't a parent selector which rules out looking for the parent of the element with the target URI. The only possible ways I can think of are using :contains and I don't think that'll even work with anything but text. If anyone knows some sort of trick or other selector that'd solve this issue, help would be appreciated.
First guess:
I'm having a hard time understanding your question, so my answer is offered on the assumption that your question is something like this:
Is there any way to style the parent of a targeted element?
And the answer is no, css works by cascading down the hierarchy, it can't cascade up; have a read of the following questions/answers for further details:
CSS Parent/Ancestor Selector
Is there a CSS parent selector?
Complex CSS selector for parent of active child
(There are others, if you search for 'css parent selectors')
Second guess:
If your question is:
can I find links that target other sections of the same page?
Then yes, you can (with css3 and/or using jQuery):
a[href*='#'] { /* css */ }
$("a[href*='#']") // jQuery selector
The href*='#' part is an attribute-selector, that searches the 'href' attribute for any occurrence1 of the quoted string '#' (the # being used to target same-page links).
If you're able to revise your question to make it more clear what you'd like us to help you with, then I'll be more than happy to try and be more use to you, but as it is I can only guess. Which is pretty much useless. =(
Footnotes:
Other options are:
starts with, eg: a[href^='http://'] which selects all links whose href begin with 'http://', and
ends with, eg: a[href$='.pdf'], which selects all links that end with the filetype .pdf.

Resources