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

Upgraded Features #7

Merged
merged 19 commits into from
Dec 30, 2024
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/master'
# Conflicts:
#	midscribe-core/src/main/java/com/evolveum/midscribe/generator/TemplateUtils.java
#	midscribe-core/src/main/java/com/evolveum/midscribe/generator/export/HtmlExporter.java
#	midscribe-core/src/main/java/com/evolveum/midscribe/generator/export/PdfExporter.java
#	midscribe-core/src/main/resources/midscribe.properties
#	midscribe-core/src/test/java/com/evolveum/midscribe/TemplateUtilsTest.java
#	pom.xml
matejglombik committed Dec 4, 2024
commit 2e7d1a14c742767bddc027427dd34746d8c3c09f
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
import org.w3c.dom.Element;
import org.w3c.dom.Text;

/*import javax.xml.bind.JAXBElement;*/
import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
import java.util.*;

@@ -129,14 +129,6 @@ public static List<Attribute> getConnectorConfiguration(ResourceType resource) {
}

List<Attribute> attributes = new ArrayList<>();
String type = "";
/*List<Element> list = new ArrayList<>();
XmlSchemaType xmlSchemaType = resource.getSchema();
if (xmlSchemaType != null){
SchemaDefinitionType schemaDefinitionType = xmlSchemaType.getDefinition();
list = schemaDefinitionType.getAny();
type = "unknown";
}*/

for (Object obj : config.getAny()) {
if (!(obj instanceof Element)) {
@@ -151,22 +143,14 @@ public static List<Attribute> getConnectorConfiguration(ResourceType resource) {
value = "XML"; // todo improve, passwords, etc
}

/*if (xmlSchemaType != null){
for (Element typeElement : list){
Attr attr = typeElement.getAttributeNode(element.getLocalName());
type = attr.getSchemaTypeInfo().getTypeName();
}
}*/

attributes.add(new Attribute(element.getLocalName(), null, value,type));
attributes.add(new Attribute(element.getLocalName(), null, value));
}

return attributes;
}

private static <T> T getConnectorConfiguration(ResourceType resource, Class<T> type) {
ConnectorConfigurationType config = resource.getConnectorConfiguration();

List configs = config.getAny();
if (configs.isEmpty()) {
return null;
@@ -451,6 +435,5 @@ protected void appendDetail(StringBuffer buffer, String fieldName, Object value)
(Class) value.getClass(), false, false, true).toString();
buffer.append("\n");
}

}
}
Original file line number Diff line number Diff line change
@@ -50,8 +50,7 @@ public void export(File adocFile, File output) throws IOException {
.headerFooter(true)
.build();

Asciidoctor doctor = createAsciidoctor();

try (Asciidoctor doctor = createAsciidoctor()) {
doctor.convertFile(adocFile, options);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package com.evolveum.midscribe.generator;
import org.jruby.util.log.Logger;
import org.jruby.util.log.LoggerFactory;
package com.evolveum.midscribe.generator.export;

import org.asciidoctor.Asciidoctor;
import org.asciidoctor.Options;
import org.asciidoctor.SafeMode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;

public class PdfExporter extends ExporterBase {
/**
* Created by Viliam Repan (lazyman).
*/
public class PdfExporter extends ExporterBase {

private static final Logger LOG = LoggerFactory.getLogger(PdfExporter.class);

@@ -15,38 +22,20 @@ public String getDefaultExtension() {
}

@Override
public void export(File adocFile, File outputPdf) throws IOException {
File tempHtmlFile = File.createTempFile("temp", ".html");

try {
HtmlExporter htmlExporter = new HtmlExporter();
htmlExporter.export(adocFile, tempHtmlFile);

String princeCommand = "prince " + tempHtmlFile.getAbsolutePath() + " -o " + outputPdf.getAbsolutePath();
Process process = Runtime.getRuntime().exec(princeCommand);
int exitCode = process.waitFor();
if (exitCode != 0) {
LOG.error("PrinceXML conversion failed with exit code " + exitCode);
}
} catch (IOException | InterruptedException e) {
LOG.error("Error converting AsciiDoc to PDF", e);
throw new IOException("Conversion failed", e);
} finally {
// Delete temporary HTML file
tempHtmlFile.delete();
public void export(File adocFile, File output) throws IOException {
File dir = output.getAbsoluteFile().getParentFile();
File file = new File(output.getName());

Options options = Options.builder()
.safe(SafeMode.UNSAFE)
.inPlace(true)
.toDir(dir)
.toFile(file)
.backend("pdf")
.build();

try (Asciidoctor doctor = createAsciidoctor()) {
doctor.convertFile(adocFile, options);
}
}
}













Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package com.evolveum.midscribe;

/*import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType;*/
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CapabilityCollectionType;
import com.evolveum.midscribe.generator.*;
import com.evolveum.midscribe.generator.Generator;
import com.evolveum.midscribe.generator.GeneratorOptions;
import com.evolveum.midscribe.generator.GeneratorProperties;
import com.evolveum.midscribe.generator.GeneratorUtils;
import com.evolveum.midscribe.generator.store.GetOptions;
import com.evolveum.midscribe.generator.store.InMemoryObjectStoreFactory;
import com.evolveum.midscribe.generator.store.ObjectStore;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;

12 changes: 2 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -39,10 +39,6 @@
</modules>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>21</java.version>

<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>

@@ -51,12 +47,8 @@
<asciidoctorj.version>3.0.0</asciidoctorj.version>
<asciidoctorj.pdf.version>2.3.19</asciidoctorj.pdf.version>
<asciidoctorj.tabbed.code.version>0.3</asciidoctorj.tabbed.code.version>
<commons.io.version>2.11.0</commons.io.version>
<velocity.version>2.3</velocity.version>
<midpoint.version>4.8</midpoint.version>
<testng.version>7.4.0</testng.version>
<xml.apis.version>2.0.2</xml.apis.version>
<jruby.version>9.2.19.0</jruby.version>
<velocity.version>2.4</velocity.version>
<jruby.version>9.4.8.0</jruby.version>
</properties>

<dependencyManagement>
You are viewing a condensed version of this merge commit. You can view the full changes here.