use of org.ligoj.app.model.Subscription in project ligoj-api by ligoj.
the class PluginsClassLoaderTest method newSubscription.
private Subscription newSubscription() {
Subscription subscription = new Subscription();
Node node = new Node();
node.setId("service:id:ldap:server1");
Node tool = new Node();
tool.setId("service:id:ldap");
Node service = new Node();
service.setId("service:id");
tool.setRefined(service);
node.setRefined(tool);
subscription.setNode(node);
subscription.setId(42);
return subscription;
}
use of org.ligoj.app.model.Subscription in project ligoj-api by ligoj.
the class ToVoConverter method apply.
@Override
public ProjectVo apply(final Project entity) {
final ProjectVo vo = new ProjectVo();
vo.copyAuditData(entity, userConverter);
DescribedBean.copy(entity, vo);
vo.setPkey(entity.getPkey());
vo.setTeamLeader(userConverter.apply(entity.getTeamLeader()));
// Build the subscriptions
final Map<Integer, SubscriptionVo> subscriptions = new TreeMap<>();
for (final Object[] resultSet : this.subscriptionsAndParam) {
// Add subscription value
final ParameterValue parameterValue = (ParameterValue) resultSet[1];
addVo(subscriptions, (Subscription) resultSet[0]).getParameters().put(parameterValue.getParameter().getId(), ParameterValueResource.parseValue(parameterValue, new ParameterValueVo()));
}
// Merge with subscription without parameters
entity.getSubscriptions().forEach(s -> addVo(subscriptions, s));
// Return the subscription to order by the related node
vo.setSubscriptions(subscriptions.values().stream().sorted(Comparator.comparing(s -> s.getNode().getId(), String::compareTo)).collect(Collectors.toList()));
return vo;
}
use of org.ligoj.app.model.Subscription in project ligoj-api by ligoj.
the class SubscriptionResource method delete.
/**
* Delete entity and cascaded associations : parameters, events then subscription.
*
* @param id
* the entity identifier.
* @param deleteRemoteData
* When <code>true</code>, remote data will be also destroyed.
* @throws Exception
* When the delete fails. Managed at JAX-RS level.
*/
@Path("{id:\\d+}/{deleteRemoteData}")
@DELETE
public void delete(@PathParam("id") final int id, @PathParam("deleteRemoteData") final boolean deleteRemoteData) throws Exception {
final Subscription entity = checkVisibleSubscription(id);
checkManagedProject(entity.getProject().getId());
// Delete the events
eventRepository.deleteAllBy("subscription", entity);
// Delegate the deletion
deleteWithTasks(entity.getNode().getId(), id, deleteRemoteData);
parameterValueResource.deleteBySubscription(id);
repository.delete(entity);
}
use of org.ligoj.app.model.Subscription in project ligoj-api by ligoj.
the class SubscriptionResource method toEntity.
/**
* {@link SubscriptionEditionVo} to JPA entity transformer.
*
* @param vo
* The object to convert.
* @param project
* The related project.
* @param node
* The related node.
* @return The mapped entity.
*/
public static Subscription toEntity(final SubscriptionEditionVo vo, final Project project, final Node node) {
final Subscription entity = new Subscription();
entity.setProject(project);
entity.setId(vo.getId());
entity.setNode(node);
return entity;
}
use of org.ligoj.app.model.Subscription in project ligoj-api by ligoj.
the class TestAbstractConfiguredServicePlugin method checkVisibilityKo.
@Test
public void checkVisibilityKo() {
final Subscription subscription = new Subscription();
final Node node = new Node();
node.setId("service:s:t:i");
subscription.setNode(node);
subscription.setId(2000);
Assertions.assertThrows(EntityNotFoundException.class, () -> {
resource.checkVisibility(subscription, "any");
});
}
Aggregations