Search in sources :

Example 1 with LrsObject

use of org.apereo.portal.events.tincan.om.LrsObject in project uPortal by Jasig.

the class LrsDataModelSerializeTest method testLrsStatementSerialize.

@Test
public void testLrsStatementSerialize() throws Exception {
    final LrsActor lrsActor = new LrsActor("user@example.com", "John Doe");
    final UrnBuilder idBuilder = new UrnBuilder("UTF-8", "tincan", "uportal", "activities", "portlet", "fname");
    final URI id = idBuilder.getUri();
    final LrsObject lrsObject = new LrsObject(id, "Activity", ImmutableMap.of("name", new LocalizedString(new Locale("en", "us"), "Portlet Name"), "description", new LocalizedString(new Locale("en", "us"), "Portlet Description")));
    final LrsStatement lrsStatement = new LrsStatement(lrsActor, LrsVerb.INITIALIZED, lrsObject);
    final String result = this.objectMapper.writeValueAsString(lrsStatement);
    assertEquals("{\"actor\":{\"mbox\":\"user@example.com\",\"name\":\"John Doe\",\"objectType\":\"Agent\"},\"verb\":{\"id\":\"http://adlnet.gov/expapi/verbs/initialized\",\"display\":{\"en-us\":\"initialized\"}},\"object\":{\"id\":\"urn:tincan:uportal:activities:portlet:fname\",\"objectType\":\"Activity\",\"definition\":{\"name\":{\"en-US\":\"Portlet Name\"},\"description\":{\"en-US\":\"Portlet Description\"}}}}", result);
}
Also used : Locale(java.util.Locale) UrnBuilder(org.apereo.portal.events.tincan.UrnBuilder) LrsObject(org.apereo.portal.events.tincan.om.LrsObject) LrsActor(org.apereo.portal.events.tincan.om.LrsActor) LrsStatement(org.apereo.portal.events.tincan.om.LrsStatement) LocalizedString(org.apereo.portal.events.tincan.om.LocalizedString) LocalizedString(org.apereo.portal.events.tincan.om.LocalizedString) URI(java.net.URI) Test(org.junit.Test)

Example 2 with LrsObject

use of org.apereo.portal.events.tincan.om.LrsObject in project uPortal by Jasig.

the class PortletExecutionEventConverter method getLrsObject.

@Override
protected LrsObject getLrsObject(PortalEvent event) {
    final String fname = ((PortletExecutionEvent) event).getFname();
    final AggregatedPortletMapping mappedPortletForFname = this.aggregatedPortletLookupDao.getMappedPortletForFname(fname);
    final Builder<String, LocalizedString> definitionBuilder = ImmutableMap.builder();
    definitionBuilder.put("name", new LocalizedString(Locale.US, mappedPortletForFname.getName()));
    return new LrsObject(buildUrn("portlet", fname), getDefaultObjectType(), definitionBuilder.build());
}
Also used : PortletExecutionEvent(org.apereo.portal.events.PortletExecutionEvent) LrsObject(org.apereo.portal.events.tincan.om.LrsObject) AggregatedPortletMapping(org.apereo.portal.events.aggr.portlets.AggregatedPortletMapping) LocalizedString(org.apereo.portal.events.tincan.om.LocalizedString) LocalizedString(org.apereo.portal.events.tincan.om.LocalizedString)

Example 3 with LrsObject

use of org.apereo.portal.events.tincan.om.LrsObject in project uPortal by Jasig.

the class LrsDataModelSerializeTest method testLrsObjectSerialize.

@Test
public void testLrsObjectSerialize() throws Exception {
    final UrnBuilder idBuilder = new UrnBuilder("UTF-8", "tincan", "uportal", "activities", "portlet", "fname");
    final URI id = idBuilder.getUri();
    final LrsObject lrsObject = new LrsObject(id, "Activity", ImmutableMap.of("name", new LocalizedString(new Locale("en", "us"), "Portlet Name"), "description", new LocalizedString(new Locale("en", "us"), "Portlet Description")));
    final String result = this.objectMapper.writeValueAsString(lrsObject);
    assertEquals("{\"id\":\"urn:tincan:uportal:activities:portlet:fname\",\"objectType\":\"Activity\",\"definition\":{\"name\":{\"en-US\":\"Portlet Name\"},\"description\":{\"en-US\":\"Portlet Description\"}}}", result);
}
Also used : Locale(java.util.Locale) UrnBuilder(org.apereo.portal.events.tincan.UrnBuilder) LrsObject(org.apereo.portal.events.tincan.om.LrsObject) LocalizedString(org.apereo.portal.events.tincan.om.LocalizedString) LocalizedString(org.apereo.portal.events.tincan.om.LocalizedString) URI(java.net.URI) Test(org.junit.Test)

Example 4 with LrsObject

use of org.apereo.portal.events.tincan.om.LrsObject in project uPortal by Jasig.

the class PortletRenderEventConverter method getLrsObject.

@Override
protected LrsObject getLrsObject(PortalEvent event) {
    final String targetedLayoutNodeId = ((PortalRenderEvent) event).getTargetedLayoutNodeId();
    final AggregatedTabMapping aggregatedTabMapping = aggregatedTabLookupDao.getMappedTabForLayoutId(targetedLayoutNodeId);
    final Builder<String, LocalizedString> definitionBuilder = ImmutableMap.builder();
    definitionBuilder.put("name", new LocalizedString(Locale.US, aggregatedTabMapping.getDisplayString()));
    return new LrsObject(buildUrn("tab", aggregatedTabMapping.getFragmentName()), getDefaultObjectType(), definitionBuilder.build());
}
Also used : PortalRenderEvent(org.apereo.portal.events.PortalRenderEvent) LrsObject(org.apereo.portal.events.tincan.om.LrsObject) LocalizedString(org.apereo.portal.events.tincan.om.LocalizedString) LocalizedString(org.apereo.portal.events.tincan.om.LocalizedString) AggregatedTabMapping(org.apereo.portal.events.aggr.tabs.AggregatedTabMapping)

Aggregations

LocalizedString (org.apereo.portal.events.tincan.om.LocalizedString)4 LrsObject (org.apereo.portal.events.tincan.om.LrsObject)4 URI (java.net.URI)2 Locale (java.util.Locale)2 UrnBuilder (org.apereo.portal.events.tincan.UrnBuilder)2 Test (org.junit.Test)2 PortalRenderEvent (org.apereo.portal.events.PortalRenderEvent)1 PortletExecutionEvent (org.apereo.portal.events.PortletExecutionEvent)1 AggregatedPortletMapping (org.apereo.portal.events.aggr.portlets.AggregatedPortletMapping)1 AggregatedTabMapping (org.apereo.portal.events.aggr.tabs.AggregatedTabMapping)1 LrsActor (org.apereo.portal.events.tincan.om.LrsActor)1 LrsStatement (org.apereo.portal.events.tincan.om.LrsStatement)1