diff --git a/backend/src/main/java/ch/xxx/aidoclibchat/adapter/repository/ImageRepositoryBean.java b/backend/src/main/java/ch/xxx/aidoclibchat/adapter/repository/ImageRepositoryBean.java new file mode 100644 index 0000000..8e82dbe --- /dev/null +++ b/backend/src/main/java/ch/xxx/aidoclibchat/adapter/repository/ImageRepositoryBean.java @@ -0,0 +1,52 @@ +/** + * Copyright 2023 Sven Loesekann + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ +package ch.xxx.aidoclibchat.adapter.repository; + +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +import org.springframework.stereotype.Repository; + +import ch.xxx.aidoclibchat.domain.model.entity.Image; +import ch.xxx.aidoclibchat.domain.model.entity.ImageRepository; + +@Repository +public class ImageRepositoryBean implements ImageRepository { + private final JpaImageRepository jpaImageRepository; + + public ImageRepositoryBean(JpaImageRepository jpaImageRepository) { + this.jpaImageRepository = jpaImageRepository; + } + + @Override + public Optional findById(UUID id) { + return this.findById(id); + } + + @Override + public Image save(Image document) { + return this.jpaImageRepository.save(document); + } + + @Override + public List findAll() { + return this.jpaImageRepository.findAll(); + } + + @Override + public List findAllById(Iterable ids) { + return this.jpaImageRepository.findAllById(ids); + } + +} diff --git a/backend/src/main/java/ch/xxx/aidoclibchat/adapter/repository/JpaImageRepository.java b/backend/src/main/java/ch/xxx/aidoclibchat/adapter/repository/JpaImageRepository.java new file mode 100644 index 0000000..97b862c --- /dev/null +++ b/backend/src/main/java/ch/xxx/aidoclibchat/adapter/repository/JpaImageRepository.java @@ -0,0 +1,23 @@ +/** + * Copyright 2023 Sven Loesekann + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ +package ch.xxx.aidoclibchat.adapter.repository; + +import java.util.UUID; + +import org.springframework.data.jpa.repository.JpaRepository; + +import ch.xxx.aidoclibchat.domain.model.entity.Image; + +public interface JpaImageRepository extends JpaRepository { + +} diff --git a/backend/src/main/java/ch/xxx/aidoclibchat/domain/common/MetaData.java b/backend/src/main/java/ch/xxx/aidoclibchat/domain/common/MetaData.java index d45f127..2213930 100644 --- a/backend/src/main/java/ch/xxx/aidoclibchat/domain/common/MetaData.java +++ b/backend/src/main/java/ch/xxx/aidoclibchat/domain/common/MetaData.java @@ -16,7 +16,7 @@ public class MetaData { public enum DataType { - DOCUMENT, TABLE, COLUMN, ROW + DOCUMENT, TABLE, COLUMN, ROW, IMAGE }; public enum DocumentType { diff --git a/backend/src/main/java/ch/xxx/aidoclibchat/domain/model/entity/Image.java b/backend/src/main/java/ch/xxx/aidoclibchat/domain/model/entity/Image.java new file mode 100644 index 0000000..deb23df --- /dev/null +++ b/backend/src/main/java/ch/xxx/aidoclibchat/domain/model/entity/Image.java @@ -0,0 +1,61 @@ +/** + * Copyright 2023 Sven Loesekann + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ +package ch.xxx.aidoclibchat.domain.model.entity; + +import java.util.UUID; + +import ch.xxx.aidoclibchat.domain.common.MetaData.ImageType; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Lob; + +@Entity +public class Image { + @Id + @GeneratedValue(strategy = GenerationType.UUID) + private UUID id; + private String imageName; + @Enumerated(EnumType.STRING) + private ImageType imageType; + @Lob + private byte[] imageContent; + + public UUID getId() { + return id; + } + public void setId(UUID id) { + this.id = id; + } + public String getImageName() { + return imageName; + } + public void setImageName(String imageName) { + this.imageName = imageName; + } + public ImageType getImageType() { + return imageType; + } + public void setImageType(ImageType imageType) { + this.imageType = imageType; + } + public byte[] getImageContent() { + return imageContent; + } + public void setImageContent(byte[] imageContent) { + this.imageContent = imageContent; + } +} diff --git a/backend/src/main/java/ch/xxx/aidoclibchat/domain/model/entity/ImageRepository.java b/backend/src/main/java/ch/xxx/aidoclibchat/domain/model/entity/ImageRepository.java new file mode 100644 index 0000000..10a12f1 --- /dev/null +++ b/backend/src/main/java/ch/xxx/aidoclibchat/domain/model/entity/ImageRepository.java @@ -0,0 +1,24 @@ +/** + * Copyright 2023 Sven Loesekann + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ +package ch.xxx.aidoclibchat.domain.model.entity; + +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +public interface ImageRepository { + Optional findById(UUID id); + Image save(Image document); + List findAll(); + List findAllById(Iterable ids); +} diff --git a/backend/src/main/resources/dbchangelog/changes/db.changelog-3.xml b/backend/src/main/resources/dbchangelog/changes/db.changelog-3.xml new file mode 100644 index 0000000..a59416b --- /dev/null +++ b/backend/src/main/resources/dbchangelog/changes/db.changelog-3.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/src/main/resources/dbchangelog/db.changelog-master-ollama.xml b/backend/src/main/resources/dbchangelog/db.changelog-master-ollama.xml index 5b60518..b55dec6 100644 --- a/backend/src/main/resources/dbchangelog/db.changelog-master-ollama.xml +++ b/backend/src/main/resources/dbchangelog/db.changelog-master-ollama.xml @@ -19,6 +19,7 @@ + diff --git a/backend/src/main/resources/dbchangelog/db.changelog-master.xml b/backend/src/main/resources/dbchangelog/db.changelog-master.xml index 3b2436c..4f6ed15 100644 --- a/backend/src/main/resources/dbchangelog/db.changelog-master.xml +++ b/backend/src/main/resources/dbchangelog/db.changelog-master.xml @@ -18,6 +18,7 @@ + diff --git a/frontend/src/angular/src/app/image-query/image-query.component.ts b/frontend/src/angular/src/app/image-query/image-query.component.ts index e2b6dd3..176cf34 100644 --- a/frontend/src/angular/src/app/image-query/image-query.component.ts +++ b/frontend/src/angular/src/app/image-query/image-query.component.ts @@ -31,6 +31,7 @@ import { MatToolbarModule } from '@angular/material/toolbar'; styleUrl: './image-query.component.scss' }) export class ImageQueryComponent { + //'What do you see in the image? Describe the background. Describe the colors.' protected imageForm = new FormGroup({ file: new FormControl(null, Validators.required), query: new FormControl('', Validators.minLength(3))