Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix Kai client's build spec for Windows #351

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

pranavgaikwad
Copy link
Contributor

@pranavgaikwad pranavgaikwad commented Sep 4, 2024

This also addresses a bug in JSON decoder caused due to differences in default encoding on Windows. Now we don't have to worry about default encoding as we are not reading strings anymore but using the bytes directly and enforcing utf-8 encoding explicitly.

gaikw@pranav MINGW64 /e/Projects/kai/playpen (main)
$ python rpc-client.py /e/Projects/kai/kai/config.toml coolstore /e/Projects/kai/notebooks/evaluation/analysis_output.yaml /e/Projects/coolstore/src/main/java/com/redhat/coolstore/service/CatalogService.java
running get_incident_solutions_for_file() with params {'config_path': 'E:/Projects/kai/kai/config.toml', 'app_name': 'coolstore', 'report_path': 'E:/Projects/kai/notebooks/evaluation/analysis_output.yaml', 'input_file_path': 'E:/Projects/coolstore/src/main/java/com/redhat/coolstore/service/CatalogService.java'}
package com.redhat.coolstore.service;

import java.util.List;
import java.util.logging.Logger;

import jakarta.inject.Inject;

import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Root;

import jakarta.ejb.ApplicationScoped;
import jakarta.persistence.EntityManager;

import com.redhat.coolstore.model.*;

@ApplicationScoped
public class CatalogService {

    @Inject
    Logger log;

    @Inject
    private EntityManager em;

    public CatalogService() {
    }

    public List<CatalogItemEntity> getCatalogItems() {
        CriteriaBuilder cb = em.getCriteriaBuilder();
        CriteriaQuery<CatalogItemEntity> criteria = cb.createQuery(CatalogItemEntity.class);
        Root<CatalogItemEntity> member = criteria.from(CatalogItemEntity.class);
        criteria.select(member);
        return em.createQuery(criteria).getResultList();
    }

    public CatalogItemEntity getCatalogItemById(String itemId) {
        return em.find(CatalogItemEntity.class, itemId);
    }

    public void updateInventoryItems(String itemId, int deducts) {
        InventoryEntity inventoryEntity = getCatalogItemById(itemId).getInventory();
        int currentQuantity = inventoryEntity.getQuantity();
        inventoryEntity.setQuantity(currentQuantity-deducts);
        em.merge(inventoryEntity);
    }

}


Received response successfully!
(venv)

@pranavgaikwad pranavgaikwad changed the title 🐛 fix things for Windows 🐛 fix Kai client's build spec for Windows Sep 4, 2024
Signed-off-by: Pranav Gaikwad <pgaikwad@redhat.com>
Copy link
Member

@jwmatthews jwmatthews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pranavgaikwad pranavgaikwad merged commit 0006e28 into konveyor:main Sep 5, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants