SAP UI5 Smart Table Json Data Usage - sapui5

I've got a problem about usage of json data in smart table object. I'm getting json data from web service and I set that json data any other variable. How can I bind that variable to EntitySet ? In fact I haven't got any json file in my application folders.
Here is the application sample link that I used for my project;
https://sapui5.netweaver.ondemand.com/explored.html#/sample/sap.m.tutorial.walkthrough.27/code
Here is the my metadata.xml codes;
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmx:DataServices m:DataServiceVersion="1.0" m:MaxDataServiceVersion="3.0"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<Schema Namespace="UserModel" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityType Name="Users">
<Key>
<PropertyRef Name="TKID"/>
<PropertyRef Name="TKTX"/>
</Key>
<Property Name="TKTX" Type="Edm.String" Nullable="false" MaxLength="40" FixedLength="false" Unicode="true"/>
<Property Name="TKID" Type="Edm.Int16" Nullable="false"/>
</EntityType>
</Schema>
<Schema Namespace="ODataWebV2.Northwind.Model" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityContainer Name="UserModelEntities" m:IsDefaultEntityContainer="true" p6:LazyLoadingEnabled="true"
xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation">
<EntitySet Name="Users" EntityType="UserModel.Users"/>
<!--How can I bind my json data incoming from webservice ?-->
</EntityContainer>
</Schema>
</edmx:DataServices>
Thanks for your help.

Related

Receive bytea with asp .net api

First of all, sorry for the probable English mistakes
I created a table in my postgresql database using the entity framework.
In edmx in the creation section I passed as bytea, however in the mapping I used binary (primitive type use is necessary).
<EntityType Name="styleexample">
<Key>
<PropertyRef Name="id" />
</Key>
<Property Name="id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="example" Type="String" MaxLength="40" />
<Property Name="example1" Type="Binary" />
<Property Name="example2" Type="DateTime" />
</EntityType>
<EntityType Name="styleexample">
<Key>
<PropertyRef Name="id" />
</Key>
<Property Name="id" Type="int4" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="example" Type="varchar" MaxLength="40" />
<Property Name="example1" Type="bytea" />
<Property Name="example2" Type="timestamp" />
</EntityType>
The table was created with the correct typing
In the entity I referenced the column as byte []
In the column I inserted the base64 string of a png image, but in the service when I return the value is different from what I inserted
My response is also byte[]
It works. However, it returns the incorrect value. Is there a different way to do this process?
I solved the issue by adding to the service
var example1 = new StreamReader(new MemoryStream(estilo.example1));
var example1Stream = example1 .ReadToEnd();

jaysvcutil failing with TypeError: Cannot read property 'schemas' of undefined

I am trying to generate the model from an existing OData service through jaysvcutil and am getting:
[...]\node_modules\jaydata-odatajs\lib\odata\odatautils.js:385
throw err;
^
TypeError: Cannot read property 'schemas' of undefined
at Metadata.processMetadata ([...]\node_modules\jaydata-dynamic-metadata\lib\metadata.js:353:35)
at requestData ([...]\node_modules\jaydata-dynamic-metadata\lib\metadataHandler.js:46:42)
at [...]\node_modules\jaydata-odatajs\lib\odata\odatautils.js:382:13
at IncomingMessage.<anonymous> ([...]\node_modules\jaydata-odatajs\lib\odata\net.js:179:21)
at emitNone (events.js:72:20)
at IncomingMessage.emit (events.js:166:7)
at endReadableNT (_stream_readable.js:921:12)
at nextTickCallbackWith2Args (node.js:442:9)
at process._tickCallback (node.js:356:17)
I tried to condense the domain model into something really simple, so my current $metadata looks like this:
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">
<edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="1.0">
<Schema xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://schemas.microsoft.com/ado/2007/05/edm" Namespace="data">
<EntityType Name="Product">
<Key>
<PropertyRef Name="ProductId"/>
</Key>
<Property Name="ProductId" Type="Edm.Int64" Nullable="false"/>
<Property Name="ProductNo" Type="Edm.String" Nullable="true"/>
<Property Name="LifeTime" Type="Edm.Int64" Nullable="false"/>
<Property Name="Capacity" Type="Edm.Int64" Nullable="false"/>
<Property Name="PackingSize" Type="Edm.Int64" Nullable="false"/>
<Property Name="CreationTime" Type="Edm.DateTime" Nullable="false"/>
<Property Name="ModificationTime" Type="Edm.DateTime" Nullable="false"/>
</EntityType>
</Schema>
<Schema xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://schemas.microsoft.com/ado/2007/05/edm" Namespace="Namespace">
<EntityContainer Name="DomainData" m:IsDefaultEntityContainer="true">
<EntitySet Name="Product" EntityType="data.Product"/>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
This is an existing WCF DataService based OData provider using OData V1 and I am not able to change that - so please do not recommend updating the provider to V4.
Any help would be appreciated.
As per feedback from the JayData team:
JayData supports OData v4, as there have been multiple breaking changes in both OData and DataJS since v1.
and also
JayData 1.3.7 supports v2 and v3, but it does not support TypeScript and Angular 2.
I will therefore be looking at alternatives, presumably breezejs.

Fetching data from PostgreSQL database in Mule flow using JDBC transport

I have a Mule flow to fetch data from a table in a PostgreSQL database and convert the data into XML format and write to a file:
<mule ...>
<spring:bean id="Postgres-jdbcDataSource"
class="org.enhydra.jdbc.standard.StandardDataSource" destroy-method="shutdown">
<spring:property name="driverName" value="org.postgresql.Driver" />
<spring:property name="url"
value="jdbc:postgresql://host:port/schema?user=username&password=password" />
</spring:bean>
<jdbc:connector name="Postgres-jdbcConnector"
dataSource-ref="Postgres-jdbcDataSource" pollingFrequency="60000"
transactionPerMessage="false">
<jdbc:query key="read" value="SELECT * FROM tablename" />
</jdbc:connector>
<file:connector name="file_connector" fileAge="500"
streaming="false" pollingFrequency="60000" />
<flow name="Postgres-flow">
<jdbc:inbound-endpoint queryKey="read"
connector-ref="Postgres-jdbcConnector">
<jdbc:transaction action="ALWAYS_BEGIN" />
<property key="receiveMessageInTransaction" value="true" />
</jdbc:inbound-endpoint>
<custom-transformer name="Postgres-transformer"
class="com.example.transformer.DbToXmlTransformer" ignoreBadInput="false"
encoding="UTF-8" />
<file:outbound-endpoint connector-ref="file_connector"
path="/home/path" outputPattern="file.xml" responseTimeout="10000"
encoding="UTF-8" />
</flow>
</mule>
When I run this flow, the flow does not fetch data from DB and write to file. It does not throw any errors or exceptions either. But when I run the same flow for MySQL or SQLServer database, changing driverName and url properties accordingly, the flow works fine.
Any idea why the Postgres database does not work? Probably it requires different DataSource class?
There is also a Postgre data source for mule and you can use it instead of spring beans :
<jdbc:postgresql-data-source name="PostgreSQL_Data_Source" user="your user name" password="your pwd" url="jdbc:postgresql://localhost:5432/TestDB" transactionIsolation="UNSPECIFIED" doc:name="PostgreSQL Data Source"/>
Anyways... , with your existing config you can just check by keeping the JDBC inbound endpoint in a poll component and place a logger before File outbound to check the payload value.. If it gets payload value in logger ..that means it is fetching the value ..Let me know if it works ... you can try the following :-
<mule ...>
<spring:bean id="Postgres-jdbcDataSource"
class="org.enhydra.jdbc.standard.StandardDataSource" destroy-method="shutdown">
<spring:property name="driverName" value="org.postgresql.Driver" />
<spring:property name="url"
value="jdbc:postgresql://host:port/schema?user=username&password=password" />
</spring:bean>
<jdbc:connector name="Postgres-jdbcConnector"
dataSource-ref="Postgres-jdbcDataSource" pollingFrequency="60000"
transactionPerMessage="false">
<jdbc:query key="read" value="SELECT * FROM tablename" />
</jdbc:connector>
<file:connector name="file_connector" fileAge="500"
streaming="false" pollingFrequency="60000" />
<flow name="Postgres-flow">
<poll frequency="1000" doc:name="Poll">
<jdbc:inbound-endpoint queryKey="read"
connector-ref="Postgres-jdbcConnector">
<jdbc:transaction action="ALWAYS_BEGIN" />
<property key="receiveMessageInTransaction" value="true" />
</jdbc:inbound-endpoint>
</poll>
<!-- You can also use object to xml transformer if you are not using any custom transformer -->
<!--<mulexml:object-to-xml-transformer doc:name="Object to XML"/> -->
<custom-transformer name="Postgres-transformer"
class="com.example.transformer.DbToXmlTransformer" ignoreBadInput="false"
encoding="UTF-8" />
<logger message="Payload :- #[message.payload]" level="INFO" doc:name="Logger"/>
<file:outbound-endpoint connector-ref="file_connector"
path="/home/path" outputPattern="file.xml" responseTimeout="10000"
encoding="UTF-8" />
</flow>
</mule>
For more find the reference here for Postgre Database with Mule :- http://www.dotnetfunda.com/articles/show/2068/using-mule-studio-to-read-data-from-postgresqlinbound-and-write-it-to

specify a database schema for activiti-5.12.1 tables

I am going to use activiti-5.12.1, in my project.
here is the activiti.cfg.xml file:
<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration" >
<property name="databaseType" value="postgres" />
<property name="jdbcUrl" value="jdbc:postgresql://project:5432/MYPROJECT" />
<property name="jdbcDriver" value="org.postgresql.Driver" />
<property name="jdbcUsername" value="me" />
<property name="jdbcPassword" value="you" />
<property name="databaseSchemaUpdate" value="false" />
<property name="jobExecutorActivate" value="false" />
<property name="history" value="full" />
<property name="customPreVariableTypes">
<list>
<ref bean="activitiScriptNodeType" />
<ref bean="activitiScriptNodeListType" />
</list>
</property>
<property name="mailServerHost" value="mail.my-corp.com" />
<property name="mailServerPort" value="5025" />
</bean>
</beans>
I want to create activiti database on my own, by using the scripts which are available in activiti-engine-5.12.1.jar.
By default, the tables are created in public schema, but I want them to be in another schema like mySchema for example.
my questioin is how can I manage this, besides, how can I specify this in activiti.cfg.xml, to inform activiti engine api that activiti tables are in mySchema?
I am using MySQL database for activiti, so i have got some configuration like this to creat my own schema name :
<property name="databaseType" value="mysql" />
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activiti" />
<property name="jdbcDriver" value="com.mysql.jdbc.Driver" />
<property name="jdbcUsername" value="root" />
<property name="jdbcPassword" value="root" />
So as you using postgresql, i am not quite sure about whether the following code will work for you or not :
<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration" >
<property name="databaseType" value="postgres" />
<property name="jdbcUrl" value="jdbc:postgresql://project:5432/MYPROJECT/activiti" />
<property name="jdbcDriver" value="org.postgresql.Driver" />
<property name="jdbcUsername" value="me" />
<property name="jdbcPassword" value="you" />
<property name="databaseSchemaUpdate" value="false" />
<property name="jobExecutorActivate" value="false" />
<property name="history" value="full" />
<property name="customPreVariableTypes">
<list>
<ref bean="activitiScriptNodeType" />
<ref bean="activitiScriptNodeListType" />
</list>
</property>
<property name="mailServerHost" value="mail.my-corp.com" />
<property name="mailServerPort" value="5025" />
</bean>
Before deploying `activiti with new changes, mke sure that your database has the schema created.
Try changing the database's type to your database's name or "postgresql".
If you are using spring the below property helps:
spring.activiti.databaseSchema=MY_SCHEMA

Entity Framework: 0..1-to-many foreign key constraint not recognized?

I am using EF4 to map a DB schema to an object model; I initially generated the EDMX from the database but have been editing the XML directly (trying to leave the SSDL the same while changing the CSDL/MSL to approximate the object model I want). The database contains, among many other things, a couple tables with a (0..)1-to-many constraint via foreign key like so:
go
create table Options (
KitNodeID int primary key foreign key references KitNodes (KitNodeID),
[SKUID] int null foreign key (SKUID) references SKUs (SKUID)
)
go
create table Upgrades (
UpgradeID int identity (1, 1) primary key not null,
[Name] nvarchar(50) not null,
DefaultOptionID int null references Options (KitNodeID)
)
The relevant sections in the EDMX look like this:
[...]
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="DModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
<EntityContainer Name="DModelStoreContainer">
<AssociationSet Name="FK__Upgrades__Defaul__70DDC3D8" Association="DModel.Store.FK__Upgrades__Defaul__70DDC3D8">
<End Role="Options" EntitySet="Options" />
<End Role="Upgrades" EntitySet="Upgrades" />
</AssociationSet>
</EntityContainer>
<EntityType Name="Upgrades">
<Key>
<PropertyRef Name="UpgradeID" />
</Key>
<Property Name="UpgradeID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="50" />
<Property Name="DefaultOptionID" Type="int" />
</EntityType>
<Association Name="FK__Upgrades__Defaul__70DDC3D8">
<End Role="Options" Type="DModel.Store.Options" Multiplicity="0..1" />
<End Role="Upgrades" Type="DModel.Store.Upgrades" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Options">
<PropertyRef Name="KitNodeID" />
</Principal>
<Dependent Role="Upgrades">
<PropertyRef Name="DefaultOptionID" />
</Dependent>
</ReferentialConstraint>
</Association>
</Schema></edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema Namespace="DModel" Alias="Self" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityContainer Name="DEntities" annotation:LazyLoadingEnabled="true">
<EntitySet Name="Upgrades" EntityType="DModel.Upgrade" />
<AssociationSet Name="Upgrade_DefaultOption" Association="DModel.Upgrade_DefaultOption">
<End Role="Options" EntitySet="Options" />
<End Role="Upgrades" EntitySet="Upgrades" />
</AssociationSet>
</EntityContainer>
<Association Name="Upgrade_DefaultOption">
<End Role="Options" Type="DModel.Option" Multiplicity="0..1" />
<End Role="Upgrades" Type="DModel.Upgrade" Multiplicity="*" />
</Association>
<EntityType Name="Upgrade">
<Key>
<PropertyRef Name="UpgradeID" />
</Key>
<Property Name="UpgradeID" Nullable="false" annotation:StoreGeneratedPattern="Identity" Type="Int32" />
<Property Name="Name" Type="String" Nullable="false" MaxLength="50" Unicode="true" FixedLength="false" />
<NavigationProperty Name="DefaultOption" Relationship="DModel.Upgrade_DefaultOption" FromRole="Upgrades" ToRole="Options" />
<NavigationProperty Name="OptInOptions" Relationship="DModel.OptInOptions" FromRole="Upgrades" ToRole="Options" />
</EntityType>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
<edmx:Mappings>
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2008/09/mapping/cs">
<EntityContainerMapping StorageEntityContainer="DModelStoreContainer" CdmEntityContainer="DEntities">
<EntitySetMapping Name="Upgrades"><EntityTypeMapping TypeName="DModel.Upgrade"><MappingFragment StoreEntitySet="Upgrades">
<ScalarProperty Name="UpgradeID" ColumnName="UpgradeID" />
<ScalarProperty Name="Name" ColumnName="Name" />
</MappingFragment></EntityTypeMapping></EntitySetMapping>
<AssociationSetMapping Name="Upgrade_DefaultOption" TypeName="DModel.Upgrade_DefaultOption" StoreEntitySet="FK__Upgrades__Defaul__70DDC3D8">
<EndProperty Name="Upgrades">
<ScalarProperty Name="UpgradeID" ColumnName="UpgradeID"/>
</EndProperty>
<EndProperty Name="Options">
<ScalarProperty Name="KitNodeID" ColumnName="DefaultOptionID"/>
</EndProperty>
</AssociationSetMapping>
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
It will generate code, but when I try to use it I get an "Error 2007: The Table 'FK_Upgrades_Defaul__70DDC3D8' specified as part of this MSL does not exist in MetadataWorkspace." It looks like it can't find the underlying foreign key constraint that the SSDL is supposed to use, but I do see one with that name in the database.
Really, I feel I don't have a very good understanding of how this kind of mapping is supposed to work in general - is a foreign key constraint in the database really treated as an "associationset"? - but this is the closest I can work out. I don't know if anyone could diagnose the problem from the info I've given, but any pointers on where to look? I've tried various things like changing the StoreEntitySet to point to Options, etc. but they just result in different errors.
Try changing how you define your foreign key, see: How do I create a foreign key in SQL Server?
You will probably have to delete and recreate you model.