-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature ETP: Add Cloning hook for Assistants and KBFile #58
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GPT Review for AD_TAB.xmlReview
Code feedback
<!--09F802E423924081BC2947A64DDB5AF5--> <EM_OBUIAPP_SHOW_CLONE_BUTTON><![CDATA[Y]]></EM_OBUIAPP_SHOW_CLONE_BUTTON>
<!--09F802E423924081BC2947A64DDB5AF5--> <EM_OBUIAPP_CLONE_CHILDREN><![CDATA[N]]></EM_OBUIAPP_CLONE_CHILDREN>
<!--09F802E423924081BC2947A64DDB5AF5--> <EM_OBUIAPP_SHOW_CLONE_BUTTON><![CDATA[Y]]></EM_OBUIAPP_SHOW_CLONE_BUTTON>
<!--09F802E423924081BC2947A64DDB5AF5--> <EM_OBUIAPP_CLONE_CHILDREN><![CDATA[N]]></EM_OBUIAPP_CLONE_CHILDREN>
<!--F0AE228DDA0D4A3F98A08B8284EF1689--> <EM_OBUIAPP_SHOW_CLONE_BUTTON><![CDATA[Y]]></EM_OBUIAPP_SHOW_CLONE_BUTTON>
<!--F0AE228DDA0D4A3F98A08B8284EF1689--> <EM_OBUIAPP_CLONE_CHILDREN><![CDATA[N]]></EM_OBUIAPP_CLONE_CHILDREN>
<!--F0AE228DDA0D4A3F98A08B8284EF1689--> <EM_OBUIAPP_SHOW_CLONE_BUTTON><![CDATA[Y]]></EM_OBUIAPP_SHOW_CLONE_BUTTON>
<!--F0AE228DDA0D4A3F98A08B8284EF1689--> <EM_OBUIAPP_CLONE_CHILDREN><![CDATA[N]]></EM_OBUIAPP_CLONE_CHILDREN> |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GPT Review for CloneAssistant.javaReview
Code feedback
OBDal.getInstance().save(cloneAssistant);
OBDal.getInstance().flush();
OBDal.getInstance().refresh(cloneAssistant);
return cloneAssistant;
try {
OBDal.getInstance().save(cloneAssistant);
OBDal.getInstance().flush();
OBDal.getInstance().refresh(cloneAssistant);
} catch (Exception e) {
// Log the exception and handle it appropriately
System.err.println("Error during cloning operation: " + e.getMessage());
// Consider rethrowing the exception or handling it based on your application's needs
}
return cloneAssistant;
System.err.println("Error during cloning operation: " + e.getMessage());
import java.util.logging.Logger;
private static final Logger LOGGER = Logger.getLogger(CloneAssistant.class.getName());
LOGGER.severe("Error during cloning operation: " + e.getMessage()); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.etendoerp.copilot.hook.cloning; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
import org.openbravo.base.structure.BaseOBObject; | ||
import org.openbravo.client.kernel.ComponentProvider.Qualifier; | ||
import org.openbravo.dal.service.OBDal; | ||
|
||
import com.etendoerp.copilot.data.CopilotApp; | ||
import com.smf.jobs.hooks.CloneRecordHook; | ||
|
||
@ApplicationScoped | ||
@Qualifier(CopilotApp.ENTITY_NAME) | ||
public class CloneAssistant extends CloneRecordHook { | ||
|
||
/** | ||
* Determines whether to copy child records. | ||
* <p> | ||
* This method always returns true, indicating that child records should be copied. | ||
* | ||
* @param uiCopyChildren | ||
* A boolean indicating if the UI requests to copy children. | ||
* @return true, indicating that child records should be copied. | ||
*/ | ||
@Override | ||
public boolean shouldCopyChildren(boolean uiCopyChildren) { | ||
return true; | ||
} | ||
|
||
/** | ||
* Pre-copy hook. | ||
* <p> | ||
* This method is called before the original record is copied. It returns the original record without modifications. | ||
* | ||
* @param originalRecord | ||
* The original record to be copied. | ||
* @return The original record. | ||
*/ | ||
@Override | ||
public BaseOBObject preCopy(BaseOBObject originalRecord) { | ||
return originalRecord; | ||
} | ||
|
||
/** | ||
* Post-copy hook. | ||
* <p> | ||
* This method is called after the original record is copied. It modifies the cloned record by setting a new name and nullifying the module. | ||
* The cloned record is then saved, flushed, and refreshed in the database. | ||
* | ||
* @param originalRecord | ||
* The original record that was copied. | ||
* @param newRecord | ||
* The newly created cloned record. | ||
* @return The modified cloned record. | ||
*/ | ||
@Override | ||
public BaseOBObject postCopy(BaseOBObject originalRecord, BaseOBObject newRecord) { | ||
CopilotApp originalAssistant = (CopilotApp) originalRecord; | ||
CopilotApp cloneAssistant = (CopilotApp) newRecord; | ||
cloneAssistant.setName("Copy of " + originalAssistant.getName()); | ||
cloneAssistant.setModule(null); | ||
|
||
OBDal.getInstance().save(cloneAssistant); | ||
OBDal.getInstance().flush(); | ||
OBDal.getInstance().refresh(cloneAssistant); | ||
return cloneAssistant; | ||
} | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GPT Review for CloneKBFile.javaReview
Code feedback
OBDal.getInstance().save(cloneFile);
OBDal.getInstance().flush();
OBDal.getInstance().refresh(cloneFile);
try {
OBDal.getInstance().save(cloneFile);
OBDal.getInstance().flush();
OBDal.getInstance().refresh(cloneFile);
} catch (Exception e) {
// Log the exception and handle it appropriately
System.err.println("Error during database operations: " + e.getMessage());
// Consider rethrowing the exception or handling it based on your application's needs
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.etendoerp.copilot.hook.cloning; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
import org.openbravo.base.structure.BaseOBObject; | ||
import org.openbravo.client.kernel.ComponentProvider.Qualifier; | ||
import org.openbravo.dal.service.OBDal; | ||
|
||
import com.etendoerp.copilot.data.CopilotFile; | ||
import com.smf.jobs.hooks.CloneRecordHook; | ||
|
||
@ApplicationScoped | ||
@Qualifier(CopilotFile.ENTITY_NAME) | ||
public class CloneKBFile extends CloneRecordHook { | ||
|
||
/** | ||
* Determines whether to copy child records. | ||
* <p> | ||
* This method always returns true, indicating that child records should be copied. | ||
* | ||
* @param uiCopyChildren | ||
* A boolean indicating if the UI requests to copy children. | ||
* @return true, indicating that child records should be copied. | ||
*/ | ||
@Override | ||
public boolean shouldCopyChildren(boolean uiCopyChildren) { | ||
return true; | ||
} | ||
|
||
/** | ||
* Pre-copy hook. | ||
* <p> | ||
* This method is called before the original record is copied. It returns the original record without modifications. | ||
* | ||
* @param originalRecord | ||
* The original record to be copied. | ||
* @return The original record. | ||
*/ | ||
@Override | ||
public BaseOBObject preCopy(BaseOBObject originalRecord) { | ||
return originalRecord; | ||
} | ||
|
||
/** | ||
* Post-copy hook. | ||
* <p> | ||
* This method is called after the original record is copied. It modifies the cloned record by setting a new name and nullifying the module. | ||
* The cloned record is then saved, flushed, and refreshed in the database. | ||
* | ||
* @param originalRecord | ||
* The original record that was copied. | ||
* @param newRecord | ||
* The newly created cloned record. | ||
* @return The modified cloned record. | ||
*/ | ||
@Override | ||
public BaseOBObject postCopy(BaseOBObject originalRecord, BaseOBObject newRecord) { | ||
CopilotFile originalFile = (CopilotFile) originalRecord; | ||
CopilotFile cloneFile = (CopilotFile) newRecord; | ||
cloneFile.setName("Copy of " + originalFile.getName()); | ||
cloneFile.setModule(null); | ||
|
||
OBDal.getInstance().save(cloneFile); | ||
OBDal.getInstance().flush(); | ||
OBDal.getInstance().refresh(cloneFile); | ||
return cloneFile; | ||
} | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GPT Review for CheckHostsButton.javaReview
Code feedback
String token = CopilotUtils.generateEtendoToken();
if (token == null) {
log4j.error("Token is null. Unable to proceed with host checks.");
throw new OBException("Error when generating token.");
}
String token = CopilotUtils.generateEtendoToken();
if (token == null) {
log4j.error("Token is null. Unable to proceed with host checks.");
throw new OBException("Error when generating token.");
} else {
log4j.info("Token generated successfully.");
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GPT Review for CopilotUtils.javaReview
Code feedback
return getEtendoSWSToken(OBContext.getOBContext(), null);
OBContext context = OBContext.getOBContext();
if (context == null) {
throw new IllegalArgumentException("OBContext cannot be null");
}
return getEtendoSWSToken(context, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GPT Review for AD_COLUMN.xml
Review
1, because the change is minimal and straightforward, involving only a single line modification in an XML file.
Code feedback
src-db/database/sourcedata/AD_COLUMN.xml
xml
Ensure that the change in the
IS_CHILD_PROPERTY_IN_PARENT
field fromN
toY
is intentional and aligns with the business logic or requirements. This change could have implications on how child properties are handled in parent entities. [important]possible issue