Combine Hybris Impex Remove with Flexible Search - sap-commerce-cloud

I would like to remove some items from a table using Impex. The following example throws no errors, but nothing is removed.
REMOVE ProductReference;pk[unique=true]
"#% impex.exportItemsFlexibleSearch(""select {pk} from {ProductReference as pr} where {pr.referenceType}=( {{select {pk} from {ProductReferenceTypeEnum as prte} where {prte.code} = 'CROSSELLING'}})"");"
The query produces results as expected. Is REMOVE not compatible with flexible search, or am I missing something?
The problem is, that I am running an import over hotfolder and I want to remove all existing items beforehand. Alternative solutions are welcome.

Importing the query-
REMOVE ProductReference;pk[unique=true]
"#% impex.exportItemsFlexibleSearch(""select {pk} from {ProductReference as pr} where {pr.referenceType}=( {{select {pk} from {ProductReferenceTypeEnum as prte} where {prte.code} = 'CROSSELLING'}})"");"
is not working because you have not selected the Enable code execution checkbox.Also, as suggested by #B.M replacing the script with impex.includeSQLData() and #% impex.initDatabase() would not have any effect if the checkbox is not selected.However, selecting the checkbox and running the above script will give error, because there is no method by the name, exportItemsFlexibleSearch in the class MyImpExImportReader(which is called on running import).The method exportItemsFlexibleSearch is available in DeprecatedExporter (which is called on running export not import).Now, running this impex script in export will execute successfully without any error, but it won't remove anything. Instead, it will create a zip file with an impex and a script file. This script file will have the impex header for removing the items returned by the query. Using this zip file we can delete the items, conditionally.
Go to HMC -> Cronjobs -> Create a new cronjob of type Impex import job -> Upload the zip file in media attribute -> Create -> Run the impex.
This would delete the items returned by the query.There is another way of deleting the items selected by the query.

We need to export the script to generate zip file of import script and media file.Resultant zip file need to be imported with enablecodeexecution checked
Alternatively groovy script can be executed, an example:
import de.hybris.platform.servicelayer.search.FlexibleSearchQuery;
flexibleSearchService = spring.getBean("flexibleSearchService")
modelService = spring.getBean("modelService")
query = "select {pk} from {trigger}";
flexibleSearchService.search(query).result.each
{
modelService.remove(it)
}

use HAC -> SQL Query console to delete using direct SQL command.
Enable Commit code
After running the update go to Monitoring tab and clear the cache

Related

How do i make all rows of pytest-html single html report result file default to a collapsed state?

I use the pytest runner to get the output of results from my automated test frameworks (Selenium and RestAPI tests). I use the pytest-html plugin to generate a single page html result file at the end of the test. I initiate the test run with the following command (from an active VirtEnv session).
python -m pytest -v --html="api_name_test.html" --self-contained-html
(it's a little more complicated in that I use a powershell script to run this and provide a datetime stamped result file name and email the file when it's finished but it's essentially the above command)
When the reports are generated and I open this report html I find that all the non passing tests are expanded. I want to make it so all rows are collapsed by default (Failed, XFailed, Error etc..).
My project contains a conftest.py file at the diretory root and a pytest.ini file where I specify the directory for the test scripts
In the conftest.py file in my simplest projects, I have one optional hook to obtain the target url of the tests and put that in the report summary:
import pytest
from py._xmlgen import html
import os
import rootdir_ref
import simplejson
#pytest.mark.optionalhook
def pytest_html_results_summary(prefix):
theRootDir = os.path.dirname(rootdir_ref.__file__)
credentials_path = os.path.join(theRootDir, 'TestDataFiles', 'API_Credentials.txt')
target_url = simplejson.load(open(credentials_path)).get('base_url')
prefix.extend([html.p("Testing against URL: " + target_url)])
The Github page mentions that a display query can be used to collapse rows with various results, but it doesn't mention where this information is entered.
https://github.com/pytest-dev/pytest-html
"By default, all rows in the Results table will be expanded except those that have Passed. This behavior can be customized with a query parameter: ?collapsed=Passed,XFailed,Skipped"
Currently I'm unsure if the ?collapsed=... line goes in the command line, or the conftest as a hook, or do I need to edit the default style.css or main.js that comes with the pytest-html plugin? (Also i'm not familiar with css and only know a small amount of html). I'm assuming it goes in the conftest.py file as a hook but don't really understand how to apply it.
https://pytest-html.readthedocs.io/en/latest/user_guide.html#display-options
Auto Collapsing Table Rows
By default, all rows in the Results table will be expanded except those that have Passed.
This behavior can be customized either with a query parameter: ?collapsed=Passed,XFailed,Skipped or by setting the render_collapsed in a configuration file (pytest.ini, setup.cfg, etc).
[pytest]
render_collapsed = True
NOTE: Setting render_collapsed will, unlike the query parameter, affect all statuses.

Qlikview - append data to Excel

I have qvw file with sql query
Data:
LOAD source, color, date;
select source, color, date
as Mytable;
STORE Data into [..\QV_Data\Data.qvd] (qvd);
Then I export data to excel and save.
I need something to do that automatically instead of me
I need to run query every day and automatically send data to excel but keep old data in excel and append new value.
Can qlikview to do that?
For that you need to create some crazy macro that runs after a reload task in on open-trigger. If you schedule a windows task that execute a bat file with path to qlikview.exe with the filepath as parameters and -r flag for reload(?) you can probably accomplish this... there are a lot of code of similar projects to be found on google.
I suggest adding this to the loadscript instead.
STORE Table into [..\QV_Data\Data.csv] (txt);
and then open that file in excel.
If you need to append data you could concatenate new data onto the previous data.. something like:
Data:
load * from Data.csv;
//add latest data
concatenate(Data)
LOAD source, color, date from ...
STORE Data into [..\QV_Data\Data.csv] (txt);
I assume you have the desktop version so you don't have access to the Qlikview Management Console (if you do, this is obviously the best way).
So, without the Console, you should create a txt file with this command: "C:\Program Files\QlikView\Qv.exe" /r "\\thePathToYourFile\test.qvw". Save this file with .cmd file extension. After that you can schedule this command file with the windows task scheduler.

Automatically create folder of same name on file creation

Is there any way for me to set up sublime to automatically create a folder of the same name when I create certain files.
I create landing pages that all have a lp_ prefix to the filename, I would like to watch for when a file with this name is created and then automatically create a folder of the same name in another directory (for css and images).
Would this be possible with a plugin or something like Grunt?
Example:
Create file: lp_test.php
Automate Folder Creation: /lp/lp_test/
You can make a plugin that extends EventListener and overrides (for example) on_post_save_async. You can use this simple example as base:
import sublime, sublime_plugin, os
# We extend event listener
class ExampleCommand(sublime_plugin.EventListener):
# This method is called every time a file is saved (not only the first time is saved)
def on_post_save_async(self, view):
variables = view.window().extract_variables()
fileBaseName = variables['file_base_name'] # File name without extension
path = 'C:/desiredPath/css/' + fileBaseName
if fileBaseName.startswith('lp_') and not os.path.exists(path):
os.mkdir(path)
EDIT: changed on_post_save to on_post_save_async as it runs in a different thread and does not block the application. Thanks MattDMo for commenting it and for adding python highlighting.

oracle data pump import to another schema ora-31696

When trying to export import into a table into another schema i am facing the following issue:
ORA-31696: unable to export/import TABLE_DATA:"schemaowner"."tablename":"SYS_P41" using client specified AUTOMATIC method
ORA-31696: unable to export/import TABLE_DATA:"schemaowner"."tablename":"SYS_P42" using client specified AUTOMATIC method
ORA-31696: unable to export/import TABLE_DATA:"schemaowner"."tablename":"SYS_P43" using client specified AUTOMATIC method
ORA-31696: unable to export/import TABLE_DATA:"schemaowner"."tablename":"SYS_P44" using client specified AUTOMATIC method
I want to export all data from a table in one schema and import hem into another schema. The errors occur during import. Below is the command i used for export and the command for import which fails:
expdp schema1/schema1#db1 directory=MYDIR tables=schema1.tbl dumpfile=tbl.dmp logfile=tbl.log content=data_only version=10.2.0.4.0
The above works and damp file is created but when trying:
impdp schema2/schema2#db1 directory=MYDIR tables=tbl dumpfile=tbl.dmp logfile=tblload.log content=data_only version=10.2.0.40 remap_schema=schema1:schema2
The above fails with the error specified in the beginning. Can you please advise me what i am doing wrong. I would truly appreciate it
Also as a reference the commands i run them on a linux os with oracle 10

Expression Engine - Import Member Data, create XML file Parse Error

I am trying to use the the Utilities > Member Import Utility to create an XML file that I can then use to import member data.
I have about seventy members to import. I was able to work through the mapping with what appeared to be a good match, but when I click the button, I get the following error:
Line does not match structure
I am using a .csv file to bring the data and I have selected comma as the deliminator. I can map the fields but when I click Create XML I get the Parse error.
Any suggestions on how to resolve this?
Thanks.
I found the answer. I appears to automatically understand that it is relative. When I simply put the name of the file in it went in with error.
So the correct path is: customer.txt
However, because the username is a number and not alpha numeric it cannot be imported.

Resources