Is there any way can we add two datapools to a single script? Or in other words how can we get inputs from two different datapools to a single script.
Thanks in advance.
Yes, you can manually load and manage any number of datapools.
/**
* Creates a IDatapoolIterator pointing the first record
* #param datastore default project path
* #param dataPoolPath relative path in the project
* #return IDatapoolIterator pointing the first record
*/
public static IDatapoolIterator getDataPoolIterator(String datastore, String dataPoolPath)
{
java.io.File dpFile = new java.io.File(datastore, dataPoolPath+".rftdp");
DatapoolScriptSupport dss = new DatapoolScriptSupport();
IDatapool dp = (IDatapool) dss.dpFactory().load(dpFile, true);
IDatapoolIterator dpIter = dss.dpFactory().open(dp, null);
dpIter.dpInitialize(dp);
dpIter.dpReset();
return dpIter;
}
then in your code
myDatapool = getDataPoolIterator((String)getOption(IOptionName.DATASTORE), "relative/path/intheproject");
You can access any Variable in the datapool by
myDatapool.dpString("Variable");
Use the correct method depending the type of the variable you need. Using
myDatapool.dpNext();
you will advance to the next record in the datapool.
Hope this will help.
Further informations here: IBM Help System: Datapool
Related
I'm looking to test error messages by modifying a valid xml message file.
I can easily add nodes like this in the scenario:
* def invalidDocumentId = read('Valid.xml')
* set invalidDocumentId /soapenv:Envelope/soapenv:Body = <tis:extraBonus>Extra</tis:extraBonus>
Given request invalidDocumentId
But I'd like to also remove nodes, update node names, change attribute names.
Is there a way to set that or do I need to call Java com.intuit.karate.XmlUtils.
First, removing and adding a node and even attributes should be easy, just use the remove and set keywords with XPath. They will over-write values if needed.
* def base = <query><name>foo</name></query>
* remove base /query/name
* match base == <query/>
* set base /query/foo = 'bar'
* set base /query/#baz = 'ban'
* match base == <query baz="ban"><foo>bar</foo></query>
And the good news is that if you have some really tricky XML manipulation requirements, the string replace syntax comes to the rescue. This is best explained in this other answer on Stack Overflow: https://stackoverflow.com/a/50367134/143475 | https://stackoverflow.com/a/53682733/143475
I have an old oxid-version. I exported my old seo-data from the table "oxseo" to get the keywords and description for each article. Now i want to import these fields in my new version of the shop. My articles are already there, but not the seodata.
My first idea was to collect all the data i need from a csv-export of my old data.
For example, my output array could look something like:
$article = array();
$keywords = array();
$desc = array();
foreach($line as $l) {
$keywords[$i] = current_keyword
$desc[$i] = current_description
$oxid[$i] = current_oxid
}
So lets just assume I already have my filled array.
If i check the oxid's, they are still the same. So, from my exported CSV, picking a random OXID, looking for it in my new DB shows me the correct article.
Now my first thought was, to look in oxobject2seodata. I know that the data for the articles are stored in there, but i can't find a way to connect those, since the "oxid" from the old version is not the same as the objectId in the new version. In oxarticles, however, there is no "objectId".
Thank you in advance for any hints and tips
The field OXID in oxarticles table should match the field OXOBJECTID in oxobject2seodata table.
SELECT oa.OXID, o2s.* from oxobject2seodata o2s, oxarticles oa WHERE o2s.OXOBJECTID = oa.OXID AND oa.OXID = '[OXID-of-article]';
-- or
SELECT o2s.* from oxobject2seodata o2s WHERE o2s.OXOBJECTID = '[OXID-of-article]';
We built a site with Concrete5 that was originally developed in Joomla. Our job was to bring over everything and Concrete5-ize it. A major part of this site is about 1200 audio teachings, with each teaching having various attributes, such as topic, author, program, location, etc.
Some teachings might have more than one attribute assigned, say multiple keywords or topics.
I would like to give counts to all of the attributes so that the visitor can see how many teachings are by a certain author, or how many are on a particular topic at a glance, ie:
Ethics (20)
Fear (42)
Gratitude (55)
My original code turned out to have way too much overheard to be practical for so many teachings and so many attributes. Basically, I ran through and for each attribute, I did a lookup for the total count based on the PageList count. We're talking hundreds of lookups with each page load. Turning on cache didn't seem to help here.
Are there any other strategies that have proved successful for aggregating counts for attributes over a large-ish number of pages?
Here is the site for reference: http://everydayzen.org/teachings/
I typically say "don't access the database directly; use the API", but I think you should be using the DB here.
Check out the [Collection|File]SearchIndexAttributes table. (I'm not sure if teachings are files or pages. If pages, you'll need to reindex them regularly, via the job in the dashboard.) Looking at the index table will be a lot easier than joining in the most-recent version in the attribute value table. Once you see that table, you can do some simple GROUPing within SQL.
If you want to use the API, you could do it as you do today as a batch, do the appropriate calculations, and then cache it.
There's no reason caching shouldn't work but the first hit (when the cache is cold) will, of course, take the full amount of time. You should cache my IndexAttributes idea (a full table read and looping isn't trivial), but at least with a cold cache that should take a fraction of a second vs 10 or more seconds that hundreds of page list calls could take.
I've done something similar on a job site for Concrete5, by showing the counts of each Department that jobs fall in.
i.e. HR (32), Sales (12) and so on
This is the code taken from a Helper that acheives this (this is just the related functions included):
<?php
class JobHelper {
/**
* GetDepartmentJobsCount
* Returns array of Department names with job count based on input Pages
* #param Array(Pages) - Result of a PageList->getPages
* #return Array
*/
public function getDepartmentJobsCount($pages) {
$depts = $this->getDepartments();
$cj = $this->setCounts($depts);
$cj = $this->setAttributeCounts($cj, $pages,'job_department');
return $cj;
}
/**
* GetDepartments
* Return all available Departments
* #return Array(Page)
*/
public function getDepartmentPages(){
$pld = new PageList();
$pld->filterByPath('/working-lv'); //the path that your Teachings all sit under
$pld->setItemsPerPage(0);
$res = $this->getPage();
$depts = array();
foreach($res as $jp){
$depts[$jp->getCollectionName()] = $jp;
}
ksort($depts);
return $depts;
}
/**
* PopulateCounts
* Returns array of page names and counts
* #param Array - Array to feed from
* #return Array
*/
public function setCounts($v){
foreach($v as $w){
$a[$w]['count'] = 0;
}
return $a;
}
/**
* PopulateCounts
* Returns array of page names, with counts added from attribute, and paths
* #param Array - Array to add counts and paths in to
* #param Array(Pages) - Pages to run through
* #param String - Attribute to also add to counts
* #param String - Optional - Job Search parameter, leave blank to get Page URL
* #return Array
*/
public function setAttributeCounts($cj, $pages, $attr){
foreach($pages as $p) {
$pLoc = explode('|',$p->getAttribute($attr)); // Our pages could have multiple departments pipe separated
foreach($pLoc as $locName){
$cj[$locName]['count']++;
}
}
return $cj;
}
You can then do the following from a PageList template
$jh = Loader::helper('job');
$deptCounts = $jh->getDepartmentJobsCount($pages);
foreach($deptCounts as $dept => $data) {
echo $dept . '(' . $data['count] . ')';
}
We have an Endeca index configured across multiple fields of email content - subject and body. But we only want searches to be performed on the subject lines. Endeca is returning matches within the bodies too. How do you limit the search to the subject?
You can search a specific field or fields by specifying it (them) with the Ntk parameter.
Or if you wish to search a specific group of fields frequently you can set up an interface (also specified with the Ntk parameter), that includes that group of fields.
This is how you can do it using presentation API.
final ENEQuery query = new ENEQuery();
final DimValIdList dimValIdList = new DimValIdList("0");
query.setNavDescriptors(dimValIdList);
final ERecSearchList searches = new ERecSearchList();
final StringBuilder builder = new StringBuilder();
for(final String productId : productIds){
builder.append(productId);
builder.append(" ");
}
final ERecSearch eRecSearch = new ERecSearch("product.id", builder.toString().trim(), "mode matchany");
searches.add(eRecSearch);
query.setNavERecSearches(searches);
Please see this post for a complete example.
Use Search Interfaces in Developer Studio.
Refer - http://docs.oracle.com/cd/E28912_01/DeveloperStudio.612/pdf/DevStudioHelp.pdf#page=209
I'm trying to write a PHP code to validate a form input in a field. If the field has already value the system must send an error message. If there is not a value or the value is the same like the input then the form can be submitted.
The edited code is:
/**
* Implement a function to get the ID and the title of the referenced node
* of type Reservation
* by the nodereference field called Period
* in the currently edited node from type Board
* Try to do this by the node_load() instead of the database query
* Is it the correct method to get the edited node's ID?
**/
function period_get_value() {
$thisnodeboard = $node->field_period_1[$node->language][0]['nid'];
$reservationrec = node_load(array('nid'=>$thisnodeboard));
return $reservationrec->title;
}
/**
* Implement the hook_form_FORM_ID_alter function to validate
* if the field Period has already value set
* and if there is such to check if it is the same as the input value
**/
function period_validate_form_slickgrid_editor_form_alter(&$form, $form_state){
/**
* The current value is the title of the referenced node
**/
$valcurr = period_get_value();
$valnew = $form_state['values']['field_period_1'];
if (isset($valcurr)&&($valcurr!=$valnew)){
form_set_error('field_period_1', t('There is already value set for this field'));
}
return $form;
}
But it still doesn't work - does not set any message and allow for changing the existing value in the field_period_1.
Firstly, writing a manual SQL query in D7 is an absolute last resort.
OK so you actually want to just prevent the user from updating a field after the node has been created.
You can do one of two things. If you only want to prevent edits from the node/edit form you could implement hook_form_FORM_ID_alter() and then add your own validate or submit handler. You would then validate that the field has not changed and act accordingly.
If you wanted to prevent it happening from anywhere, Eg programmatically. You could implement hook_node_update() and check $node->is_new and $node->type to prevent changes to nodes that are not new.