本文整理匯總了Java中org.ligoj.app.iam.Activity類的典型用法代碼示例。如果您正苦於以下問題:Java Activity類的具體用法?Java Activity怎麽用?Java Activity使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Activity類屬於org.ligoj.app.iam包,在下文中一共展示了Activity類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getActivities
import org.ligoj.app.iam.Activity; //導入依賴的package包/類
/**
* Return activities associates by given a subscription.
*/
private ActivitiesComputations getActivities(final int subscription, final boolean global) throws Exception {
// Get users from other LDAP subscriptions
final Subscription main = subscriptionResource.checkVisibleSubscription(subscription);
final List<Subscription> subscriptions = subscriptionRepository.findAllOnSameProject(subscription);
final Set<UserOrg> users = global ? getMembersOfAllSubscription(subscriptions) : getMembersOfSubscription(main);
// Get the activities from each subscription of the same project,
final ActivitiesComputations result = new ActivitiesComputations();
result.setUsers(users);
final List<String> userLogins = users.stream().map(UserOrg::getId).collect(Collectors.toList());
final Map<String, Map<String, Activity>> activities = new HashMap<>();
final Set<INamableBean<String>> nodes = new LinkedHashSet<>();
for (final Subscription projectSubscription : subscriptions) {
final ServicePlugin resource = servicePluginLocator.getResource(projectSubscription.getNode().getId());
addSubscriptionActivities(activities, userLogins, projectSubscription, resource, nodes);
}
result.setNodes(nodes);
result.setActivities(activities);
return result;
}
示例2: addSubscriptionActivities
import org.ligoj.app.iam.Activity; //導入依賴的package包/類
@Test
public void addSubscriptionActivities() throws Exception {
final LdapPluginResource resource = new LdapPluginResource();
final Map<String, Map<String, Activity>> activities = new HashMap<>();
final Subscription susbscription = new Subscription();
final Node service = new Node();
service.setId("J1");
susbscription.setNode(service);
susbscription.setId(1);
final SampleActivityProvider plugin = Mockito.mock(SampleActivityProvider.class);
final Map<String, Activity> activities1 = new HashMap<>();
final Activity activity2 = new Activity();
activities1.put(DEFAULT_USER, activity2);
Mockito.when(plugin.getActivities(1, null)).thenReturn(activities1);
final Set<INamableBean<String>> nodes = new HashSet<>();
resource.addSubscriptionActivities(activities, null, susbscription, plugin, nodes);
Assert.assertEquals(1, activities.size());
Assert.assertTrue(activities.containsKey(DEFAULT_USER));
Assert.assertEquals(1, activities.get(DEFAULT_USER).size());
Assert.assertTrue(activities.get(DEFAULT_USER).containsKey("J1"));
Assert.assertEquals(activity2, activities.get(DEFAULT_USER).get("J1"));
}
示例3: addSubscriptionActivitiesDuplicateUser
import org.ligoj.app.iam.Activity; //導入依賴的package包/類
@Test
public void addSubscriptionActivitiesDuplicateUser() throws Exception {
final LdapPluginResource resource = new LdapPluginResource();
final Map<String, Map<String, Activity>> activities = new HashMap<>();
activities.put(DEFAULT_USER, new HashMap<>());
final Activity activity1 = new Activity();
activities.get(DEFAULT_USER).put("J0", activity1);
final Subscription susbscription = new Subscription();
final Node service = new Node();
service.setId("J1");
susbscription.setNode(service);
susbscription.setId(1);
final SampleActivityProvider plugin = Mockito.mock(SampleActivityProvider.class);
final Map<String, Activity> activities1 = new HashMap<>();
final Activity activity2 = new Activity();
activities1.put(DEFAULT_USER, activity2);
Mockito.when(plugin.getActivities(1, null)).thenReturn(activities1);
final Set<INamableBean<String>> nodes = new HashSet<>();
resource.addSubscriptionActivities(activities, null, susbscription, plugin, nodes);
Assert.assertEquals(1, activities.size());
Assert.assertTrue(activities.containsKey(DEFAULT_USER));
Assert.assertEquals(2, activities.get(DEFAULT_USER).size());
Assert.assertTrue(activities.get(DEFAULT_USER).containsKey("J1"));
Assert.assertEquals(activity1, activities.get(DEFAULT_USER).get("J0"));
Assert.assertEquals(activity2, activities.get(DEFAULT_USER).get("J1"));
}
示例4: writeData
import org.ligoj.app.iam.Activity; //導入依賴的package包/類
/**
* Write activities data. Ends with new line.
*/
protected void writeData(final Writer writer, final Format df) throws IOException {
for (final UserOrg user : computations.getUsers()) {
// Write user data
writeUserData(writer, user);
// Write activities of this user
final Map<String, Activity> activities = computations.getActivities().get(user.getId());
if (activities != null) {
// At least one activity for this user
writeNodeActivities(activities, writer, df);
}
writer.write('\n');
}
}
示例5: writeNodeActivities
import org.ligoj.app.iam.Activity; //導入依賴的package包/類
/**
* Write user's activities
*/
protected void writeNodeActivities(final Map<String, Activity> activities, final Writer writer, final Format df) throws IOException {
for (final INamableBean<String> node : computations.getNodes()) {
writer.write(';');
// Last connection, if available
final Activity activity = activities.get(node.getId());
if (activity != null) {
// There is an activity for this user and this node
writer.write(df.format(activity.getLastConnection()));
}
}
}
示例6: addSubscriptionActivities
import org.ligoj.app.iam.Activity; //導入依賴的package包/類
/**
* Add activities related to given subscription.
*/
protected void addSubscriptionActivities(final Map<String, Map<String, Activity>> activities,
final Collection<String> userLogins, final Subscription otherSubscription, final ServicePlugin plugin,
final Set<INamableBean<String>> nodes) throws Exception { // NOSONAR
// Collect activities of each subscription of unique node
if (plugin instanceof ActivitiesProvider && nodes.add(otherSubscription.getNode())) {
final Map<String, Activity> subscriptionActivities = ((ActivitiesProvider) plugin)
.getActivities(otherSubscription.getId(), userLogins);
for (final Entry<String, Activity> userActivity : subscriptionActivities.entrySet()) {
addUserActivities(activities, otherSubscription.getNode(), userActivity);
}
}
}
示例7: write
import org.ligoj.app.iam.Activity; //導入依賴的package包/類
@Test
public void write() throws IOException {
final ActivitiesComputations computations = new ActivitiesComputations();
// Nodes
final Collection<INamableBean<String>> nodes = new ArrayList<>();
final NamedBean<String> node1 = new NamedBean<>();
nodes.add(node1);
node1.setId("J0");
node1.setName("J0N");
final NamedBean<String> node2 = new NamedBean<>();
nodes.add(node2);
node2.setId("J1");
node2.setName("J1N");
computations.setNodes(nodes);
// Activities
final Map<String, Map<String, Activity>> activities = new HashMap<>();
final Map<String, Activity> userActivities = new HashMap<>();
activities.put("U0", userActivities);
final Activity activity1 = new Activity();
activity1.setLastConnection(new Date(0));
userActivities.put("J0", activity1);
computations.setActivities(activities);
// Users
final Collection<UserOrg> users = new ArrayList<>();
final UserOrg user = new UserOrg();
user.setFirstName("F0");
user.setLastName("L0");
user.setId("U0");
user.setMails(new ArrayList<>());
users.add(user);
final UserOrg user2 = new UserOrg();
user2.setFirstName("F1");
user2.setLastName("L1");
user2.setId("U1");
user2.setMails(Arrays.asList("M1", "M2"));
users.add(user2);
computations.setUsers(users);
// Call
final ByteArrayOutputStream out = new ByteArrayOutputStream();
new CsvStreamingOutput(computations).write(out);
final List<String> lines = IOUtils.readLines(new ByteArrayInputStream(out.toByteArray()), StandardCharsets.UTF_8);
// Check
Assert.assertEquals(3, lines.size());
Assert.assertEquals("user;firstName;lastName;mail;J0N;J1N", lines.get(0));
Assert.assertEquals("U0;F0;L0;;1970/01/01 01:00:00;", lines.get(1));
Assert.assertEquals("U1;F1;L1;M1", lines.get(2));
}
示例8: addSubscriptionActivitiesDuplicateNode
import org.ligoj.app.iam.Activity; //導入依賴的package包/類
@Test
public void addSubscriptionActivitiesDuplicateNode() throws Exception {
final Map<String, Map<String, Activity>> activities = new HashMap<>();
final LdapPluginResource resource = new LdapPluginResource();
final Subscription susbscription = new Subscription();
final Node service = new Node();
service.setId("J");
susbscription.setNode(service);
final SampleActivityProvider plugin = Mockito.mock(SampleActivityProvider.class);
final Set<INamableBean<String>> nodes = new HashSet<>();
nodes.add(service);
resource.addSubscriptionActivities(activities, null, susbscription, plugin, nodes);
Assert.assertTrue(activities.isEmpty());
}
示例9: getActivities
import org.ligoj.app.iam.Activity; //導入依賴的package包/類
/**
* Query JIRA database to collect activities of given users. For now, only the last success connection is
* registered.
*
* @param dataSource The JIRA datasource to query the user activities.
* @param users
* the users to query.
* @return activities.
*/
public Map<String, Activity> getActivities(final DataSource dataSource, final Collection<String> users) {
final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
final Map<String, Activity> result = new HashMap<>();
if (!users.isEmpty()) {
jdbcTemplate.query("SELECT u.lower_user_name AS login, attribute_value AS value FROM cwd_user AS u"
+ " INNER JOIN cwd_user_attributes AS ua ON ua.user_id = u.ID WHERE u.lower_user_name IN (" + newIn(users)
+ ") AND attribute_name=?;", rs -> {
final Activity activity = new Activity();
activity.setLastConnection(new Date(Long.valueOf(rs.getString("value"))));
result.put(rs.getString("login"), activity);
}, ArrayUtils.add(users.toArray(), "lastAuthenticated"));
}
return result;
}
示例10: getActivities
import org.ligoj.app.iam.Activity; //導入依賴的package包/類
@Test
public void getActivities() throws Exception {
final Collection<String> users = new ArrayList<>();
users.add("fdaugan");
users.add("alocquet");
users.add("any");
final Map<String, Activity> activities = resource.getActivities(subscription, users);
Assert.assertEquals(1, activities.size());
Assert.assertTrue(activities.containsKey("fdaugan"));
Assert.assertNotNull(activities.get("fdaugan").getLastConnection());
}
示例11: addUserActivities
import org.ligoj.app.iam.Activity; //導入依賴的package包/類
/**
* Add activities related to a single node.
*/
private void addUserActivities(final Map<String, Map<String, Activity>> activities, final Node node,
final Entry<String, Activity> userActivity) {
final String user = userActivity.getKey();
activities.computeIfAbsent(user, k -> new HashMap<>()).put(node.getId(), userActivity.getValue());
}
示例12: addSubscriptionActivitiesNotProvider
import org.ligoj.app.iam.Activity; //導入依賴的package包/類
@Test
public void addSubscriptionActivitiesNotProvider() throws Exception {
final Map<String, Map<String, Activity>> activities = new HashMap<>();
new LdapPluginResource().addSubscriptionActivities(activities, null, null, null, null);
Assert.assertTrue(activities.isEmpty());
}
示例13: getActivities
import org.ligoj.app.iam.Activity; //導入依賴的package包/類
@Override
public Map<String, Activity> getActivities(final int subscription, final Collection<String> users) throws Exception {
// Mock
return null;
}
示例14: getActivities
import org.ligoj.app.iam.Activity; //導入依賴的package包/類
@Override
public Map<String, Activity> getActivities(final int subscription, final Collection<String> users) throws Exception {
final Map<String, String> parameters = subscriptionResource.getParameters(subscription);
final DataSource dataSource = getDataSource(parameters);
return jiraDao.getActivities(dataSource, users);
}
示例15: getActivitiesNoUser
import org.ligoj.app.iam.Activity; //導入依賴的package包/類
@Test
public void getActivitiesNoUser() throws Exception {
final Collection<String> users = new ArrayList<>();
final Map<String, Activity> activities = resource.getActivities(subscription, users);
Assert.assertTrue(activities.isEmpty());
}