Hybris custom Category itemtype not syncing - categories

I've created my own Itemtype extending Category:
<itemtype code="BrandCategory" extends="Category">
<attributes>
<attribute qualifier="hide" type="java.lang.Boolean">
<persistence type="property"/>
<defaultvalue>java.lang.Boolean.FALSE</defaultvalue>
<modifiers read="true" write="true" optional="false" search="true"/>
</attribute>
</attributes>
</itemtype>
However, when I assign this category to any Product that already has other categories and I do a catalog synchronization, all the categories do copy to online except the custom ones (BrandCategory).
How can I fix this bug?

you need to update SyncAttributeDescriptorConfig and it can be done either via Backoffice or via Impex.
"#%groovy%
def query = '''SELECT {pk} FROM {<CustomJOBName>CatalogVersionSyncJob}'''
def syncJobs = flexibleSearchService.search(query).result
//forcing all sync jobs to create sync descriptors, if not created
syncJobs.each { syncJob -> syncJob.getSyncAttributeConfigurations() }
"
UPDATE GenericItem[processor = de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor]; pk[unique = true]
$attribute = attributeDescriptor(enclosingType(code), qualifier)[unique = true]
UPDATE SyncAttributeDescriptorConfig[batchmode = true]; $attribute ; includedInSync
; BrandCategory:hide ; true
UPDATE AttributeDescriptor; enclosingType(code)[unique = true]; qualifier[unique = true]; unique
; BrandCategory ; catalogVersion ; true
To run groovy in Impex, please add this property to local. properties.
Disable legacy scripting (makes groovy work at impex)
impex.legacy.scripting=false
or run impex via enabling the code execution.

Try adding the new type(i.e BrandCategory) into your product synchronization job as a root type as depicted in below image:

Related

Need to change Access Control of Published Items though api

In Smartsheet I have downloaded Published Items list from user management. Using this list I need to change the Access control (Public/Organization) value through api. Please help. Thanks
Depending on the type of object you're updating (Sheet, Report, or Dashboard), the operations you'll use are as follows:
Set Sheet Publish Status
Set Report Publish Status
Set Dashboad (Sight) Publish Status
I've included some code examples below (taken nearly verbatim from those you'll find in the docs I've linked to above.)
One additional note: You'll notice that the values written to the Published Items list that you manually export from Smartsheet differ from the values used by the API. For example, the Access Control column of exported data contains values like Organization and Public -- where as the corresponding values used by the API are ORG and ALL.
Example #1: SHEET --> Set ReadOnlyFullAccessibleBy to ALL, ReadWriteAccessibleBy to ORG
SheetPublish sheetPublish = new SheetPublish();
sheetPublish.ReadOnlyLiteEnabled = false;
sheetPublish.ReadOnlyFullEnabled = true;
sheetPublish.ReadOnlyFullAccessibleBy = "ALL";
sheetPublish.ReadWriteEnabled = true;
sheetPublish.ReadWriteAccessibleBy = "ORG";
sheetPublish.IcalEnabled = false;
smartsheet.SheetResources.UpdatePublishStatus(
4583614634583940, // sheetId
sheetPublish
);
Example #2: Report --> Set ReadOnlyFullAccessibleBy to ORG
ReportPublish reportPublish = new ReportPublish();
reportPublish.ReadOnlyFullEnabled = true;
reportPublish.ReadOnlyFullAccessibleBy = "ORG";
smartsheet.ReportResources.UpdatePublishStatus(
1653087851556740, // reportId
reportPublish
);
Example #3: Dashboard (Sight) --> Set ReadOnlyFullAccessibleBy to ALL
SightPublish publish = new SightPublish();
publish.ReadOnlyFullEnabled = true;
publish.ReadOnlyFullAccessibleBy = "ALL";
smartsheet.SightResources.SetPublishStatus(
5363568917931908, // sightId
publish
);

Why does Jooq code-generation break with PostGIS?

Context - I am trying out Postgres' Geographic Information System extension PostGis that enables stories latitude and longitudes as Point and operations on it.
If I understand correctly then I need to add a custom converter that can convert the point between JOOQ and PostGis and add it to the gradle file.
Problem - When I generate the jooq-code, few files are generated incorrectly and have the fields defined twice which fail compilation. These are:
<configured-generation-dir>/tables/StValuecount.java
<configured-generation-dir>/tables/records/StValuecountRecord.java
<configured-generation-dir>/tables/records/StValuepercentRecord.java
<configured-generation-dir>/tables/_StValuecount.java
<configured-generation-dir>/tables/records/_StValuecountRecord.java
<configured-generation-dir>/tables/_StHistogram.java
<configured-generation-dir>/tables/records/_StHistogramRecord.java
<configured-generation-dir>/tables/_StQuantile.java
Gradle config =>
jooq{
myAwesomeApp(sourceSets.main){
logging = 'WARN'
jdbc {
driver = 'org.postgresql.Driver'
url = db_url
user = db_user
password = db_password
}
generator {
name = 'org.jooq.codegen.DefaultGenerator'
strategy {
name = 'org.jooq.codegen.DefaultGeneratorStrategy'
}
database {
name = 'org.jooq.meta.postgres.PostgresDatabase'
inputSchema = 'public'
forcedTypes {
forcedType {
userType = 'org.postgis.Point'
converter = 'com.example.JooqBreaksWithPostGis.jooq.converters.PostgresPointJooqConverter'
expression = '.*\\.point'
types = '.*'
}
}
}
generate {
routines = false
relations = true
deprecated = false
records = true
immutablePojos = false
fluentSetters = true
}
target {
packageName = 'jooq.fancy.app'
directory = 'src/main/java/generated'
}
}
}
}
What am I doing wrong?
I have also created a minimal project where I have reproduced the problem in case someone wants to quickly try it.
Steps to reproduce
Checkout project
git clone git#github.com:raj-saxena/JooqBreaksWithPostGis.git
Go to the project directory and start postgis docker container with
docker-compose up
Similarly, to remove postgis docker container run
docker-compose down
Run migrations that add a simple City table containing Point type with
./gradlew flywayMigrate
I have added few rows in a second migration to verify if the DB structure was working. Details to connect to Postgres instance in the build.gradle file.
Generate jooq files with
./gradlew generateMyAwesomeAppJooqSchemaSource
Verify that the files are generated in the configured src/main/java/generated directory.
Verify that the files mentioned above fail to compile.
Taking Lukas' advice, I added the exclude configuration to the jooq config as below:
database {
name = 'org.jooq.meta.postgres.PostgresDatabase'
...
excludes = '.*ST_ValueCount' +
'|.*St_Valuepercent' +
'|.*St_Histogram' +
'|.*St_Quantile' +
'|.*St_Approxhistogram' +
'|.*St_PixelOfValue' +
'|.*St_Approxquantile' +
'|.*ST_Tile'
}
This allowed the code to compile.
This sounds a lot like https://github.com/jOOQ/jOOQ/issues/4055. jOOQ 3.11 currently cannot handle overloaded table valued functions in any RDBMS that supports table valued functions. Your best option here is to exclude all the affected functions from the code generation, using <excludes>:
https://www.jooq.org/doc/latest/manual/code-generation/codegen-advanced/codegen-config-database/codegen-database-includes-excludes/

Strange behaviour of Grails' application connected to PostgreSQL

I'm trying to switch my grails application from h2 to PostgreSQL.
Steps I've done to reach my goal:
Download JDBC from http://jdbc.postgresql.org/download.html (JDBC4 Postgresql Driver, Version 9.3-1100)
Attach JDBC to /lib folder
Change DataSource. Now it looks like:
dataSource {
pooled = true
driverClassName = "org.postgresql.Driver"
dialect="org.hibernate.dialect.PostgreSQLDialect"
username = "postgres"
password = "admin"
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
//url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
url = "jdbc:postgresql://localhost:5432/admin_panel"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:postgresql://localhost:5432/admin_panel"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:postgresql://localhost:5432/admin_panel"
pooled = true
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
}
}
And now the game starts. I type 'run-app' in GGTS and I get an error. Objects I'm trying to create using BootStrap cannot be initialized because of Validation: Error initializing the application: Validation Error(s) occurred during save() .
It is really strange because the message says that reference to previously created object is null: Field error in object 'adminpanel.component.Text' on field 'subpage': rejected value [null];.
There should be no possibility that "subpage" is null in this line, so I go to the pgAdmin III to check if this record is created and there I notice that no table is created at all.
Everetyhing works if application is connected to H2, but starts to freak out when I switch it to postgres. Additionally, when I remove everything from BootStrap, application starts and I can create objects normally, but I still cannot see them into pgAdmin. Do you have any advice what else can I check or why GORM does not create tables in my app when I use PostgreSQL ?
Thanks in advance.
EDIT:
I found the source of the problem after few tests more...
PostgreSQL gives a strange value for 'id' column in every table. When I was using H2, I had values from 1..x in every table, in PostgreSQL I have something like this:
table1
id:
1
2
3
-
7
8
9
table2
id:
4
5
6
-
10
11
As you probably noticed, values are given interchangeably for all rows in different tables, so I cannot have e.g. object table1 with id 1 and object table2 with id 1. Do you have idea why?
Grails/Hibernate uses Sequence for object ID for databases like Postgres (or Oracle, etc). By default, Grails uses a shared sequence (hibernate_sequence). So all object will have uniq id, but unique per whole database, not per table.
You can configure domain to use a different Sequence for a domain, like:
static mapping = {
id generator: 'sequence', params: [sequence: 'my_own_sequence']
}
See also
http://www.postgresql.org/docs/9.1/static/sql-createsequence.html
http://grails.org/doc/2.3.4/ref/Database%20Mapping/id.html

ItemConsolidatedQuery Find by Custom Field

In QuickBooks Desktop, I have an inventory item with a custom field called code. The value of the code is 12345. I need to pull a inventory item where the custom field code is 12345.
Here is my XML:
<?xml version="1.0" encoding="utf-8"?><ItemConsolidatedQuery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.intuit.com/sb/cdm/v2"><CustomFieldEnable>true</CustomFieldEnable><NameContains>temple</NameContains></ItemConsolidatedQuery>
I know the item's name, so I tried to query by it. There are 3 items with the same name, so I attempted to query them later. I am unable to see any custom field data:
http://pastebin.com/FBD1na0s
I know that the custom field exists. Here is my C# code:
Intuit.Ipp.Data.Qbd.ItemConsolidatedQuery itQuery = new Intuit.Ipp.Data.Qbd.ItemConsolidatedQuery();
itQuery.NameContains = "temple";
itQuery.CustomFieldEnable = true;
itQuery.CustomFieldEnableSpecified = true;
itQuery.CustomFieldFilter = Intuit.Ipp.Data.Qbd.customFieldFilterEnumType.Include;
var itemsList = itQuery.ExecuteQuery<Intuit.Ipp.Data.Qbd.ItemConsolidated>(ds.ServiceContext);
Is there a C# example to query custom fields in QBD?
Have you tried adding this line:
itQuery.CustomFieldFilterSpecified = true;
Also, custom fields in QB are secured by OwnerID. Probably theOwnerID must be specified in itQuery.CustomFieldQueryParam; I haven't experimented with it yet.
Need to include OwnerIDList in the request. See the OSR for examples.

DOM + need to remove element from XML bt VB script

I have the following VB script , I want to remove the "NET2 ID" element from name list
how to remove the NET2 ID element , need first to verify if NET2 defined and then to delete it
THX
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load("\\dir\d.xml")
Set objRoot = objXMLDoc.documentElement
Set objExNode = objRoot.removeChild(objRoot.childNodes.item(1))
the XML file:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<root version="3.0">
<names>
<NET1 ID="10.10.10.1-10" />
<NET2 ID="10.10.10.1-10" />
</names>
</root>
You can use XPath to determine if the node exists then remove it. Something like this:
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load("\\dir\d.xml")
Set objRoot = objXMLDoc.documentElement
If Not objRoot.selectSingleNode("./names/NET2") Is Nothing Then
Set objExNode = objRoot.firstChild.removeChild(objRoot.firstChild.childNodes(1))
End If
Also, the element NET2 is a child of "names" and not "root", which is the documentElement, so
Set objExNode = objRoot.removeChild(objRoot.childNodes.item(1))
becomes
Set objExNode = objRoot.firstChild.removeChild(objRoot.firstChild.childNodes(1))
EDIT: To add a new node you would do the following. 1 means NODE_ELEMENT
Set newNode = objXMLDoc.createNode(1, "NET3", "")
Set id = objXMLDoc.createAttribute("ID")
id.Value = "newIDValue"
newNode.attributes.setNamedItem(id)
objRoot.firstChild.appendChild(newNode)