Skip to content
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

Fix for DHFPROD-1773, DHFPROD-1746 #1820

Merged
merged 3 commits into from
Jan 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.marklogic.appdeployer.command.CommandContext;
import com.marklogic.appdeployer.command.es.GenerateModelArtifactsCommand;
import com.marklogic.client.DatabaseClient;
import com.marklogic.client.eval.EvalResultIterator;
import com.marklogic.client.ext.es.CodeGenerationRequest;
import com.marklogic.client.ext.es.EntityServicesManager;
import com.marklogic.client.ext.es.GeneratedCode;
Expand Down Expand Up @@ -77,7 +78,14 @@ public void execute(CommandContext context) {
File esModel;
try {
//Write the ES model to a temp file
esModel = File.createTempFile("es-", f.getName());
String tempDir = System.getProperty("java.io.tmpdir");
String fileName = f.getName();
esModel = new File(tempDir, fileName);
String modelString = generateModel(f);
if(modelString == null) {
logger.warn(f.getName() + " is not deployed to the database");
continue;
}
FileUtils.writeStringToFile(esModel, generateModel(f));
} catch (IOException e) {
throw new RuntimeException("Unable to generate ES model");
Expand Down Expand Up @@ -109,7 +117,11 @@ private String generateModel(File f) {
String xquery = "import module namespace hent = \"http://marklogic.com/data-hub/hub-entities\"\n" +
"at \"/data-hub/4/impl/hub-entities.xqy\";\n" +
String.format("hent:get-model(\"%s\")", extactEntityNameFromFilename(f.getName()).get());
return hubConfig.newStagingClient().newServerEval().xquery(xquery).eval().next().getString();
EvalResultIterator resp = hubConfig.newStagingClient().newServerEval().xquery(xquery).eval();
if (resp.hasNext()) {
return resp.next().getString();
}
return null ;
}

public String getEntityNames() {
Expand Down