Skip to content

Commit

Permalink
Issue #264: Added deleted client gradle task process.
Browse files Browse the repository at this point in the history
EPL-1146: Also fixed issues with source format modules with dependencies to JAR format modules unable to find their tables.
  • Loading branch information
Matias Bernal committed Dec 27, 2023
1 parent 170f3dd commit 7897e05
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src-db/database/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -242,5 +242,12 @@ export.database.structure: Exports the database structure in the xml's files.
</transaction>
</sql>
</target>

<target name="delete.client">
<taskdef name="deleteClient" classname="org.openbravo.service.system.SystemDeleteClientTask">
<classpath refid="project.class.path" />
</taskdef>
<deleteClient clientId="${clientId}" userid="0" propertiesFile="${base.config}/Openbravo.properties" />
</target>
</project>

34 changes: 34 additions & 0 deletions src/org/openbravo/service/system/SystemDeleteClientTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.openbravo.service.system;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.openbravo.base.exception.OBException;
import org.openbravo.dal.core.DalInitializingTask;
import org.openbravo.dal.service.OBDal;
import org.openbravo.model.ad.system.Client;

/**
* Performs delete client process.
*
* @author szapata
*/
public class SystemDeleteClientTask extends DalInitializingTask {
private static final Logger log = LogManager.getLogger("SystemDeleteClientTask");
protected String clientId;

public void setClientId(String clientId) {
this.clientId = clientId;
}

@Override
protected void doExecute() {
// Validate module
Client client = OBDal.getInstance().get(Client.class, clientId);
if (client == null) {
throw new OBException("Client not found");
}
log.info("Deleting Client: {}", client.getName());

SystemService.getInstance().deleteClient(client);
}
}
3 changes: 3 additions & 0 deletions src/org/openbravo/service/system/SystemService.java
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ private void enableConstraints(Platform platform) {
addDirectory(dirs, obDir, "/src-db/database/model/");
addModuleDirectories(dirs, obDir, "/modules");
addModuleDirectories(dirs, obDir, "/modules_core");
addModuleDirectories(dirs, obDir, "/build/etendo/modules");
File[] fileArray = new File[dirs.size()];
for (int i = 0; i < dirs.size(); i++) {
fileArray[i] = dirs.get(i);
Expand All @@ -467,6 +468,8 @@ private void enableConstraints(Platform platform) {
platform.enableAllTriggers(con, xmlModel, false);
log4j.info(" Enabling foreign keys");
platform.enableAllFK(con, xmlModel, false);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (con != null) {
platform.returnConnection(con);
Expand Down

0 comments on commit 7897e05

Please sign in to comment.