You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ha...@apache.org on 2008/08/28 15:39:15 UTC
svn commit: r689816 - in /ofbiz/trunk:
applications/party/webapp/partymgr/WEB-INF/actions/party/GetMyCompany.groovy
specialpurpose/mypage/webapp/mypage/WEB-INF/actions/GetMyCompany.bsh
specialpurpose/mypage/widget/MyPageScreens.xml
Author: hansbak
Date: Thu Aug 28 06:39:13 2008
New Revision: 689816
URL: http://svn.apache.org/viewvc?rev=689816&view=rev
Log:
convert and move from bsh to groovy..because also used in the accounting component (next commit)
Added:
ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetMyCompany.groovy (with props)
Removed:
ofbiz/trunk/specialpurpose/mypage/webapp/mypage/WEB-INF/actions/GetMyCompany.bsh
Modified:
ofbiz/trunk/specialpurpose/mypage/widget/MyPageScreens.xml
Added: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetMyCompany.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetMyCompany.groovy?rev=689816&view=auto
==============================================================================
--- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetMyCompany.groovy (added)
+++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetMyCompany.groovy Thu Aug 28 06:39:13 2008
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+if (userLogin) {
+ companies = delegator.findByAnd("PartyRelationship",
+ [partyIdTo: userLogin.partyId,
+ roleTypeIdTo: "CONTACT",
+ roleTypeIdFrom: "ACCOUNT"]);
+ if (companies) {
+ company = companies.get(0);
+ context.myCompanyId = company.partyIdFrom;
+ } else {
+ context.myCompanyId = userLogin.partyId;
+ }
+}
\ No newline at end of file
Propchange: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetMyCompany.groovy
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetMyCompany.groovy
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author URL Id"
Propchange: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetMyCompany.groovy
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: ofbiz/trunk/specialpurpose/mypage/widget/MyPageScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/mypage/widget/MyPageScreens.xml?rev=689816&r1=689815&r2=689816&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/mypage/widget/MyPageScreens.xml (original)
+++ ofbiz/trunk/specialpurpose/mypage/widget/MyPageScreens.xml Thu Aug 28 06:39:13 2008
@@ -463,7 +463,7 @@
<section>
<actions>
<set field="headerItem" value="invoices"/>
- <script location="component://mypage/webapp/mypage/WEB-INF/actions/GetMyCompany.bsh"/>
+ <script location="component://party/webapp/partymgr/WEB-INF/actions/party/GetMyCompany.groovy"/>
<set field="parameters.partyId" from-field="myCompanyId"/>
</actions>
<widgets>
Re: svn commit: r689816 - in /ofbiz/trunk: applications/party/webapp/partymgr/WEB-INF/actions/party/GetMyCompany.groovy
specialpurpose/mypage/webapp/mypage/WEB-INF/actions/GetMyCompany.bsh specialpurpose/mypage/widget/MyPageScreens.xml
Posted by Adam Heath <do...@brainfood.com>.
hansbak@apache.org wrote:
> --- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetMyCompany.groovy (added)
> +++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetMyCompany.groovy Thu Aug 28 06:39:13 2008
> +if (userLogin) {
> + companies = delegator.findByAnd("PartyRelationship",
> + [partyIdTo: userLogin.partyId,
> + roleTypeIdTo: "CONTACT",
> + roleTypeIdFrom: "ACCOUNT"]);
> + if (companies) {
> + company = companies.get(0);
> + context.myCompanyId = company.partyIdFrom;
> + } else {
> + context.myCompanyId = userLogin.partyId;
> + }
> +}
So, you use [:] for fast map creation, Map.field for fast putting, but
then use .get(int) to fetch from the list.
Why not use:
company = companies[0]?