cancel
Showing results for 
Search instead for 
Did you mean: 

Copying properties from a type to an aspect

srowsell
Champ in-the-making
Champ in-the-making
In order to use the Forms Management add-on module – which is something I have to do – I need to migrate my documents from using Types to using Aspects.  I have to deal with a lot of documents – over a million, which isn't a lot in the grand scheme of things, but is a lot to work with all at once – and most of these are already done.  I wrote a web script which just attached the aspect to each document, then copied the contents of each property to a like-named property for the new Aspect.

There's this other Type, though, which is being stubborn.  The web script is pretty much exactly the same as the one which worked nicely for the first Type, and the only difference in the models of these two was that the second (problematic) one also attaches a few properties via an Aspect.  I will present the relevant information, and I'm hoping that someone can tell me what's going wrong.

The relevant message in the stack trace seems to be:

A single-valued property of this type may not be a collection

I would associate this with trying to fit a multi-valued property into a single-valued field, but since both are set to multiple I don't see how this could be happening.

Steve


//This is the .js file for the web script
var type=args.type;
var path=args.path;
var startTime=new Date();

if (path!=null)
{
   var pathArray=path.split("_");
}



var query = "+PATH:\"/app:company_home"
+"/st:"+search.ISO9075Encode("sites")

for(i=0;i<pathArray.length;i++)
{
  query+="/cm:"+search.ISO9075Encode(pathArray);
}
var count=0;
var counter=0;
query+="//*\"+TYPE:\""+type+"\"";
var results=search.luceneSearch(query);
   
   for (var i = 0;i<results.length;i++)
   {
counter++;
      
      results.addAspect("ed:commonProperties");
      results.addAspect("ed:eDocumentTaxes");
      results.properties["ed:esid"]=results.properties["eDoc:esid"];
      results.properties["ed:eDocumentDate"]=results.properties["eDoc:eDocumentDate"];
      results.properties["ed:eDocumentType"]=results.properties["eDoc:eDocumentType"];
      results.properties["ed:memberNameTx"]=results.properties["eDoc:memberNameTx"];
      results.properties["ed:statusTx"]=results.properties["eDoc:statusTx"];
      results.properties["ed:formTypeTx"]=results.properties["eDoc:formTypeTx"];
      results.properties["ed:expirationDateTx"]=results.properties["eDoc:expirationDateTx"];
      results.properties["ed:receiptNoTx"]=results.properties["eDoc:receiptNoTx"];
            results.properties["ed:sinTx"]=results.properties["eDoc:sinTx"];
      results.properties["ed:contractNoTx"]=results.properties["eDoc:contractNoTx"];
      results.properties["ed:yearTx"]=results.properties["eDoc:yearTx"];
      results.properties["ed:acctNoTx"]=results.properties["eDoc:acctNoTx"];
      results.properties["ed:branchNoTx"]=results.properties["eDoc:branchNoTx"];
            results.properties["ed:branchNameTx"]=results.properties["eDoc:branchNameTx"];
      results.properties["ed:transitTx"]=results.properties["eDoc:transitTx"];
      results.save();
      
if (!(results.hasAspect["ed:eDocumentTaxes"]))
{
count++
}
      
   }
var endTime=new Date();
model.endTime=endTime;
model.startTime=startTime;   
model.count=results.length+" "+count+" "+counter;
model.query=query;



//This is the model of the Type whose properties are getting transferred to the new Aspect
<?xml version="1.0" encoding="UTF-8"?>
<model xmlns="http://www.alfresco.org/model/dictionary/1.0"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.alfresco.org/model/dictionary/1.0
   ../../../../webapps/alfresco/WEB-INF/classes/alfresco/model/modelSchema.xsd"
   name="eDoc:model">
   <description>eDocuments Model</description>
   <author>Steve Rowsell</author>
   <version>1.0</version>
   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
   </imports>
   <namespaces>
      <namespace uri="edocuments.model" prefix="eDoc" />
   </namespaces>
   <types>
    
     <type name="eDoc:taxes">
         <title>Taxes</title>
         <parent>cm:content</parent>
         <properties>
         <property name="eDoc:memberNameTx">
               <title>Member Name</title>
               <description>Member Name</description>
               <type>d:text</type>
            <index enabled="true">
            <atomic>false</atomic>       <!– index in the background –>
            <stored>true</stored>       <!– store the property value in the index –>
            <tokenised>true</tokenised>
            </index>
            </property>
         <property name="eDoc:statusTx">
               <title>Status</title>
               <description>Status</description>
               <type>d:text</type>
            <index enabled="true">
            <atomic>false</atomic>       <!– index in the background –>
            <stored>true</stored>       <!– store the property value in the index –>
            <tokenised>true</tokenised>
            </index>
            </property>
         <property name="eDoc:formTypeTx">
               <title>Form Type</title>
               <description>Form Type</description>
               <type>d:text</type>
            <index enabled="true">
            <atomic>false</atomic>       <!– index in the background –>
            <stored>true</stored>       <!– store the property value in the index –>
            <tokenised>true</tokenised>
            </index>
            </property>
         
         <property name="eDoc:expirationDateTx">
               <title>Expiration Date</title>
               <description>Expiration Date</description>
               <type>d:date</type>
            <index enabled="true">
            <atomic>false</atomic>       <!– index in the background –>
            <stored>true</stored>       <!– store the property value in the index –>
            <tokenised>true</tokenised>
            </index>
            </property>
         <property name="eDoc:receiptNoTx">
               <title>Receipt Number</title>
               <description>Receipt Number</description>
               <type>d:text</type>
            <index enabled="true">
            <atomic>false</atomic>       <!– index in the background –>
            <stored>true</stored>       <!– store the property value in the index –>
            <tokenised>true</tokenised>
            </index>
            </property>
         <property name="eDoc:sinTx">
               <title>SIN</title>
               <description>Social Insurance Number</description>
               <type>d:text</type>
            <index enabled="true">
            <atomic>false</atomic>       <!– index in the background –>
            <stored>true</stored>       <!– store the property value in the index –>
            <tokenised>true</tokenised>
            </index>
            </property>
         <property name="eDoc:contractNoTx">
               <title>Contract Number</title>
               <description>Contract Number</description>
               <type>d:text</type>
            <index enabled="true">
            <atomic>false</atomic>       <!– index in the background –>
            <stored>true</stored>       <!– store the property value in the index –>
            <tokenised>true</tokenised>
            </index>
            </property>
         <property name="eDoc:yearTx">
               <title>Year</title>
               <description>Taxation Year</description>
               <type>d:text</type>
            <index enabled="true">
            <atomic>false</atomic>       <!– index in the background –>
            <stored>true</stored>       <!– store the property value in the index –>
            <tokenised>true</tokenised>
            </index>
            </property>
            <property name="eDoc:acctNoTx">
               <title>Account Number</title>
               <description>Account Number</description>
               <type>d:text</type>
            <index enabled="true">
            <atomic>false</atomic>       <!– index in the background –>
            <stored>true</stored>       <!– store the property value in the index –>
            <tokenised>true</tokenised>
            </index>
            </property>
            <property name="eDoc:branchNoTx">
               <title>Branch Number</title>
               <description>Branch Number</description>
               <type>d:text</type>
            <index enabled="true">
            <atomic>false</atomic>       <!– index in the background –>
            <stored>true</stored>       <!– store the property value in the index –>
            <tokenised>true</tokenised>
            </index>
            </property>
         <property name="eDoc:branchNameTx">
               <title>Branch Name</title>
               <description>Branch Name</description>
               <type>d:text</type>
            <index enabled="true">
            <atomic>false</atomic>       <!– index in the background –>
            <stored>true</stored>       <!– store the property value in the index –>
            <tokenised>true</tokenised>
            </index>
            </property>
            <property name="eDoc:transitTx">
               <title>Transit</title>
               <description>Transit</description>
               <type>d:text</type>
            <index enabled="true">
            <atomic>false</atomic>       <!– index in the background –>
            <stored>true</stored>       <!– store the property value in the index –>
            <tokenised>true</tokenised>
            </index>
            </property>
         
         </properties>
      <mandatory-aspects>
            <aspect>eDoc:eDocumentProperties</aspect>
        </mandatory-aspects>
      </type>
   </types>


   <aspects>
      <aspect name="eDoc:eDocumentProperties">
         <title>e-Document Properties</title>
         <properties>
            <property name="eDoc:eDocumentDate">
               <title>Document Date</title>
               <type>d:date</type>
            </property>
            <property name="eDoc:eDocumentType">
               <title>Document Type</title>
               <type>d:text</type>
            </property>
                <property name="eDoc:esid">
               <title>mid</title>
                     <description>mid</description>
                     <type>d:text</type>
                         <multiple>true</multiple>
                         <index enabled="true">
                        <atomic>false</atomic>       <!– index in the background –>
                        <stored>true</stored>       <!– store the property value in the index –>
                        <tokenised>true</tokenised>
                         </index>
            </property>
         </properties>
      </aspect>
   </aspects>


</model>


<?xml version="1.0" encoding="UTF-8"?>
<!– First namespace prefix in namespace array is used for model prefix –>
<model xmlns="http://www.alfresco.org/model/dictionary/1.0" name="ed:eDocumentsAspect">
   <description>Alfresco Form Builder Project</description>
   <author></author>
   <version>1.0</version>
   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
   </imports>
   <namespaces>
      <namespace uri="ed.model" prefix="ed" />
   </namespaces>
   <aspects>
      <aspect name="ed:commonProperties">
         <title>eDocument Properties</title>
         <properties>
            <property name="ed:esid">
               <title>esid</title>
               <type>d:text</type>
               <multiple>true</multiple>
            </property>
            <property name="ed:eDocumentType">
               <title>eDocument Type</title>
               <type>d:text</type>
            </property>
            <property name="ed:eDocumentDate">
               <title>eDocument Date</title>
               <type>d:date</type>
            </property>
         </properties>
      </aspect>
      <aspect name="ed:eDocumentTaxes">
         <title>Tax Document Properties</title>
         <properties>
            <property name="ed:memberNameTx">
               <title>Member Name</title>
               <type>d:text</type>
            </property>
            <property name="ed:statusTx">
               <title>Status</title>
               <type>d:text</type>
            </property>
            <property name="ed:formTypeTx">
               <title>Form Type</title>
               <type>d:text</type>
            </property>
            <property name="ed:expirationDateTx">
               <title>Expiration Date</title>
               <type>d:date</type>
            </property>
            <property name="ed:receiptNoTx">
               <title>Receipt Number</title>
               <type>d:text</type>
            </property>
            <property name="ed:sinTx">
               <title>SIN</title>
               <type>d:text</type>
            </property>
            <property name="ed:contractNoTx">
               <title>Contract Number</title>
               <type>d:text</type>
            </property>
            <property name="ed:yearTx">
               <title>Year</title>
               <type>d:text</type>
            </property>
            <property name="ed:acctNoTx">
               <title>Account Number</title>
               <type>d:text</type>
            </property>
            <property name="ed:branchNoTx">
               <title>Branch Number</title>
               <type>d:text</type>
            </property>
            <property name="ed:branchNameTx">
               <title>Branch Name</title>
               <type>d:text</type>
            </property>
            <property name="ed:transitTx">
               <title>Transit</title>
               <type>d:text</type>
            </property>
         </properties>
      </aspect>
   </aspects>
</model>


It gets called with a URL like this:


http://alfprod1:8080/alfresco/service/applyTaxesAspect?path=roler_documentLibrary_Taxes_2011_2011-12...



//This is the stack trace I get when I run the web script
09:00:57,305 ERROR [org.springframework.extensions.webscripts.AbstractRuntime] Exception from executeScript - redirecting to status template error: 11270008 Wrapped Exception (with status template): 11271169 Failed to execute script '/scripts/applyStatementAspect/applyTaxesAspect.get.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts)': 11271168 A single-valued property of this type may not be a collection:
   Property: Name: {ed.model}esid
Title: esid
Description: null
Default Value: null
DataType Name: {http://www.alfresco.org/model/dictionary/1.0}text
ContainerClass Name: {ed.model}commonProperties
isMultiValued: false
isMandatory: false
isMandatoryEnforced: false
isProtected: false
isIndexed: true
isStoredInIndex: false
isIndexedAtomically: true
indexTokenisationMode: TRUE

   Type: {http://www.alfresco.org/model/dictionary/1.0}text
   Value: [100205000100205]
org.springframework.extensions.webscripts.WebScriptException: 11270008 Wrapped Exception (with status template): 11271169 Failed to execute script '/scripts/applyStatementAspect/applyTaxesAspect.get.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts)': 11271168 A single-valued property of this type may not be a collection:
   Property: Name: {ed.model}esid
Title: esid
Description: null
Default Value: null
DataType Name: {http://www.alfresco.org/model/dictionary/1.0}text
ContainerClass Name: {ed.model}commonProperties
isMultiValued: false
isMandatory: false
isMandatoryEnforced: false
isProtected: false
isIndexed: true
isStoredInIndex: false
isIndexedAtomically: true
indexTokenisationMode: TRUE

   Type: {http://www.alfresco.org/model/dictionary/1.0}text
   Value: [100205000100205]
   at org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:1067)
   at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:171)
   at org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:417)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:401)
   at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:479)
   at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:517)
   at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:333)
   at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:377)
   at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
   at org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:132)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.valves.RequestFilterValve.process(RequestFilterValve.java:316)
   at org.apache.catalina.valves.RemoteAddrValve.invoke(RemoteAddrValve.java:81)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
   at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:448)
   at org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler.process(AjpAprProtocol.java:399)
   at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
   at java.lang.Thread.run(Thread.java:662)
Caused by: org.alfresco.scripts.ScriptException: 11271169 Failed to execute script '/scripts/applyStatementAspect/applyTaxesAspect.get.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts)': 11271168 A single-valued property of this type may not be a collection:
   Property: Name: {ed.model}esid
Title: esid
Description: null
Default Value: null
DataType Name: {http://www.alfresco.org/model/dictionary/1.0}text
ContainerClass Name: {ed.model}commonProperties
isMultiValued: false
isMandatory: false
isMandatoryEnforced: false
isProtected: false
isIndexed: true
isStoredInIndex: false
isIndexedAtomically: true
indexTokenisationMode: TRUE

   Type: {http://www.alfresco.org/model/dictionary/1.0}text
   Value: [100205000100205]
   at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:202)
   at org.alfresco.repo.processor.ScriptServiceImpl.execute(ScriptServiceImpl.java:212)
   at org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:174)
   at org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:102)
   at org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:1305)
   at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:86)
   … 27 more
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 11271168 A single-valued property of this type may not be a collection:
   Property: Name: {ed.model}esid
Title: esid
Description: null
Default Value: null
DataType Name: {http://www.alfresco.org/model/dictionary/1.0}text
ContainerClass Name: {ed.model}commonProperties
isMultiValued: false
isMandatory: false
isMandatoryEnforced: false
isProtected: false
isIndexed: true
isStoredInIndex: false
isIndexedAtomically: true
indexTokenisationMode: TRUE

   Type: {http://www.alfresco.org/model/dictionary/1.0}text
   Value: [100205000100205]
   at org.alfresco.repo.domain.node.NodePropertyHelper.addValueToPersistedProperties(NodePropertyHelper.java:191)
   at org.alfresco.repo.domain.node.NodePropertyHelper.convertToPersistentProperties(NodePropertyHelper.java:97)
   at org.alfresco.repo.domain.node.AbstractNodeDAOImpl.setNodePropertiesImpl(AbstractNodeDAOImpl.java:2211)
   at org.alfresco.repo.domain.node.AbstractNodeDAOImpl.setNodeProperties(AbstractNodeDAOImpl.java:2369)
   at org.alfresco.repo.node.db.DbNodeServiceImpl.addAspectsAndProperties(DbNodeServiceImpl.java:527)
   at org.alfresco.repo.node.db.DbNodeServiceImpl.addAspectsAndProperties(DbNodeServiceImpl.java:434)
   at org.alfresco.repo.node.db.DbNodeServiceImpl.setProperties(DbNodeServiceImpl.java:1620)
   at sun.reflect.GeneratedMethodAccessor359.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at org.alfresco.repo.tenant.MultiTNodeServiceInterceptor.invoke(MultiTNodeServiceInterceptor.java:141)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy15.setProperties(Unknown Source)
   at sun.reflect.GeneratedMethodAccessor359.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.alfresco.repo.service.StoreRedirectorProxyFactory$RedirectorInvocationHandler.invoke(StoreRedirectorProxyFactory.java:215)
   at $Proxy42.setProperties(Unknown Source)
   at org.alfresco.repo.node.MLPropertyInterceptor.invoke(MLPropertyInterceptor.java:215)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.enterprise.repo.sync.SyncPropertyInterceptor.invoke(SyncPropertyInterceptor.java:188)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.node.NodeRefPropertyMethodInterceptor.invoke(NodeRefPropertyMethodInterceptor.java:244)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy15.setProperties(Unknown Source)
   at sun.reflect.GeneratedMethodAccessor359.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196)
   at $Proxy15.setProperties(Unknown Source)
   at sun.reflect.GeneratedMethodAccessor359.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at org.alfresco.repo.audit.DisableAuditableBehaviourInterceptor.invoke(DisableAuditableBehaviourInterceptor.java:113)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:80)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:46)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.audit.AuditMethodInterceptor.proceedWithAudit(AuditMethodInterceptor.java:245)
   at org.alfresco.repo.audit.AuditMethodInterceptor.proceed(AuditMethodInterceptor.java:211)
   at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:164)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.transaction.RetryingTransactionInterceptor$1.execute(RetryingTransactionInterceptor.java:79)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:401)
   at org.alfresco.repo.transaction.RetryingTransactionInterceptor.invoke(RetryingTransactionInterceptor.java:69)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy15.setProperties(Unknown Source)
   at org.alfresco.repo.jscript.ScriptNode.save(ScriptNode.java:1631)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155)
   at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:243)
   at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:119)
   at org.mozilla.javascript.gen.c39._c0(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts/scripts/applyStatementAspect/applyTaxesAspect.get.js:45)
   at org.mozilla.javascript.gen.c39.call(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts/scripts/applyStatementAspect/applyTaxesAspect.get.js)
   at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
   at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
   at org.mozilla.javascript.gen.c39.call(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts/scripts/applyStatementAspect/applyTaxesAspect.get.js)
   at org.mozilla.javascript.gen.c39.exec(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts/scripts/applyStatementAspect/applyTaxesAspect.get.js)
   at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:492)
   at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:198)
   … 32 more
2 REPLIES 2

zladuric
Champ on-the-rise
Champ on-the-rise
I'm writing just a guess here, but here's what I think may be the problem:

eDoc:esid is a multivalued property. So, doc.properties['eDoc:esid'] is a collection.

You're trying to add a collection to a field of type text, with doc.properties['ed:esid'] = someCollection. Now, from what I remember, if your prop is multivalued, you would also access individual values as if the whole prop is an array, but assign it on a simpler manner. I remember I had problems with mltext like that.

So, try taking your eDoc:esid collection (even if it is just one element or null) then for each of them, assign the value to the ed:esid property.

Maybe it will help a bit.

srowsell
Champ in-the-making
Champ in-the-making
I had thought of this, but since I used very similar code with another Type I had been working with – and the collection of properties was copied as though it were one value – I can tell you that this isn't the problem.

I did manage to get it to work, after beating my head against the problem a little longer.  I just split up the aspect assignments like so:


for (var i = 0;i<results.length;i++)
   {
      counter++;
      
      results.addAspect("ed:commonProperties");
      results.properties["ed:esid"]=results.properties["eDoc:esid"];
      results.properties["ed:eDocumentDate"]=results.properties["eDoc:eDocumentDate"];
      results.properties["ed:eDocumentType"]=results.properties["eDoc:eDocumentType"];
      results.save();
      
      if (!(results.hasAspect["ed:commonProperties"]))
      {
      count++
      }
   }
   
   for (var i = 0;i<results.length;i++)
   {
      counter2++;
      
      results.addAspect("ed:eDocumentTaxes");
      results.properties["ed:memberNameTx"]=results.properties["eDoc:memberNameTx"];
      results.properties["ed:statusTx"]=results.properties["eDoc:statusTx"];
      results.properties["ed:formTypeTx"]=results.properties["eDoc:formTypeTx"];
      results.properties["ed:expirationDateTx"]=results.properties["eDoc:expirationDateTx"];
      results.properties["ed:receiptNoTx"]=results.properties["eDoc:receiptNoTx"];
      results.properties["ed:sinTx"]=results.properties["eDoc:sinTx"];
      results.properties["ed:contractNoTx"]=results.properties["eDoc:contractNoTx"];
      results.properties["ed:yearTx"]=results.properties["eDoc:yearTx"];
      results.properties["ed:acctNoTx"]=results.properties["eDoc:acctNoTx"];
      results.properties["ed:branchNoTx"]=results.properties["eDoc:branchNoTx"];
      results.properties["ed:branchNameTx"]=results.properties["eDoc:branchNameTx"];
      results.properties["ed:transitTx"]=results.properties["eDoc:transitTx"];
      results.save();
      
      if (!(results.hasAspect["ed:eDocumentTaxes"]))
      {
      count++
      }      
   }


I don't know why this fixed it, but I also cleaned up a couple of nagging problems with the model, which might have been what actually solved it.

Thanks for your help.