[Building Sakai] A question about how to use some APIs in project Profile2

Steve Swinsburg steve.swinsburg at gmail.com
Thu Nov 12 13:08:48 PST 2009


If using Spring, inject the actual API, not the static cover. However,  
don't inject into the tool.

Since you seem to be modifying Profile2, inject the GradebookService  
into SakaiProxy.java which is where I have kept all Sakai related API  
calls. That is already injected into all Tool pages so you can just  
call sakaiProxy.someMethod() to do things.

Could you let me know what additions you are making to Profile2? Are  
you wanting to contribute them back to the main release of Profile2?

cheers,
Steve


On 13/11/2009, at 6:26 AM, Small Cat wrote:

> ... I want to add a new page using gradebook service into profile 2,  
> I name this page "MyHello.html" and implement it in MyHello.java &  
> MyQuery.java (this class in a new package  
> org.sakaiproject.profile2.tool.mysql    )
>
> I've already use some other service like database api, site service   
> by using cover (but I fell in using methods of adding bean in  
> compponents.xml >"<). But the problem is that I can't found  
> gradebook cover ...
> I tried to inject it follow these steps :( I use sakai 2.5.5 )
> - add dependency in maven file
> <dependency>
>             <groupId>org.sakaiproject</groupId>
>             <artifactId>sakai-gradebook-service-api</artifactId>
>             <version>${sakai.version}</version>
>         </dependency>
> - add bean in components
> <bean id="org.sakaiproject.profile2.tool.mysql.MyQuery"
>         class="org.sakaiproject.profile2.tool.mysql.MyQuery">
>         <property name="gradebookService"
>             ref="org.sakaiproject.service.gradebook.shared.*">
>         </property>
>     </bean>
> - coding...and this is a test function to get some assignment name  
> ( I think gradebookId = coursesiteID , it is right ? )
> // courseList is a list of course site id
> public LinkedList<String> getAssignmentNameList(
>             LinkedList<String> courseList) {
>         LinkedList<Assignment> assignmentList = new LinkedList();
>         try {
>             while (!courseList.isEmpty()) {
>                 String tmpString = courseList.remove();
>                 List<Assignment> tmpList = gradebookService
>                         .getAssignments(tmpString);
>                 assignmentList.addAll(tmpList);
>             }
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>
>         LinkedList<String> assignmentNameList = new LinkedList();
>         try {
>             while (!assignmentList.isEmpty()) {
>                 assignmentNameList.add(assignmentList.remove 
> ().getName());
>             }
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>         return assignmentNameList;
>     }
> /**************************************************************/
>
>  I tried like that in Sakai and it return nothing >"<.
> Can anyone help me ?
>
>
>
> 2009/11/6 Steve Swinsburg <steve.swinsburg at gmail.com>
> You've got a ; in the bean definitions, not sure if that matters too  
> much though. But as for the dependency in the pom, if matters if you  
> are on 2.5 or 2.6+. If 2.6 then you don't need that dependency as  
> its in the kernel but for 2.5 you will.
>
> Also, are you modifying the current Profile2 tool? ie
> http://confluence.sakaiproject.org/display/PROFILE/Profile2
>
> I am currently polishing up release of Profile2 for possible  
> inclusion in 2.7 so it would be good to coordinate efforts here.
>
> cheers,
> Steve
>
>
> On 06/11/2009, at 3:47 PM, Small Cat wrote:
>
>> Hi,
>> In the components.xml, I added a bean for my class as :
>>
>> <!--  MyPortfolios -->
>>     <bean id =  
>> "org.sakaiproject.profile2.tool.myportfolios.MyPortfolios;"
>>          
>> class="org.sakaiproject.profile2.tool.myportfolios.MyPortfolios;">
>>
>>         <property name="siteService"  
>> ref="org.sakaiproject.site.api.SiteService"/>
>>
>>     </bean>
>> In relevant pom.xml , I added :
>> <dependency>
>>                     <groupId>org.sakaiproject</groupId>
>>                     <artifactId>sakai-site-api</artifactId>
>>                     <scope>provided</scope>
>>                 </dependency>
>>
>> Is this right ?
>> Thanks ,
>>
>>
>> 2009/11/6 Steve Swinsburg <steve.swinsburg at gmail.com>
>> Hi,
>>
>> Are you making an addition to Profile2 that you might like to  
>> contribute back? If so, thats great! Could you possibly Jira it here:
>> http://jira.sakaiproject.org/browse/PRFL
>>
>> For your issue, it's most likely an API injection issue. You'll  
>> need to make sure you have the dependency in the relevant POM and  
>> in the components.xml so Spring can inject it into the beans.  
>> However if you Jira this task we can go over the goal and  
>> implementation details.
>>
>> cheers,
>> Steve
>>
>>
>>
>> On 06/11/2009, at 1:51 AM, Small Cat wrote:
>>
>>> Dear all,
>>> I want to add some functions for Profile2, and one of them can  
>>> show all scores of assigments in all course sites...
>>> But I can't use some APIs as getSites.... ( I can use it in other  
>>> tools, but in Profile2 I don't know why it can't )
>>> This is error when I deploy :
>>>
>>> [ERROR] BUILD FAILURE
>>> [INFO]  
>>> ------------------------------------------------------------------------
>>> [INFO] Compilation failure
>>>
>>> C:\sakai\profile2-1.2.1\tool\src\java\org\sakaiproject 
>>> \profile2\tool\myportfolio
>>> s\MyPortfolios.java:[22,52] cannot access  
>>> org.sakaiproject.entity.api.EntityProd
>>> ucer
>>> file org\sakaiproject\entity\api\EntityProducer.class not found
>>>                         courseSiteList = siteService.getSites 
>>> (SelectionType.ACCE
>>> SS,
>>>
>>> C:\sakai\profile2-1.2.1\tool\src\java\org\sakaiproject 
>>> \profile2\tool\myportfolio
>>> s\MyPortfolios.java:[35,60] cannot access  
>>> org.sakaiproject.entity.api.Edit
>>> file org\sakaiproject\entity\api\Edit.class not found
>>>                         courseList.add(courseSiteList.remove 
>>> (0).getTitle());
>>>
>>> How to use getSites in Profile2 , if can not, what methods I can  
>>> use to replace ?
>>> Thank you,
>>> -- 
>>> Regards,
>>> Tran Trung Kien
>>> _______________________________________________
>>> sakai-dev mailing list
>>> sakai-dev at collab.sakaiproject.org
>>> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>>>
>>> TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org 
>>>  with a subject of "unsubscribe"
>>
>>
>>
>>
>> -- 
>> Regards,
>> Tran Trung Kien
>
>
>
>
> -- 
> Regards,
> Tran Trung Kien
> <MyHello.html><MyQuery.java><MyHello.java>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20091113/006fe58e/attachment.html 


More information about the sakai-dev mailing list