protected boolean resourceCheckInListIds(IPResource resource, List<Long> resourceIds) { return resourceIds.stream() // .map(it -> resourceService.resourceFind(it).get()) // .filter(it -> resourceService.resourceEqualsPk(resource, it)) // .findAny().isPresent(); }
public static void init(CommonServicesContext commonServicesContext, InternalServicesContext internalServicesContext) { // Load all the plugins commonServicesContext.getPluginService().loadPlugins(commonServicesContext, internalServicesContext); }
private void common(CommonServicesContext services, ChangesContext changes) { IPResourceService resourceService = services.getResourceService(); List<Bind9Server> bind9Servers = resourceService.resourceFindAll(resourceService.createResourceQuery(Bind9Server.class)); bind9Servers.forEach(it -> { changes.resourceRefresh(it); }); }
private UnixUser findByName(String name) { IPResourceService resourceService = getCommonServicesContext().getResourceService(); return resourceService.resourceFind(resourceService.createResourceQuery(UnixUser.class) // .propertyEquals(UnixUser.PROPERTY_NAME, name)) // .get(); }
@Test public void testQueryBoolean_like_no() { thrown.expectMessage("Property [bool] does not support querying like"); IPResourceService resourceService = getCommonServicesContext().getResourceService(); resourceService.createResourceQuery(JunitResource.class) // .propertyLike(JunitResource.PROPERTY_BOOL, "%true"); }
public void resourceDelete(IPResource resource) { Long internalId = resource.getInternalId(); if (internalId == null) { Optional<IPResource> found = resourceService.resourceFindByPk(resource); if (found.isPresent()) { internalId = found.get().getInternalId(); } } resourceDelete(internalId); }
/** * Create and add an {@link InputTextFieldPageItem} to the page. * * @param servicesCtx * the services context to get the translation service * @param pageDefinition * the page definition on which to add the field * @param labelCode * the message code for the label (will be translated) * @param fieldName * the name of the field * @return the created field on which you can set the value if needed */ public static InputTextFieldPageItem createInputTextField(CommonServicesContext servicesCtx, PageDefinition pageDefinition, String labelCode, String fieldName) { InputTextFieldPageItem pageItem = new InputTextFieldPageItem().setLabel(servicesCtx.getTranslationService().translate(labelCode)); pageItem.setFieldName(fieldName); pageDefinition.addPageItem(pageItem); return pageItem; }
protected boolean resourceCheckInList(IPResource resource, List<Tuple2<Long, IPResource>> resources) { return resources.stream() // .filter(it -> resourceService.resourceEqualsPk(resource, it.getB())) // .findAny().isPresent(); }
protected void commonHandlerExecute(CommonServicesContext services, ChangesContext changes) { IPResourceService resourceService = services.getResourceService(); resourceService.resourceFindAll(resourceService.createResourceQuery(Machine.class)).forEach(machine -> changes.resourceRefresh(machine)); }
@Test public void testQuerySetTexts_single_greater_no() { thrown.expectMessage("Property [setTexts] does not support querying greater"); IPResourceService resourceService = getCommonServicesContext().getResourceService(); resourceService.createResourceQuery(JunitResource.class) // .propertyGreater(JunitResource.PROPERTY_SET_TEXTS, "a"); }
public <T extends IPResource> T assertResourceExists(boolean expectedExists, T resourcePk, Class<T> resourceClass) { IPResourceService resourceService = getCommonServicesContext().getResourceService(); Optional<T> resourceFindOne = resourceService.resourceFindByPk(resourcePk); Assert.assertEquals(expectedExists, resourceFindOne.isPresent()); if (resourceFindOne.isPresent()) { return resourceFindOne.get(); } else { return null; } }
public void resourceDelete(Long resourceId) { if (resourceId == null) { throw new IllegalUpdateException("Cannot delete a resource without id"); } resourcesToDelete.add(resourceId); // Remove in add and update Optional<IPResource> resourceOptional = resourceService.resourceFind(resourceId); if (resourceOptional.isPresent()) { IPResource resource = resourceOptional.get(); resourcesToAdd.removeIf(it -> resourceService.resourceEqualsPk(resource, it)); } resourcesToUpdate.removeIf(it -> it.getA() == resourceId); }
protected void linksClean(Tuple3<IPResource, String, IPResource> newTuple, List<Tuple3<IPResource, String, IPResource>> linksList) { linksList.removeIf(it -> // resourceService.resourceEqualsPk(newTuple.getA(), it.getA()) && // newTuple.getB().equals(it.getB()) && // resourceService.resourceEqualsPk(newTuple.getC(), it.getC()) // ); }
private void checkUniqueName(CommonServicesContext services, String name) { IPResourceService resourceService = services.getResourceService(); List<UnixUser> unixUsers = resourceService.resourceFindAll(resourceService.createResourceQuery(UnixUser.class) // .propertyEquals(UnixUser.PROPERTY_NAME, name)); if (unixUsers.size() > 1) { throw new IllegalUpdateException("Unix User name " + name + " is already used"); } }
@Test public void testQuerySetTexts_single_less_no() { thrown.expectMessage("Property [setTexts] does not support querying lesser"); IPResourceService resourceService = getCommonServicesContext().getResourceService(); resourceService.createResourceQuery(JunitResource.class) // .propertyLesser(JunitResource.PROPERTY_SET_TEXTS, "a"); }
public void resourceRefresh(IPResource resource) { Long internalId = resource.getInternalId(); if (internalId == null) { Optional<IPResource> found = resourceService.resourceFindByPk(resource); if (found.isPresent()) { internalId = found.get().getInternalId(); } } resourceRefresh(internalId); }
protected void tagsClean(Tuple2<IPResource, String> newTuple, List<Tuple2<IPResource, String>> tagsList) { tagsList.removeIf(it -> // resourceService.resourceEqualsPk(newTuple.getA(), it.getA()) && // newTuple.getB().equals(it.getB()) // ); }
private void checkUniqueName(CommonServicesContext services, String name) { IPResourceService resourceService = services.getResourceService(); List<UnixUser> unixUsers = resourceService.resourceFindAll(resourceService.createResourceQuery(UnixUser.class) // .propertyEquals(UnixUser.PROPERTY_NAME, name)); if (unixUsers.size() > 1) { throw new IllegalUpdateException("Unix User name " + name + " is already used"); } }
public <T extends IPResource> T assertResourceExists(boolean expectedExists, T resourcePk, Class<T> resourceClass) { IPResourceService resourceService = getCommonServicesContext().getResourceService(); Optional<T> resourceFindOne = resourceService.resourceFindByPk(resourcePk); Assert.assertEquals(expectedExists, resourceFindOne.isPresent()); if (resourceFindOne.isPresent()) { return resourceFindOne.get(); } else { return null; } }
@Test public void testQueryOne() { IPResourceService resourceService = getCommonServicesContext().getResourceService(); resourceService.resourceFindByPk(new JunitResource("www.example.com", JunitResourceEnum.A, 2)).get(); }