How to fix oData VDM generator error «trying to create the same field twice»? - sap-cloud-sdk

I use SAP Cloud SDK 2.19.1 and odata-generator-maven-plugin:2.19.1.
When I try to generate VDM by metadata-file from oData service /sap/opu/odata/sap/API_PRODUCT_SRV I get an error during the execution of a command mvn clean install:
Error: URI=file:/D:/opensap/firstapp/application/edmx/ApiProductSrv.edmx Line=1: Document root element "edmx:Edmx", must match DOCTYPE root "null".
Error: URI=file:/D:/opensap/firstapp/application/edmx/ApiProductSrv.edmx Line=1: Document is invalid: no grammar found.
…
[ERROR] Failed to execute goal com.sap.cloud.s4hana.datamodel:odata-generator-maven-plugin:2.19.1:generate (generate-consumption) on project firstapp-application: Execution generate-consumption of goal com.sap.cloud.s4hana.datamodel:odata-generator-maven-plugin:2.1
9.1:generate failed: trying to create the same field twice: Продукт -> [Help 1]
I use the metadata-file obtained at the address /sap/opu/odata/sap/API_PRODUCT_SRV/$metadata, but it contains Russian-language text. For example, in sap-annotations:
<Property Name="Product" Type="Edm.String" Nullable="false" MaxLength="40" sap:display-format="UpperCase" sap:label="Продукт" sap:quickinfo="Номер продукта"/>
When I specify the locale when retrieving the metadata file ($metadata?sap-language=EN), it is possible to generate VDM.
But is it possible to generate correct VDM by metadata-file without special instructions sap-language?
Thanks!

For the generated code the locale does not really matter. Therefore, we suggest you use explicitly the English locale to retrieve the metadata.
The tutorial of the SAP Cloud SDK implicitly assume that the default locale of your system is English.

Related

groovy RESTClient is not working on Windows 7 machine

I am trying to use the below lines to get API response, but its not working for me.
Please help me.
Groovy ver = 2.4.15
OS = windows 7
#Grab(group='org.codehaus.groovy.modules.http-builder',module='http-builder',version='0.7.1')
import groovyx.net.http.HTTPBuilder
As mentioned in the comments, I think the best place to start would be to run your script with the following flag turned on:
~> groovy -Dgroovy.grape.report.downloads=true <yourscript>
that should give you some logging indicating what the grape resolution is doing and hopefully where it tried to download the file from when it failed.
For an overview of the grape resolution mechanics, you can refer to the groovy documentation on grapes.
My guess is that groovy is trying multiple resolvers (i.e. maven central, jcenter, etc) and one of them is failing early even though a later one has the artifact. In a situation like this the resolution engine naturally should keep trying until it finds a working artifact but I have seen things fail this way before.
To modify the resolution order and behavior, you should look at the file:
<your user home dir>/.groovy/grapeConfig.xml
where, if the file does not exist, groovy uses the following default data for the file:
<ivysettings>
<settings defaultResolver="downloadGrapes"/>
<resolvers>
<chain name="downloadGrapes" returnFirst="true">
<filesystem name="cachedGrapes">
<ivy pattern="${user.home}/.groovy/grapes/[organisation]/[module]/ivy-[revision].xml"/>
<artifact pattern="${user.home}/.groovy/grapes/[organisation]/[module]/[type]s/[artifact]-[revision](-[classifier]).[ext]"/>
</filesystem>
<ibiblio name="localm2" root="file:${user.home}/.m2/repository/" checkmodified="true" changingPattern=".*" changingMatcher="regexp" m2compatible="true"/>
<!-- todo add 'endorsed groovy extensions' resolver here -->
<ibiblio name="jcenter" root="https://jcenter.bintray.com/" m2compatible="true"/>
<ibiblio name="ibiblio" m2compatible="true"/>
</chain>
</resolvers>
</ivysettings>
(from the groovy github repo)
Two things to note here:
The returnFirst attribute. The resolution engine will try the resolvers one by one and return the first hit for this specific artifact. If my hunch is correct, this is not working correctly and an early resolver is failing and not giving a later resolver a chance to resolve the artifact.
The list of resolvers is ordered so changing this order will affect the result.
So, long story short: turn on debugging and see if that gives anything.
Then either modify or create the grapeConfig.xml file and either:
change the order of the ibiblio elements to change the resolution order
add another maven resolver (i.e. add another ibiblio node) for a target you have verified has the artifact (and add it first in the chain to make sure one of the others does not fail first).
or play with the returnFirst flag to see if setting it to false resolves your issue

B2B hybris module gen does not work

AFter using b2b_acc recipe, i want to do module gen. like:
ant modulegen -Dinput.module=accelerator -Dinput.name=qqq -Dinput.package=com.fffff.sampa -Dinput.template=develop
but it gives error of
hybris "java.util.regex.PatternSyntaxException": Illegal repetition near index 0 ${YMODULE_TOKEN}(.*)
And there is no information about how to do for b2b.
What can i do? I need to develop a b2b website. Should i use extgen?
Now it gives this:
java.lang.IllegalArgumentException: cannot merge namespace
((fulfilmentprocess)) into (()) due to duplicate attribute
'ConsignmentProcess.done(java.lang.Boolean):((fulfilmentprocess))::YAttributeDescriptor[fulfilmentprocess-items.xml:18(AttributeTagListener)][PROPERTY]'
vs
'ConsignmentProcess.done(java.lang.Boolean):((yacceleratorfulfilmentprocess))::YAttributeDescriptor[yacceleratorfulfilmentprocess-items.xml:18(AttributeTagListener)][PROPERTY]'
When you are creating your custom extension using modulegen, you should delete existing template extension as well in your localextension.properties file.
Remove any of the following extensions that might appear in your localextensions.xml file
yacceleratorcore
yacceleratorfacades
yacceleratorstorefront
yacceleratorinitialdata
yacceleratortest
yacceleratorcockpits
yacceleratorfulfilmentproces
Read Here for more details on how to customize Accelerator using modulegen :
https://help.hybris.com/6.6.0/hcd/8ace75c786691014a5e9dcafa29d5410.html
Removing yacceleratorbackoffice work for me.
This issue is version-dependent but try removing yacceleratorfulfilmentproces or yacceleratorbackoffice from localextensions.xml and that may help.

Cannot resolve value 'homepage' for attribute 'startingPage' (hybris)

I created a project with ant modulegen. b2b from b2c recipe, because hybris wiki says this.
But i could not get a proper result on backoffice / wcms / website
for that, mystore shows empty for
Name
and
Content Catalogs
I found that inpex that is not working on hac admin.
This is path
mystoreinitialdata/import/coredata/stores/mystore/site.impex
This is the error:
INSERT_UPDATE CMSSite;uid[unique=true];theme(code);channel(code);stores(uid);contentCatalogs(id);defaultCatalog(id);defaultLanguage(isoCode);siteMapConfig(&siteMapConfigId);urlPatterns;active;previewURL;startingPage(uid,catalogVersion(CatalogVersion.catalog(Catalog.id[default=mystoreContentCatalog]),CatalogVersion.version[default=Staged])[default=mystoreContentCatalog:Staged]);urlEncodingAttributes;defaultPromotionGroup(Identifier)[default=mystorePromoGrp]
,8796093187112,,,column 12: could not resolve item for homepage| column 12: cannot resolve value 'homepage' for attribute 'startingPage';mystore;blue;B2C;mystore;mystoreContentCatalog;mystoreProductCatalog;en;mystoreSiteMapConfig;(?i)^https?://[^/]+(/[^?])?\?(.\&)?(site=mystore)(|\&.)$,(?i)^https?://mystore.[^/]+(|/.|\?.)$,(?i)^https?://api.hybrisdev.com(:[\d]+)?/rest/.$,(?i)^https?://localhost(:[\d]+)?/rest/.*$;true;/?site=mystore;homepage;storefront,language;
error is for that line
> # CMS Site
> INSERT_UPDATE CMSSite;uid[unique=true];theme(code);channel(code);stores(uid);contentCatalogs(id);defaultCatalog(id);defaultLanguage(isoCode);siteMapConfig(&siteMapConfigId);urlPatterns;active;previewURL;startingPage(uid,$contentCV);urlEncodingAttributes;defaultPromotionGroup(Identifier)[default=$promoGrp]
> ;$siteUid;blue;B2C;$storeUid;$contentCatalog;$productCatalog;$defaultLanguage;$storeUidSiteMapConfig;(?i)^https?://[^/]+(/[^?]*)?\?(.*\&)?(site=$siteUid)(|\&.*)$,(?i)^https?://$siteUid\.[^/]+(|/.*|\?.*)$,(?i)^https?://api\.hybrisdev\.com(:[\d]+)?/rest/.*$,(?i)^https?://localhost(:[\d]+)?/rest/.*$;true;$storefrontContextRoot/?site=$siteUid;homepage;storefront,language
I followed the recipe wiki and
https://wiki.hybris.com/pages/viewpage.action?pageId=294094425
that wiki. What am i doing wrong?
INSERT_UPDATE CMSSite;uid[unique=true];theme(code);channel(code);stores(uid);contentCatalogs(id);defaultCatalog(id);defaultLanguage(isoCode);urlPatterns;active;previewURL;startingPage(uid,$contentCV);urlEncodingAttributes;defaultPromotionGroup(Identifier)[default=PromoGrp];# unknown attributes [ContentPage.$contentCV] - cannot resolve item reference;# invalid item expression '# unknown attributes [ContentPage.$contentCV] - cannot resolve item reference' - unexpected expression at 45
,,,,unknown attributes [ContentPage.$contentCV] - cannot resolve item reference, invalid item expression '# unknown attributes [ContentPage.$contentCV] - cannot resolve item reference' - unexpected expression at 45;$siteUid;lambda;B2B;$storeUid;$contentCatalog;$productCatalog;$defaultLanguage;(?i)^https?://[^/]+(/[^?]*)?\?(.*\&)?(site=$siteUid)(|\&.*)$,(?i)^https?://$siteUid\.[^/]+(|/.*|\?.*)$;true;$storefrontContextRoot/?site=$siteUid;homepage;storefront,language,currency
Add this to your impex before importing CMS Site
INSERT_UPDATE SiteMapPage;&siteMapPage;code(code)[unique=true];frequency(code)[unique=true];priority[unique=true];active[default=true]
;Homepage;Homepage;daily;1.0;;
I think some Impex might have failed during your system initialization. So what I would suggest.
Since you have set up the custom extension with your store data, remove all OOTB stores(powertools, apparel-us etc.) from your localextension.xml file
Initialize your system. Look for the error log in the console, note down all Impex which fail to load
Correct those Impex and run it through hac Impex-Import
Once setup correctly your store correctly, you can follow this to access your site as root
You're using a version 6.7 of Hybris but you're following the wiki for the version 5.7.
Follow this link. Here instead you can find the trails.

Create C# class from reqif.xsd

I am trying to generate a C# class from the following ReqIF XSD file.
I have tried with xsd.exe which failed and now also with xsd2code which fails with the following error message (translation: reference to undeclared attribute group):
Xsd2Code Version 3.4.0.32990
Code generation utility from XML schema files.
Error: Verweis auf nicht deklarierte Attributgruppe http://www.w3.org/1999/xhtml:xhtml.style.attrib.
SubType: Unspecified
Rule:
I suppose the xsd file is not 100% correct. I tried to get some information about the xsd format, but with my limited knowledge I was not able to solve the issue.
Does somebody have an idea what could be wrong here or how I could proceed?
Thanks!
I was able to generate java code with the linked files and the following command line on Windows (make sure the files are all in the same directory to make your life easier):
NOTE: It took my PC about 15 minutes to get past the parsing stage. I had thought it was locked up, but grabbed some coffee and was pleasantly surprised when I returned.
"<path_to_xjc.exe>" "<path_to_reqif.xsd>" -b "<path_to_linked_xjb_file>" -extension -p <the.package.name.you.want.to.generate.to>
Link to files I used to generate

Getting following Error in Sphinx 4.0- 'helloLinguist' property:'grammar' - mandatory property is not set

I am using sphinx 4.0 recognizer.While am running my application for swapping two statically defined grammars at runtime, i am getting the error in ecllipse as " 'helloLinguist' property:'grammar' - mandatory property is not set! ". I am using the cofiguration xml file provided on the link http://cmusphinx.sourceforge.net/wiki/sphinx4:swappinggrammars. Please help.
You must have accidentally edited the configuration and removed/commented the entry, or you are removing the grammar element during runtime. In the configuration you linked the property is set:
<component name="helloLinguist"
type="edu.cmu.sphinx.linguist.flat.FlatLinguist">
<property name="grammar" value="helloGrammar"/>
</component>

Resources