Author Topic: Transfer projects via the automation interface in a fully automated way  (Read 656 times)

Heidi V.

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
I am trying to use the method

Code: [Select]
org.sparx.Project.ProjectTransfer(String, String, String)
in a Java project.

It is described as:

Quote
Notes: Transfers the project from a source .eap file or DBMS to a target .eap file, .eapx file or .feap file.

Parameters:

    SourceFilePath: String - the path of the source file to transfer
    TargetFilePath: String - the path of the target file, including the file type extension; Enterprise Architect creates a new Base project in this location (using the TargetFilePath as its name) and then transfers the content of the source project into that file
    LogFilePath: String - the path of the log file where the status of the transfer process is updated

In automation, the target file must not previously exist. Enterprise Architect creates a new, empty Base.* file using the specified target name and extension, and transfers the source project into it.

So something like the following:

Code: [Select]
// ...
Repository repository = new Repository();
repository.OpenFile(sourceProjectFile.getAbsolutePath());
repository.GetProjectInterface().ProjectTransfer(sourceProjectFile.getAbsolutePath(), targetProjectFile.getAbsolutePath(), new File(FileUtils.getTempDirectoryPath(), "projecttransferlog.txt").getAbsolutePath());
repository.CloseFile();
repository.Exit();
// ...

When running my application, a new file is created, but a window appears, titled "Project Transfer", the same one as described on https://sparxsystems.com/enterprise_architect_user_guide/16.0/model_exchange/performadatatransfer.html.

In order to continue the application, I have to click, meaning I cannot actually perform a fully automated project transfer.

Is it not possible at all to transfer (a rather large bunch of existing) projects in a fully automated way? That would especially be useful when migrating from EA 15 to EA 16, and thus migrating from .eap(x) to .qea files (once the feature request mentioned in https://sparxsystems.com/forums/smf/index.php/topic,47405.msg276388.html is implemented).

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 12349
  • Karma: +490/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Transfer projects via the automation interface in a fully automated way
« Reply #1 on: January 19, 2023, 01:20:42 am »
Yes, it's possible but the target file should not exist yet.

That's different from the GUI, where the target file should exist.

Geert

Heidi V.

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Transfer projects via the automation interface in a fully automated way
« Reply #2 on: January 19, 2023, 01:26:52 am »
I did make sure that the target file did not exist, before running the application. I can see that right after invoking org.sparx.Project.ProjectTransfer(String, String, String), the target file is created, and then the GUI, the "Project Transfer" window, appears.

Some more information: I tested using EA 16.0.1605.

I noticed that the release notes of EA 16.1.1623, released yesterday (17.01.2023), state:

Quote
ProjectInterface.ProjectTransfer now accepts .qea and .qeax as Source and Target extensions

A way to bulk migrate a set of EAP(X) projects to QEA(X) projects would be really useful.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 12349
  • Karma: +490/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Transfer projects via the automation interface in a fully automated way
« Reply #3 on: January 19, 2023, 01:58:09 am »
I'll have a look with the newest version, but I use this function on older versions since years.
It always worked perfectly fine without any dialogs showing.
In our code, we first delete the log file as well.

It might be a bug though.

Have you tried by passing literal strings to the function?

Geert

Heidi V.

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Transfer projects via the automation interface in a fully automated way
« Reply #4 on: January 19, 2023, 07:10:34 pm »
I now tried with literal strings, that didn't change anything, the dialog is still shown. I tried with Java, and I tried with JavaScript, same result.

Java:
Code: [Select]
package dk.gov.data.modellingtools.projectmanagement;

import org.sparx.Repository;

public class Main {

  public static void main(String[] args) {
    System.out.println("Start");
    Repository repository = new Repository();
    boolean projectTransferResult = repository.GetProjectInterface().ProjectTransfer("C:\\Users\\B004114\\Documents\\workingdir\\EA2\\EABase.eap",
        "C:\\Users\\B004114\\Documents\\workingdir\\EA2\\EABase.feap",
        "C:\\Users\\B004114\\Documents\\workingdir\\EA2\\log.txt");
    System.out.println("Result: " + projectTransferResult);
    repository.Exit();
    repository = null;
    System.out.println("Stop");
  }

}

JavaScript:
Code: [Select]
function main() {
Repository.EnsureOutputVisible("Script");
Session.Output("Start");
var project as EA.Project;
project = Repository.GetProjectInterface();
project.ProjectTransfer("C:\\Users\\B004114\\Documents\\workingdir\\EA2\\EABase.eap",
"C:\\Users\\B004114\\Documents\\workingdir\\EA2\\EABase.feap",
"C:\\Users\\B004114\\Documents\\workingdir\\EA2\\log.txt");
Session.Output("Stop");
}

main();

The project is also not transferred, even when I click on the Transfer button when it shows up. It's just an empty file, there's no model in it.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 12349
  • Karma: +490/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Transfer projects via the automation interface in a fully automated way
« Reply #5 on: January 19, 2023, 07:41:23 pm »
This is the script (VBScript) I use.
The connectionstring is copied from an encrypted EA shortcut file.
This fully automatically transfers our projects from SQL Server to .eap files.

Code: [Select]
const logPath =    "G:\Projects\80 Enterprise Architect\Output\Backups\LogFile\"
const backupPath = "G:\Projects\80 Enterprise Architect\Output\Backups\"

'---------------------------CONFIGURATION---------------------------------------
const EADEVconnectionString = "DBType=1;ConnectEx=6' lgOUNphsdL9V'v^;KJl*`XYta*2{S3%Qoj=E*7%u&LT# R7w(E9p%?Yajszqn#87d3Q$+NX3Gn<SdG!W|^)AJ[XQ!Z{mY""muLhLVnIW'Q6t,3Sq4'(fA6-GI|GK1DY8[iwAvtW2I3XZ:ydO`97W70[m2ieu=l@+*7{=HsGsqdw=^aFD)Wy-^3{;cfgVxov2az:7mC0T5^<IR""=:<<<!$Ke10\fzF^*:iJ-R,U?ct^i; V9_fpj5,maX64Xb\_]1TfQIX{n()$jv\2@`g'ndbnK8%FCWW)#vEEj`"
'---------------------------CONFIGURATION---------------------------------------


sub main
dim repository
set repository = CreateObject("EA.Repository")
'backup DEV
backupRepository repository, EADEVconnectionString, backupPath, logPath, "EA DEV"
'close EA
repository.Exit
'tell user we have finished
msgbox "Finished backups"
end sub


function backupRepository (repository, sourceModel, backupPath, logPath, modelName)
Dim currentDate
currentdate = (Year(Date) & (Right(String(2,"0") & Month(Date), 2)) & (Right(String(2,"0") & Day(Date), 2)))  'yyyymmdd'

dim projectInterface
 
dim logFilePath
logFilePath = logPath & CurrentDate & " " & modelName & " (back-up).log"

'delete logfile if exists
deleteFile logFilePath

dim targetFilePath
targetFilePath = backupPath & CurrentDate & " " & modelName & " (back-up).eap"

'delete targetfile if exists
deleteFile targetFilePath

'get project interface
set projectInterface = repository.GetProjectInterface()
'execute project transfer
projectInterface.ProjectTransfer sourceModel, targetFilePath, logFilePath

end function

function deleteFile (filePath)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.FileExists(filePath) then
fso.DeleteFile filePath
end if
end function

main

I'll try to adapt this to check if it also works to transfer from .eap to .qea

Geert

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 12349
  • Karma: +490/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Transfer projects via the automation interface in a fully automated way
« Reply #6 on: January 19, 2023, 07:57:13 pm »
I just tested with a .eap file and the latest version (v16.1.1623 64 bit); and I can confirm what you are seeing. It doesn't work.

I get the dialog, but even when pressing the Transfer button it doesn't work.

Just to be sure, I checked; but I can still transfer from DB to .qea automatically

Looks like a bug to me. You better contact support@sparxsystems.com

Geert

Heidi V.

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Transfer projects via the automation interface in a fully automated way
« Reply #7 on: January 20, 2023, 03:25:22 am »
@Geert: thanks for taking the time to test this!

I filed a bug report at Sparx.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 7839
  • Karma: +107/-20
    • View Profile
Re: Transfer projects via the automation interface in a fully automated way
« Reply #8 on: January 23, 2023, 02:15:53 pm »
I just tested with a .eap file and the latest version (v16.1.1623 64 bit); and I can confirm what you are seeing. It doesn't work.

I get the dialog, but even when pressing the Transfer button it doesn't work.

Just to be sure, I checked; but I can still transfer from DB to .qea automatically

Looks like a bug to me. You better contact support@sparxsystems.com

Geert
That's because the 64 bit version of EA can't handle .eap files. If that's what you're using you're going to need to update your code to use .qea.
Eve

support@sparxsystems.com