diff --git a/OpenAI Showcase App.mpr b/OpenAI Showcase App.mpr index 605e045f..a7a7c9e0 100644 Binary files a/OpenAI Showcase App.mpr and b/OpenAI Showcase App.mpr differ diff --git a/javasource/pgvectorknowledgebase/actions/ChunkList_RetrieveNearestNeighbors_SetAssociation.java b/javasource/pgvectorknowledgebase/actions/ChunkList_RetrieveNearestNeighbors_SetAssociation.java index 3042940a..239dfb0b 100644 --- a/javasource/pgvectorknowledgebase/actions/ChunkList_RetrieveNearestNeighbors_SetAssociation.java +++ b/javasource/pgvectorknowledgebase/actions/ChunkList_RetrieveNearestNeighbors_SetAssociation.java @@ -9,8 +9,10 @@ package pgvectorknowledgebase.actions; +import com.mendix.core.Core; import com.mendix.systemwideinterfaces.core.IContext; import com.mendix.systemwideinterfaces.core.IMendixObject; +import com.mendix.systemwideinterfaces.core.meta.IMetaObject; import com.mendix.webui.CustomJavaAction; import pgvectorknowledgebase.impl.ChunkUtils; import pgvectorknowledgebase.impl.MxLogger; @@ -32,14 +34,14 @@ public class ChunkList_RetrieveNearestNeighbors_SetAssociation extends CustomJav private IMendixObject __DatabaseConfiguration; private pgvectorknowledgebase.proxies.DatabaseConfiguration DatabaseConfiguration; private java.lang.String KnowledgeBaseName; - private IMendixObject TargetChunk; + private java.lang.String TargetChunk; private java.lang.String Vector; private java.util.List __LabelList; private java.util.List LabelList; private java.lang.Long MaxNumberOfResults; private java.math.BigDecimal MinimumSimilarity; - public ChunkList_RetrieveNearestNeighbors_SetAssociation(IContext context, IMendixObject DatabaseConfiguration, java.lang.String KnowledgeBaseName, IMendixObject TargetChunk, java.lang.String Vector, java.util.List LabelList, java.lang.Long MaxNumberOfResults, java.math.BigDecimal MinimumSimilarity) + public ChunkList_RetrieveNearestNeighbors_SetAssociation(IContext context, IMendixObject DatabaseConfiguration, java.lang.String KnowledgeBaseName, java.lang.String TargetChunk, java.lang.String Vector, java.util.List LabelList, java.lang.Long MaxNumberOfResults, java.math.BigDecimal MinimumSimilarity) { super(context); this.__DatabaseConfiguration = DatabaseConfiguration; @@ -65,14 +67,15 @@ public java.util.List executeAction() throws Exception // BEGIN USER CODE try { - ChunkUtils.validateTargetChunk(this.TargetChunk); + IMetaObject targetChunk = Core.getMetaObject(TargetChunk); + ChunkUtils.validateTargetChunk(targetChunk); // call a microflow to retrieve chunks java.util.List chunkList = pgvectorknowledgebase.proxies.microflows.Microflows.chunkList_RetrieveNearestNeighbors( getContext(), DatabaseConfiguration, KnowledgeBaseName, Vector, MinimumSimilarity, MaxNumberOfResults, LabelList); //map to target chunks to return - return ChunkUtils.getTargetChunkList(getContext(), chunkList, TargetChunk, LOGGER); + return ChunkUtils.getTargetChunkList(getContext(), chunkList, targetChunk, LOGGER); } catch (Exception e) { LOGGER.error(e.getMessage()); diff --git a/javasource/pgvectorknowledgebase/actions/ChunkList_Retrieve_SetAssociation.java b/javasource/pgvectorknowledgebase/actions/ChunkList_Retrieve_SetAssociation.java index 9db64743..73823f02 100644 --- a/javasource/pgvectorknowledgebase/actions/ChunkList_Retrieve_SetAssociation.java +++ b/javasource/pgvectorknowledgebase/actions/ChunkList_Retrieve_SetAssociation.java @@ -9,8 +9,10 @@ package pgvectorknowledgebase.actions; +import com.mendix.core.Core; import com.mendix.systemwideinterfaces.core.IContext; import com.mendix.systemwideinterfaces.core.IMendixObject; +import com.mendix.systemwideinterfaces.core.meta.IMetaObject; import com.mendix.webui.CustomJavaAction; import pgvectorknowledgebase.impl.ChunkUtils; import pgvectorknowledgebase.impl.MxLogger; @@ -32,13 +34,13 @@ public class ChunkList_Retrieve_SetAssociation extends CustomJavaAction __LabelList; private java.util.List LabelList; private java.lang.Long MaxNumberOfResults; private java.lang.Long Offset; - public ChunkList_Retrieve_SetAssociation(IContext context, IMendixObject DatabaseConfiguration, java.lang.String KnowledgeBaseName, IMendixObject TargetChunk, java.util.List LabelList, java.lang.Long MaxNumberOfResults, java.lang.Long Offset) + public ChunkList_Retrieve_SetAssociation(IContext context, IMendixObject DatabaseConfiguration, java.lang.String KnowledgeBaseName, java.lang.String TargetChunk, java.util.List LabelList, java.lang.Long MaxNumberOfResults, java.lang.Long Offset) { super(context); this.__DatabaseConfiguration = DatabaseConfiguration; @@ -63,15 +65,15 @@ public java.util.List executeAction() throws Exception // BEGIN USER CODE try { - - ChunkUtils.validateTargetChunk(TargetChunk); + IMetaObject targetChunk = Core.getMetaObject(TargetChunk); + ChunkUtils.validateTargetChunk(targetChunk); // call a microflow to retrieve chunks java.util.List chunkList = pgvectorknowledgebase.proxies.microflows.Microflows.chunkList_Retrieve( getContext(), DatabaseConfiguration, KnowledgeBaseName, MaxNumberOfResults, LabelList, Offset); //map to target chunks to return - return ChunkUtils.getTargetChunkList(getContext(), chunkList, TargetChunk, LOGGER); + return ChunkUtils.getTargetChunkList(getContext(), chunkList, targetChunk, LOGGER); } catch (Exception e) { LOGGER.error(e.getMessage()); diff --git a/javasource/pgvectorknowledgebase/impl/ChunkUtils.java b/javasource/pgvectorknowledgebase/impl/ChunkUtils.java index 5235a99a..defa0d07 100644 --- a/javasource/pgvectorknowledgebase/impl/ChunkUtils.java +++ b/javasource/pgvectorknowledgebase/impl/ChunkUtils.java @@ -9,6 +9,7 @@ import com.mendix.systemwideinterfaces.core.IContext; import com.mendix.systemwideinterfaces.core.IMendixObject; import com.mendix.systemwideinterfaces.core.meta.IMetaAssociation; +import com.mendix.systemwideinterfaces.core.meta.IMetaObject; import communitycommons.ORM; import pgvectorknowledgebase.proxies.Chunk; @@ -16,10 +17,10 @@ public class ChunkUtils { - public static void validateTargetChunk(IMendixObject TargetChunk) throws Exception { + public static void validateTargetChunk(IMetaObject TargetChunk) throws Exception { // verify target chunk on non-null, subclass of chunk, requireNonNull(TargetChunk, "Target Chunk must be specified"); - if (! TargetChunk.getMetaObject().isSubClassOf("PgVectorKnowledgeBase.Chunk")){ + if (! TargetChunk.isSubClassOf("PgVectorKnowledgeBase.Chunk")){ throw new Exception("Target Chunk must be a specialization of PgVectorKnowledgeBase.Chunk"); } }; @@ -28,14 +29,14 @@ public static void validateTargetChunk(IMendixObject TargetChunk) throws Excepti public static java.util.List getTargetChunkList( - IContext context, java.util.List chunkList, IMendixObject targetChunk, MxLogger LOGGER) { + IContext context, java.util.List chunkList, IMetaObject targetChunk, MxLogger LOGGER) { // create list to return java.util.List targetChunkList = new ArrayList(); // per chunk create a TargetChunk (custom specialization) chunkList.forEach(c -> { // - instantiate Target Chunk (custom specialization) - IMendixObject targetChunkSpecialization = Core.instantiate(context, targetChunk.getMetaObject().getName()); + IMendixObject targetChunkSpecialization = Core.instantiate(context, targetChunk.getName()); // copy values from Chunk to Target Chunk (custom specialization) ORM.cloneObject(context, c.getMendixObject(), targetChunkSpecialization, true); try { @@ -49,7 +50,6 @@ public static java.util.List getTargetChunkList( // find matching association based on meta object name Long assocationsSetCount= targetChunk - .getMetaObject() .getMetaAssociationsParent() .stream() .filter(a -> assocationMatchesTarget(a, targetObject)) @@ -59,7 +59,7 @@ public static java.util.List getTargetChunkList( // set association if found, otherwise log a warning if (assocationsSetCount == 0){ LOGGER.warn("No eligible association found for target object " + targetObject.getMetaObject().getName() - + " on entity " + targetChunk.getMetaObject().getName()); + + " on entity " + targetChunk.getName()); } } catch (Exception e) {