Java Code Examples for javax.transaction.Transactional

The following examples show how to use javax.transaction.Transactional. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Test
@Transactional
public void testRegisterAdminIsIgnored() throws Exception {
    UserDTO u = new UserDTO(
        "badguy",               // login
        "password",             // password
        "Bad",                  // firstName
        "Guy",                  // lastName
        "[email protected]",   // e-mail
        true,                   // activated
        "en",                   // langKey
        new HashSet<>(Arrays.asList(AuthoritiesConstants.ADMIN)) // <-- only admin should be able to do that
    );

    restMvc.perform(
        post("/api/register")
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
            .content(TestUtil.convertObjectToJsonBytes(u)))
        .andExpect(status().isCreated());

    Optional<User> userDup = userRepository.findOneByLogin("badguy");
    assertThat(userDup.isPresent()).isTrue();
    assertThat(userDup.get().getAuthorities()).hasSize(1)
        .containsExactly(authorityRepository.findOne(AuthoritiesConstants.USER));
}
 
Example 2
@Test
@Transactional
public void testRegisterInvalidLogin() throws Exception {
    UserDTO u = new UserDTO(
        "funky-log!n",          // login <-- invalid
        "password",             // password
        "Funky",                // firstName
        "One",                  // lastName
        "[email protected]",    // e-mail
        true,                   // activated
        "en",                   // langKey
        new HashSet<>(Arrays.asList(AuthoritiesConstants.USER))
    );

    restUserMockMvc.perform(
        post("/api/register")
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
            .content(TestUtil.convertObjectToJsonBytes(u)))
        .andExpect(status().isBadRequest());

    Optional<User> user = userRepository.findOneByEmail("[email protected]");
    assertThat(user.isPresent()).isFalse();
}
 
Example 3
Source Project: apicurio-registry   Source File: JPARegistryStorage.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @see io.apicurio.registry.storage.RegistryStorage#deleteArtifactRule(java.lang.String, io.apicurio.registry.types.RuleType)
 */
@Override
@Transactional
public void deleteArtifactRule(String artifactId, RuleType rule)
throws ArtifactNotFoundException, RuleNotFoundException, RegistryStorageException {
    try {
        requireNonNull(artifactId);
        requireNonNull(rule);

        _getArtifact(artifactId, null);

        int affected = entityManager.createQuery("DELETE FROM Rule r " +
                                                 "WHERE r.artifactId = :artifact_id AND r.name = :name")
                                    .setParameter("artifact_id", artifactId)
                                    .setParameter("name", rule)
                                    .executeUpdate();

        if (affected == 0) {
            throw new RuleNotFoundException(rule);
        }
    } catch (PersistenceException ex) {
        throw new RegistryStorageException(ex);
    }
}
 
Example 4
/**
 * Use this method to change the password of a given {@link User}
 *
 * @param passwordChangeDTO the {@link PasswordChangeDTO} with the new values
 * @param user the {@link User} to be updated
 */
@Transactional
public void changePassword(PasswordChangeDTO passwordChangeDTO, User user) {

    final boolean actualMatch = this.passwordEncoder.passwordsMatch(
            passwordChangeDTO.getActualPassword(), user.getPassword());

    if (actualMatch) {
        if (passwordChangeDTO.isNewPassMatching()) {
            user.setPassword(this.passwordEncoder.encryptPassword(passwordChangeDTO.getNewPassword()));
            this.userRepository.saveAndFlushAndRefresh(user);
            return;
        }
        throw new BusinessLogicException("error.change-password.new-pass-not-match");
    }
    throw new BusinessLogicException("error.change-password.actual-pass-not-match");
}
 
Example 5
Source Project: pragmatic-microservices-lab   Source File: EventItemWriter.java    License: MIT License 6 votes vote down vote up
@Override
@Transactional
public void writeItems(List<Object> items) throws Exception {
    try (PrintWriter archive = new PrintWriter(new BufferedWriter(new FileWriter(
            new File(jobContext.getProperties().getProperty(ARCHIVE_DIRECTORY)
                    + "/archive_" + jobContext.getJobName()
                    + "_" + jobContext.getInstanceId()
                    + ".csv"), true)))) {
        for (Object item : items) {
            HandlingEventRegistrationAttempt attempt = (HandlingEventRegistrationAttempt) item;
            applicationEvents.receivedHandlingEventRegistrationAttempt(attempt);
            archive.println(attempt.getRegistrationTime()
                    + "," + attempt.getCompletionTime()
                    + "," + attempt.getTrackingId()
                    + "," + attempt.getVoyageNumber()
                    + "," + attempt.getUnLocode()
                    + "," + attempt.getType());
        }
    }
}
 
Example 6
Source Project: we-cmdb   Source File: CiServiceImplTest.java    License: Apache License 2.0 6 votes vote down vote up
@Transactional
@Test
public void executeIntegrateQueryForMultiReferCiThroughReferenceByRSThenReturnResultSucessfully() {
    IntegrationQueryDto child = new IntegrationQueryDto("invoke_sequence_design");
    child.setCiTypeId(6);
    child.setAttrs(Lists.newArrayList(92));
    child.setAttrKeyNames(Lists.newArrayList("invoke_sequence_design.code"));
    child.setParentRs(new Relationship(96, false));

    IntegrationQueryDto parent = new IntegrationQueryDto("invoke_design");
    parent.setCiTypeId(5);
    parent.setAttrs(Lists.newArrayList(76));
    parent.setAttrKeyNames(Lists.newArrayList("invoke_design.code"));
    parent.setChildren(Lists.newArrayList(child));
    AdhocIntegrationQueryDto adhocQuery = new AdhocIntegrationQueryDto();
    adhocQuery.setCriteria(parent);
    adhocQuery.setQueryRequest(new QueryRequest());

    QueryResponse response = ciService.adhocIntegrateQuery(adhocQuery);
    assertThat(response.getContents()
            .size(), equalTo(10));
}
 
Example 7
Source Project: realworld-api-quarkus   Source File: ArticlesServiceImpl.java    License: MIT License 6 votes vote down vote up
@Override
@Transactional
public ArticlesData findArticles(
    int offset,
    int limit,
    Long loggedUserId,
    List<String> tags,
    List<String> authors,
    List<String> favorited) {

  List<Article> articles =
      articleRepository.findArticles(offset, getLimit(limit), tags, authors, favorited);

  long articlesCount = articleRepository.count(tags, authors, favorited);

  return new ArticlesData(toResultList(articles, loggedUserId), articlesCount);
}
 
Example 8
Source Project: we-cmdb   Source File: CiServiceImplLegacyModelTest.java    License: Apache License 2.0 6 votes vote down vote up
@Transactional
@Test
public void updateIsNotNullableFieldThenGetException() {
    Map<String, Object> ciDataMap = MapUtils.putAll(new HashMap(), new Object[] { "guid", "0002_0000000002", "system_type", null });
    try {
        ciService.update(2, ImmutableList.of(ciDataMap));
        Assert.assertFalse(true);// should not be reached
    } catch (BatchChangeException ex) {
        Assert.assertThat(ex.getExceptionHolders()
                .size(), greaterThan(0));
        Assert.assertThat(ex.getExceptionHolders()
                .get(0)
                .getException()
                .getClass(), equalTo(InvalidArgumentException.class));
        Assert.assertThat(((InvalidArgumentException) ex.getExceptionHolders()
                .get(0)
                .getException()).getArgumentName(), equalTo("system_type"));
    }
}
 
Example 9
/**
 * Update the {@link PeriodMovement}
 *
 * @param periodMovement the {@link PeriodMovement} to be updated
 * @return the updated {@link PeriodMovement}
 */
@Transactional
public PeriodMovement update(PeriodMovement periodMovement) {

    this.periodMovementUpdatingLogics.forEach(logic -> logic.run(periodMovement));

    // delete all removed apportionments
    periodMovement.getDeletedApportionments()
            .forEach(apportionment -> this.apportionmentRepository.attachAndRemove(apportionment));

    final PeriodMovement saved = this.periodMovementRepository.saveAndFlushAndRefresh(periodMovement);

    // save all current apportionments
    periodMovement.getApportionments().forEach(apportionment -> {
        apportionment.setMovement(saved);
        this.apportionmentRepository.save(apportionment);
    });

    // fire an event telling about the update
    this.periodMovementUpdatedEvent.fire(saved);

    return saved;
}
 
Example 10
Source Project: we-cmdb   Source File: CiServiceImplLegacyModelTest.java    License: Apache License 2.0 6 votes vote down vote up
@Transactional
@Test
public void addCiDataWithAutoFieldThenThrowException() {
    Map<String, Object> ciDataMap = MapUtils.putAll(new HashMap(), new Object[] { "name_en", "new Bank system", "description", "duplicated name system", "system_type", 554, "key_name", "system_bank_system" // auto
                                                                                                                                                                                                              // filled
                                                                                                                                                                                                              // field
    });
    try {
        ciService.create(2, ImmutableList.of(ciDataMap));
        Assert.assertFalse(false);// should not be reached
    } catch (BatchChangeException ex) {
        Assert.assertThat(ex.getExceptionHolders()
                .size(), greaterThan(0));
        Assert.assertThat(ex.getExceptionHolders()
                .get(0)
                .getException()
                .getClass(), equalTo(InvalidArgumentException.class));
        Assert.assertThat(((InvalidArgumentException) ex.getExceptionHolders()
                .get(0)
                .getException()).getArgumentName(), equalTo("key_name"));
    }
}
 
Example 11
/**
 * Method to make the {@link WalletBalance} transference
 *
 * @param transference the transference
 */
@Transactional
public void transfer(Transference transference) {

    this.savingBusinessLogics.forEach(logic -> logic.run(transference));

    this.transferenceRepository.save(transference);

    // transfer
    this.updateWalletBalanceEvent.fire(WalletBalanceBuilder.getInstance()
            .to(transference.getDestination())
            .value(transference.getValue())
            .withReason(ReasonType.TRANSFERENCE)
            .build()
    );

    // adjust the origin balance
    this.updateWalletBalanceEvent.fire(WalletBalanceBuilder.getInstance()
            .to(transference.getOrigin())
            .value(transference.getValue().negate())
            .withReason(ReasonType.TRANSFERENCE)
            .build()
    );
}
 
Example 12
Source Project: openvsx   Source File: AdminService.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Transactional(rollbackOn = ErrorResultException.class)
public ResultJson editNamespaceMember(String namespaceName, String userName, String provider, String role, UserData admin)
        throws ErrorResultException {
    var namespace = repositories.findNamespace(namespaceName);
    if (namespace == null) {
        throw new ErrorResultException("Namespace not found: " + namespaceName);
    }
    if (Strings.isNullOrEmpty(provider)) {
        provider = "github";
    }
    var user = repositories.findUserByLoginName(provider, userName);
    if (user == null) {
        throw new ErrorResultException("User not found: " + provider + "/" + userName);
    }

    ResultJson result;
    if (role.equals("remove")) {
        result = users.removeNamespaceMember(namespace, user);
    } else {
        result = users.addNamespaceMember(namespace, user, role);
    }
    logAdminAction(admin, result);
    return result;
}
 
Example 13
@Transactional
public UserGroup update(String id, UpdateUserGroupRequest request) {
    UserGroup userGroup = this.get(id);
    if (!Strings.isNullOrEmpty(request.name)) {
        userGroup.name = request.name;
    }
    if (!Strings.isNullOrEmpty(request.description)) {
        userGroup.description = request.description;
    }
    if (request.roles != null) {
        userGroup.roles = Joiner.on(",").join(request.roles);
    }
    userGroup.updatedTime = now();
    userGroup.updatedBy = request.requestBy;
    repository.update(id, userGroup);
    return userGroup;
}
 
Example 14
Source Project: MultimediaDesktop   Source File: LoginIpServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Transactional
@Override
@HandlerPoint(handlerName = "loginHandler")
public void addLoginIp(LoginIpDto loginIpdto) {

	if (loginIpdto == null || StringUtils.isBlank(loginIpdto.getUserId())
			|| StringUtils.isBlank(loginIpdto.getIpaddress())
			|| loginIpdto.getLoginType() == null) {
		log.error("[登录记录]-[登录记录数据校验失败]-[校验数据为:]"
				+ ToStringBuilder.reflectionToString(loginIpdto));
		return;
	}

	LoginIp loginIp = new LoginIp(new User(loginIpdto.getUserId()),
			loginIpdto.getIpaddress(), loginIpdto.getLoginType());
	loginIpRepository.save(loginIp);
	userRepository.updateUserLastLoginDate(loginIpdto.getUserId(),
			loginIp.getLoginTime());
}
 
Example 15
Source Project: quarkus-quickstarts   Source File: EmitterResource.java    License: Apache License 2.0 6 votes vote down vote up
@Transactional
@GET
@Path("/prices")
@Produces(MediaType.SERVER_SENT_EVENTS)
@SseElementType(MediaType.TEXT_PLAIN)
public Publisher<Double> prices() {
    // get the next three prices from the price stream
    return Multi.createFrom().publisher(prices)
            .transform().byTakingFirstItems(3)
            .map(price -> {
                // store each price before we send them
                Price priceEntity = new Price();
                priceEntity.value = price;
                // here we are all in the same transaction
                // thanks to context propagation
                priceEntity.persist();
                return price;
                // the transaction is committed once the stream completes
            });
}
 
Example 16
Source Project: jeeshop   Source File: PresentationResource.java    License: Apache License 2.0 6 votes vote down vote up
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Transactional(value = Transactional.TxType.REQUIRES_NEW)
@RolesAllowed(ADMIN)
public Presentation modifyLocalizedPresentation(Presentation presentation) {
    checkEntityNotNull();

    if (this.presentation == null) {
        // Item does not exist
        throw new WebApplicationException(Response.Status.BAD_REQUEST);
    }
    entityManager.merge(presentation);

    return presentation;
}
 
Example 17
@Transactional
public Confirmation confirm(ItemState itemState) {
    List<Wrapper<CourseResponse>> wrappers = getWrappedCourses(new LinkedHashSet<>(itemState.getItems()));
    State newState = State.fromWrappers(wrappers);

    boolean matchingState = newState.isMatching(itemState.getState());
    log.debug("Is new state same as old state? {}", matchingState);

    if (!matchingState) {
        return new Confirmation(false, "Something went wrong! Please try again");
    } else {
        log.debug("Floating course requests {}", wrappers);
        Set<String> validCodes = wrappers.stream()
                .filter(item -> item.getMessage() == null || item.getMessage().getType() == Type.SUCCESS)
                .map(item -> item.getItem().getCode())
                .collect(Collectors.toCollection(LinkedHashSet::new));

        List<FloatedCourseLite> floatedCourseLites = new ArrayList<>();
        if (!validCodes.isEmpty()) {
            log.debug("Floating courses {}", validCodes);
            List<Course> courses = courseRepository.findAllByCodeIn(validCodes);
            List<FloatedCourse> floatedCourses = courses.stream()
                .map(course -> new FloatedCourse(ConfigurationService.getDefaultSessionCode(), course))
                .collect(Collectors.toList());
            Iterable<FloatedCourse> floated = floatedCourseRepository.saveAll(floatedCourses);


            floated.forEach(floatedCourse -> {
                floatedCourseLites.add(modelMapper.map(floatedCourse, FloatedCourseLiteImpl.class));
            });
        }

        return new FloatedCourseConfirmation(true, "Courses floated successfully", floatedCourseLites);
    }
}
 
Example 18
Source Project: quarkus   Source File: TestEndpoint.java    License: Apache License 2.0 5 votes vote down vote up
@GET
@Path("9036")
@Transactional
public String testBug9036() {
    Person.deleteAll();

    Person emptyPerson = new Person();
    emptyPerson.persist();

    Person deadPerson = new Person();
    deadPerson.name = "Stef";
    deadPerson.status = Status.DECEASED;
    deadPerson.persist();

    Person livePerson = new Person();
    livePerson.name = "Stef";
    livePerson.status = Status.LIVING;
    livePerson.persist();

    assertEquals(3, Person.count());
    assertEquals(3, Person.listAll().size());

    // should be filtered
    PanacheQuery<Person> query = Person.findAll(Sort.by("id")).filter("Person.isAlive").filter("Person.hasName",
            Parameters.with("name", "Stef"));
    assertEquals(1, query.count());
    assertEquals(1, query.list().size());
    assertEquals(livePerson, query.list().get(0));
    assertEquals(1, query.stream().count());
    assertEquals(livePerson, query.firstResult());
    assertEquals(livePerson, query.singleResult());

    // these should be unaffected
    assertEquals(3, Person.count());
    assertEquals(3, Person.listAll().size());

    Person.deleteAll();

    return "OK";
}
 
Example 19
Source Project: flux   Source File: StateMachineResource.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Increments the retry count for the specified Task under the specified State machine
 *
 * @param machineId the state machine identifier
 * @param stateId   the task/state identifier
 * @return Response with execution status code
 * @throws Exception
 */
@POST
@Path("/{machineId}/{stateId}/retries/inc")
@Transactional
@SelectDataSource(type = DataSourceType.READ_WRITE, storage = Storage.SHARDED)
public Response incrementRetry(@PathParam("machineId") String machineId,
                               @PathParam("stateId") Long stateId
) throws Exception {
    this.workFlowExecutionController.incrementExecutionRetries(machineId, stateId);
    return Response.status(Response.Status.ACCEPTED).build();
}
 
Example 20
Source Project: quarkus   Source File: ProxyTestEndpoint.java    License: Apache License 2.0 5 votes vote down vote up
@Transactional
public void setup(@Observes StartupEvent startupEvent) {
    Pet pet = new Pet();
    pet.setId(1);
    pet.setName("Goose");

    PetOwner petOwner = new PetOwner();
    petOwner.setId(1);
    petOwner.setName("Stuart");
    petOwner.setPet(pet);

    entityManager.persist(petOwner);

    pet = new Cat();
    pet.setId(2);
    pet.setName("Tiddles");

    petOwner = new PetOwner();
    petOwner.setId(2);
    petOwner.setName("Sanne");
    petOwner.setPet(pet);

    entityManager.persist(petOwner);

    pet = new Dog();
    pet.setId(3);
    pet.setName("Spot");
    ((Dog) pet).setFavoriteToy("Rubber Bone");

    petOwner = new PetOwner();
    petOwner.setId(3);
    petOwner.setName("Emmanuel");
    petOwner.setPet(pet);

    entityManager.persist(petOwner);

}
 
Example 21
Source Project: spring-content   Source File: CmisServiceBridge.java    License: Apache License 2.0 5 votes vote down vote up
@Transactional
public ObjectInFolderList getChildren(CmisRepositoryConfiguration config,
		String folderId,
		String filter,
		String orderBy,
		Boolean includeAllowableActions,
		IncludeRelationships includeRelationships,
		String renditionFilter,
		Boolean includePathSegment,
		BigInteger maxItems,
		BigInteger skipCount,
		ExtensionsData extension,
		CallContext context,
		ObjectInfoHandler handler) {

	Set<String> filterCol = splitFilter(filter);

	Object parent = null;
	List<Object> children = new ArrayList<>();

	if (folderId.equals(getRootId()) == false) {
		parent = getObjectInternal(config,
				folderId,
				filterCol,
				false,
				IncludeRelationships.NONE,
				null,
				false,
				false,
				null
				);
	}

	children = config.getCmisNavigationService().getChildren(parent);

	return toObjectInFolderList(config, context, children, filterCol,true, handler);
}
 
Example 22
Source Project: java-all   Source File: ManyToManyExampleApplication.java    License: MIT License 5 votes vote down vote up
@Override
@Transactional
public void run(String... args) throws Exception {
    // Tạo ra đối tượng Address
    Address hanoi = Address.builder()
                             .city("hanoi")
                             .build();
    Address hatay = Address.builder()
                           .city("hatay")
                           .build();

    // Tạo ra đối tượng person
    Person person1 = Person.builder()
                          .name("loda1")
                          .build();
    Person person2 = Person.builder()
                          .name("loda2")
                          .build();

    // set Persons vào address
    hanoi.setPersons(Lists.newArrayList(person1, person2));
    hatay.setPersons(Lists.newArrayList(person1));

    // Lưu vào db
    // Chúng ta chỉ cần lưu address, vì cascade = CascadeType.ALL nên nó sẽ lưu luôn Person.
    addressRepository.saveAndFlush(hanoi);
    addressRepository.saveAndFlush(hatay);


    // Vào: http://localhost:8080/h2-console/ để xem dữ liệu đã insert

    Address queryResult = addressRepository.findById(1L).get();
    System.out.println(queryResult.getCity());
    System.out.println(queryResult.getPersons());

}
 
Example 23
Source Project: flux   Source File: StatesDAOImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@Transactional
@SelectDataSource(type = DataSourceType.READ_WRITE, storage = Storage.SHARDED)
public void incrementRetryCount(String stateMachineId, Long stateId) {
    Query query = currentSession().createQuery("update State set attemptedNoOfRetries = attemptedNoOfRetries + 1 where id = :stateId and stateMachineId = :stateMachineId");
    query.setLong("stateId", stateId);
    query.setString("stateMachineId", stateMachineId);
    query.executeUpdate();
}
 
Example 24
@Transactional
public void delete(DeleteVariableRequest request) {
    for (String id : request.ids) {
        PageVariable pageVariable = get(id);
        repository.delete(id);
        VariableChangedMessage message = new VariableChangedMessage();
        message.name = pageVariable.name;
        publisher.publish(message);
    }
}
 
Example 25
Source Project: library   Source File: AuthorBean.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
@Transactional
public void doUpdate() {
    this.authorUpdatingLogic.forEach(logic -> logic.run(this.value));
    this.authorRepository.save(this.value);
    this.addInfo(true, "updated");
}
 
Example 26
@Test
    @Transactional
    public void queryNetworkSegmentWithFatherReferenceThenReturnProperRecord(){
        List result = routeQueryExpressionService.executeQuery("network_segment~(f_network_segment)network_segment:guid");
//        List result = routeQueryExpressionService.executeQuery("network_segment[{mask eq 16}].f_network_segment>network_segment:guid");
        assertThat(result,notNullValue());
        assertThat(result.size(),equalTo(8));
    }
 
Example 27
Source Project: apicurio-registry   Source File: JPARegistryStorage.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@Transactional
public StoredArtifact getArtifactVersion(String artifactId, long version) throws ArtifactNotFoundException, VersionNotFoundException, RegistryStorageException {
    requireNonNull(artifactId);
    try {
        return mapper.toStoredArtifact(_getArtifact(artifactId, version, ArtifactStateExt.ACTIVE_STATES));
    } catch (PersistenceException ex) {
        throw new RegistryStorageException(ex);
    }
}
 
Example 28
Source Project: we-cmdb   Source File: RouteQueryExpressListenerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
@Transactional
public void testRouteQueryParseForBwdChain() {
    String expression = "system_design~(system_design)subsys_design:key_name";
    AdhocIntegrationQueryDto adhocIntegrationQueryDto = expressParser.parse(expression);
    IntegrationQueryDto intQuery = adhocIntegrationQueryDto.getCriteria();
    assertThat(intQuery, notNullValue());
    assertThat(intQuery.getChildren().size(), equalTo(1));
    IntegrationQueryDto query_l2 = intQuery.getChildren().get(0);
    assertThat(query_l2.getCiTypeId(), equalTo(2));
    assertThat(query_l2.getParentRs(), notNullValue());
    assertThat(query_l2.getParentRs().getAttrId(), equalTo(27));
    assertThat(query_l2.getParentRs().getIsReferedFromParent(), is(false));


    expression = "system_design~(system_design)subsys_design~(subsys_design)unit_design:key_name";
    adhocIntegrationQueryDto = expressParser.parse(expression);
    intQuery = adhocIntegrationQueryDto.getCriteria();
    assertThat(intQuery, notNullValue());
    assertThat(intQuery.getChildren().size(), equalTo(1));
    query_l2 = intQuery.getChildren().get(0);
    assertThat(query_l2.getCiTypeId(), equalTo(2));
    assertThat(query_l2.getParentRs(), notNullValue());
    assertThat(query_l2.getParentRs().getAttrId(), equalTo(27));
    assertThat(query_l2.getParentRs().getIsReferedFromParent(), is(false));
    IntegrationQueryDto query_l3 = query_l2.getChildren().get(0);
    assertThat(query_l3.getCiTypeId(), equalTo(3));
    assertThat(query_l3.getParentRs(), notNullValue());
    assertThat(query_l3.getParentRs().getAttrId(), equalTo(43));
    assertThat(query_l3.getParentRs().getIsReferedFromParent(), is(false));

}
 
Example 29
Source Project: Tokenator   Source File: ApiController.java    License: GNU General Public License v3.0 5 votes vote down vote up
@RequestMapping(
        value = "/surrogates/{surrogateId}",
        method = RequestMethod.DELETE
)
@ResponseStatus(HttpStatus.NO_CONTENT) /* 204, success but no response payload */
@Transactional
public void deleteSurrogate(@PathVariable(value="surrogateId") long surrogateId) {
    surrogateDataRepo.delete(surrogateId);
}
 
Example 30
Source Project: flux   Source File: StatesDAOImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@Transactional
@SelectDataSource(type = DataSourceType.READ_WRITE, storage = Storage.SHARDED)
public void updateRollbackStatus(String stateMachineId, Long stateId, Status rollbackStatus) {
    Query query = currentSession().createQuery("update State set rollbackStatus = :rollbackStatus where id = :stateId and stateMachineId = :stateMachineId");
    query.setString("rollbackStatus", rollbackStatus != null ? rollbackStatus.toString() : null);
    query.setLong("stateId", stateId);
    query.setString("stateMachineId", stateMachineId);
    query.executeUpdate();
}