Set value text field in Activiti Worflow (Alfresco Model) - java

I have a Workflow with 2 tasks, and first task has a model with a text field (wfRepromaq:ObsAnaliseCredito).
I want to show this field on my next task with value informed on my first task when i run workflow in the Alfresco Cummunity.
My Models:
1ª Task:
<type name="wfRepromaq:analisarCredito">
<title>Analisar Crédito</title>
<parent>wfRepromaq:iniciarFluxo</parent>
<properties>
<!-- Custom field-->
<property name="wfRepromaq:ObsAnaliseCredito">
<title>Observação Analise de Crédito</title>
<type>d:text</type>
<mandatory>true</mandatory>
</property>
<!-- End fied-->
</properties>
</type>
2ª Task:
<type name="wfRepromaq:analiseComercialPedido">
<title>Análise Pedido Gerência Comercial</title>
<parent>wfRepromaq:analisarCredito</parent>
<properties>
<property name="wfRepromaq:reviewOutcome3">
<type>d:text</type>
<constraints>
<constraint type="LIST">
<parameter name="allowedValues">
<list>
<value>Aprovado</value>
<value>Reprovado</value>
</list>
</parameter>
</constraint>
</constraints>
</property>
</properties>
<overrides>
<property name="bpm:outcomePropertyName">
<default>{ecmrepromaq.com.br/workflow/1.0}reviewOutcome3</default>
</property>
</overrides>
</type>
My Share-Config:
<config evaluator="task-type" condition="wfRepromaq:analiseComercialPedido">
<forms>
<form>
<field-visibility>
<show id="bpm:workflowDescription" />
<show id="packageItems" />
<show id="bpm:comment" />
<show id="wfRepromaq:ObsAnaliseCredito" />
<show id="wfRepromaq:reviewOutcome3" />
</field-visibility>
<appearance>
<field id="packageItems" read-only="true"/>
<field id="bpm:workflowDescription" label-id="workflow.field.message" read-only="true">
<control template="/org/alfresco/components/form/controls/textarea.ftl">
<control-param name="style">width: 95%</control-param>
</control>
</field>
<field id="wfRepromaq:reviewOutcome3" read-only="false">
<control template="/org/alfresco/components/form/controls/workflow/activiti-transitions.ftl" />
</field>
</appearance>
</form>
</forms>
</config>
What i have to do to the field "wfRepromaq:ObsAnaliseCredito" load with value informed before ?
Thanks!!

I think what you need to do is more on the workflow :
you need to pass your param in a taskListener (complete event) to your next step :
<userTask id="alfrescoUsertask1" name="taskName" activiti:assignee="${initiator.properties.userName}" activiti:formKey="wfRepromaq:analisarCredito">
<extensionElements>
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string> <![CDATA[execution.setVariable('wfRepromaq_ObsAnaliseCredito', task.getVariable('wfRepromaq_ObsAnaliseCredito'));]]></activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
</userTask>
...

Related

Change value in XML file via Android Java

I want to change the "value" and "defaultValue" of the "drop" that contains "a33"
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<settings version="-1">
<setting id="1" name="a1" value="VAL555" drop="a12" defaultValue="VAL555" default="false" tag="null" />
<setting id="2" name="a2" value="VAL555" drop="a22" defaultValue="VAL555" default="false" tag="null" />
<setting id="3" name="a3" value="VAL555 <== I WANT TO CHANGE THIS" drop="a33" defaultValue="VAL555 <== I WANT TO CHANGE THIS" default="false" tag="null" />
<setting id="4" name="a4" value="VAL555" drop="a44" defaultValue="VAL555" default="false" tag="null" />
<setting id="5" name="a5" value="VAL555" drop="a55" defaultValue="VAL555" default="false" tag="null" />
</settings>
I want to do this for an app in Android Java
Currently, I can't go anywhere.
I have no idea where to start from, or where to look for.

OData function returning a collection of entities fails with PowerQuery

I got this error while using PowerQuery on a OData service I’m currently developing:
When writing a JSON response, a user model must be specified and the
entity set and entity type must be passed to the
ODataMessageWriter.CreateODataEntryWriter method or the
ODataFeedAndEntrySerializationInfo must be set on the ODataEntry or
ODataFeed that is being written.
This occurs when invoking from PowerQuery a bound function that returns a collection of entities. When invoked from a web browser, the response is (JSON format):
{
"#odata.context": "http://localhost:8080/ODataPrototype/ODataPrototype.svc/$metadata#Collection(Demo.ODataPrototype.Count)",
"value": [
{
"RowCount": 1
},
{
"RowCount": 2
},
{
"RowCount": 3
},
{
"RowCount": 4
}
]
}
I use the Olingo V4 library. A stripped down version of my metadata would be:
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
<edmx:DataServices>
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="Demo.ODataPrototype">
<EntityType Name="Instance">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="Edm.Int32" />
<Property Name="Name" Type="Edm.String" />
<Property Name="Description" Type="Edm.String" />
<Property Name="Tag" Type="Edm.String" />
<Property Name="Xid" Type="Edm.Int64" />
<Property Name="Properties" Type="Collection(Demo.ODataPrototype.Property)" />
</EntityType>
<EntityType Name="Count">
<Property Name="RowCount" Type="Edm.Int32" />
</EntityType>
<ComplexType Name="Property">
<Property Name="Name" Type="Edm.String" />
<Property Name="Value" Type="Edm.String" />
</ComplexType>
<Function Name="GetData" EntitySetPath="Instance/Demo.ODataPrototype.Count" IsBound="true">
<Parameter Name="Instance" Type="Demo.ODataPrototype.Instance" />
<Parameter Name="From" Type="Edm.DateTimeOffset" />
<Parameter Name="To" Type="Edm.DateTimeOffset" />
<ReturnType Type="Collection(Demo.ODataPrototype.Count)" />
</Function>
<EntityContainer Name="Container">
<EntitySet Name="Instances" EntityType="Demo.ODataPrototype.Instance"></EntitySet>
<EntitySet Name="Count" EntityType="Demo.ODataPrototype.Count" />
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
Would anyone know what I'm missing?
I found the solution. The context in my JSON response defines the result as a collection of type IVserver.ODataPrototype.Count:
"#odata.context": "http://localhost:8080/ODataPrototype/ODataPrototype.svc/$metadata#Collection(IVserver.ODataPrototype.Count)"
But PowerQuery needs an entityset:
"#odata.context": "http://localhost:8080/ODataPrototype/ODataPrototype.svc/$metadata#Count"
The EntitySet "Count" must be declared in the EntityContainer.
To get the EntitySet in the #odata.context, an entityset must be set when building the ContextURL. Example:
final ContextURL contextURL = ContextURL.with().entitySet(responseEdmEntitySet).selectList(selectList).serviceRoot(baseURI).build();
And, the methods asCollection() and type() must not be called.

How to add Annotations elements in metadata generated by Apache Olingo V2.0?

I have developed Odata service for a system entity which generates a metadata but however I cant figure out how to add Annotations element to it. Sample Metadata generated is as follows :-
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" xmlns:sap="http://www.sap.com/Protocols/SAPData" Version="1.0">
<edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
m:DataServiceVersion="1.0">
<Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm" Namespace="myNamespace" sap:schema-version="1">
<EntityType Name="System">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="Edm.Int32" Nullable="false" />
<Property Name="name" Type="Edm.String" sap:label="System Name" sap:creatable="false"
sap:updatable="false" sap:sortable="false" sap:required-in-filter="true"/>
<Property Name="description" Type="Edm.String" />
<Property Name="status" Type="Edm.String" />
<Property Name="type" Type="Edm.String" />
</EntityType>
<EntityContainer Name="ODataEntityContainer" m:IsDefaultEntityContainer="true">
<EntitySet Name="Systems" EntityType="myNamespace.System" />
<FunctionImport Name="NumberOfSystems" ReturnType="Collection(myNamespace.System)"
m:HttpMethod="GET" />
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
I need to add following elements to above metatada
<Annotations Target="myNamespace.System"
xmlns="http://docs.oasis-open.org/odata/ns/edm">
<Annotation Term="com.sap.vocabularies.UI.v1.LineItem">
<Collection>
<Record Type="com.sap.vocabularies.UI.v1.DataField">
<PropertyValue Property="Value" Path="name" />
</Record>
<Record Type="com.sap.vocabularies.UI.v1.DataField">
<PropertyValue Property="Value" Path="description"/>
</Record>
<Record Type="com.sap.vocabularies.UI.v1.DataField">
<PropertyValue Property="Value" Path="status" />
</Record>
</Collection>
</Annotation>
</Annotations>
I came across the org.apache.olingo.commons.api.edm.provider.annotation package but cant find any suitable API. Please let me know how should I proceed.
Thanks in advance.
The annotations you would like to use have been introduced with OData V3 which is why they are not directly supported with the Olingo V2 library.
You can use the EdmProvider AnnotationElement and AnnotationAttribute classes to mimic this behaviour though. For example You can create a AnnotationElement with the name "Annotations" this element will then have the "AnnotationAttribute" Target=SomeString. Since an "AnnotationElement" can have child elements you can put your Collection element there. Namespaces are also handled with "AnnotationAttributes".
You can only attach the annotation to Edm elements which are derived from the EdmAnnotatable interface. So this is a difference to V3.
This is currently the only way to get this behaviour with Olingo V2.

WSO2ESB Proxy - Payload mediator auto population

I want to populate payload mediator with the response from a first service and this payload is going to be sent to another service. I used context expression and everything seems correct. But payload mediator is not getting populated. When the message built to send to the second service, payload remains blank. I used ctx path expression shown below to populate.
Here is the proxy service configuration,
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="CreditProxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full">
<property name="sequence" value="inSequence - request for CreditProxy"/>
</log>
<property xmlns:sam="http://samples.esb.wso2.org"
name="ORG_ID"
expression="//sam:credit/sam:id"/>
<property xmlns:sam="http://samples.esb.wso2.org"
name="ORG_AMOUNT"
expression="//sam:credit/sam:amount"/>
<enrich>
<source type="inline" clone="true">
<sam:get xmlns:sam="http://samples.esb.wso2.org">
<sam:id>?</sam:id>
</sam:get>
</source>
<target type="body"/>
</enrich>
<enrich>
<source type="property" clone="true" property="ORG_ID"/>
<target xmlns:sam="http://samples.esb.wso2.org" xpath="//sam:get/sam:id"/>
</enrich>
<log level="full">
<property name="sequence" value="inSequence - request for PersonInfoService"/>
</log>
<property name="STATE" value="PERSON_INFO_REQUEST"/>
<send>
<endpoint>
<address uri="http://127.0.0.1:9764/services/PersonInfoService/"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="full"/>
<property xmlns:ns="http://samples.esb.wso2.org"
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"
xmlns:ax23="http://samples.esb.wso2.org/xsd"
name="address"
expression="/soapenv:Envelope/soapenv:Body/ns:getResponse/ns:return/ax23:address"
scope="default"
type="STRING"/>
<property xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"
xmlns:ns="http://samples.esb.wso2.org"
xmlns:ax23="http://samples.esb.wso2.org/xsd"
name="id"
expression="/soapenv:Envelope/soapenv:Body/ns:getResponse/ns:return/ax23:id"
scope="default"
type="STRING"/>
<property xmlns:ns="http://samples.esb.wso2.org"
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"
xmlns:ax23="http://samples.esb.wso2.org/xsd"
name="name"
expression="/soapenv:Envelope/soapenv:Body/ns:getResponse/ns:return/ax23:name"
scope="default"
type="STRING"/>
<payloadFactory media-type="xml">
<format>
<p:credit xmlns:p="http://samples.esb.wso2.org"><!--0 to 1 occurrence--><ax25:info xmlns:ax25="http://samples.esb.wso2.org"><!--0 to 1 occurrence--><xs:amount xmlns:xs="http://samples.esb.wso2.org/xsd">?</xs:amount>
<!--0 to 1 occurrence--><ax25:personInfo xmlns:ax25="http://samples.esb.wso2.org/xsd"><!--0 to 1 occurrence--><xs:address xmlns:xs="http://samples.esb.wso2.org/xsd">$1</xs:address>
<!--0 to 1 occurrence--><xs:id xmlns:xs="http://samples.esb.wso2.org/xsd">$2</xs:id>
<!--0 to 1 occurrence--><xs:name xmlns:xs="http://samples.esb.wso2.org/xsd">$3</xs:name>
</ax25:personInfo>
</ax25:info>
</p:credit>
</format>
<args>
<arg evaluator="xml" expression="$ctx:address"/>
<arg evaluator="xml" expression="$ctx:id"/>
<arg evaluator="xml" expression="$ctx:name"/>
</args>
</payloadFactory>
<send buildmessage="true">
<endpoint>
<address uri="http://127.0.0.1:9764/services/CreditService/"/>
</endpoint>
</send>
</outSequence>
<endpoint>
<address uri="http://127.0.0.1:9764/services/PersonInfoService/"/>
</endpoint>
</target>
<publishWSDL uri="file:./repository/samples/resources/proxy/CreditProxy.wsdl"/>
<description/>
</proxy>
What can be the reason for this?

Data Import in Solr 4.2 not working?

My data-config.xml is as follows and I have kept in the the Conf folder along with the solrconfig.xml :-
<dataConfig>
<dataSource name="Sample" driver="org.postgresql.Driver" url="jdbc:postgresql://localhost:5432/Sample" user="postgres" password="P#ssword">
<document name="oneDocs">
<entity dataSource="Sample" name="entity1" query="select FirstName from Employee">
<field column="EmpId" name="EmpId" />
<field column="FirstName" name="FirstName" />
<field column="LastName" name="LastName" />
</entity>
</document>
</dataSource>
</dataConfig>
And my solrconfig.xml is as follows :-
<requestHandler name="/dataimport"
class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</requestHandler>
I have also tried to add the libraries in the following ways :-
<lib dir="../../../contrib/extraction/lib" regex=".*\.jar" />
<lib dir="../../../dist/" regex="solr-cell-\d.*\.jar" />
<lib dir="../../../contrib/clustering/lib/" regex=".*\.jar" />
<lib dir="../../../dist/" regex="solr-clustering-\d.*\.jar" />
<lib dir="../../../contrib/dataimporthandler/lib/" regex=".*\.jar" />
<lib dir="../../dist/" regex="solr-dataimporthandler-\d.*\.jar" />
<lib dir="../../dist/" regex="postgresql-9.2-1002.jdbc3-\d.*\.jar" />
<lib dir="../../../contrib/langid/lib/" regex=".*\.jar" />
<lib dir="../../../dist/" regex="solr-langid-\d.*\.jar" />
<lib dir="../../../contrib/velocity/lib" regex=".*\.jar" />
<lib dir="../../../dist/" regex="solr-velocity-\d.*\.jar" />
<!-- If a 'dir' option (with or without a regex) is used and nothing
is found that matches, it will be ignored
-->
<lib dir="/total/crap/dir/ignored" />
I am getting the same error constantly :-
org.apache.solr.handler.dataimport.DataImportHandlerException: Data Config problem: DataImportHandler configuration file must have one <document> node.
at org.apache.solr.handler.dataimport.DataImporter.loadDataConfig(DataImporter.java:226)
at org.apache.solr.handler.dataimport.DataImporter.maybeReloadConfiguration(DataImporter.java:124)
at org.apache.solr.handler.dataimport.DataImportHandler.handleRequestBody(DataImportHandler.java:168)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:1797)
at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:637)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:343)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:141)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:365)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:926)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:988)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:635)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)
at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.solr.handler.dataimport.DataImportHandlerException: DataImportHandler configuration file must have one <document> node.
at org.apache.solr.handler.dataimport.DataImporter.readFromXml(DataImporter.java:250)
at org.apache.solr.handler.dataimport.DataImporter.loadDataConfig(DataImporter.java:223)
... 32 more
Please help to resolve this.This is eating away most of the time. Thanks
NOTE: I am using Postgres and Apache Tomcat 7 and Java 7 .
Your data-config.xml is flawed. You have wrapped the document elment into the datasource element. Both need to be on the same level as direct child of the dataConfig element.
This is why the exception you posted states:
Data Config problem: DataImportHandler configuration file must have
one node.
The XML parser does not find the document element as child node of dataConfig.
Try it like this:
<dataConfig>
<dataSource name="Sample" driver="org.postgresql.Driver" url="jdbc:postgresql://localhost:5432/Sample" user="postgres" password="P#ssword" />
<document name="oneDocs">
<entity dataSource="Sample" name="entity1" query="select FirstName from Employee">
<field column="EmpId" name="EmpId" />
<field column="FirstName" name="FirstName" />
<field column="LastName" name="LastName" />
</entity>
</document>
</dataConfig>
In your data-config.xml the document element should be a sibling to the dataSource element, not a child.
ie it should look like this;
<dataConfig>
<dataSource>
..
</dataSource>
<document>
..
</document>
</dataConfig>

Categories