use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class GuidedDecisionTreeEditorServiceImpl method create.
@Override
public Path create(final Path context, final String fileName, final GuidedDecisionTree content, final String comment) {
try {
final Package pkg = moduleService.resolvePackage(context);
final String packageName = (pkg == null ? null : pkg.getPackageName());
content.setPackageName(packageName);
final org.uberfire.java.nio.file.Path nioPath = Paths.convert(context).resolve(fileName);
final Path newPath = Paths.convert(nioPath);
if (ioService.exists(nioPath)) {
throw new FileAlreadyExistsException(nioPath.toString());
}
ioService.write(nioPath, GuidedDecisionTreeDRLPersistence.getInstance().marshal(content), commentedOptionFactory.makeCommentedOption(comment));
return newPath;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class GuidedRuleEditorServiceImpl method save.
@Override
public Path save(final Path resource, final RuleModel model, final Metadata metadata, final String comment) {
try {
final Package pkg = moduleService.resolvePackage(resource);
final String packageName = (pkg == null ? null : pkg.getPackageName());
model.setPackageName(packageName);
Metadata currentMetadata = metadataService.getMetadata(resource);
ioService.write(Paths.convert(resource), toSourceUnexpanded(resource, model), metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment));
fireMetadataSocialEvents(resource, currentMetadata, metadata);
return resource;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class GuidedRuleEditorServiceImpl method create.
@Override
public Path create(final Path context, final String fileName, final RuleModel model, final String comment) {
try {
final Package pkg = moduleService.resolvePackage(context);
final String packageName = (pkg == null ? null : pkg.getPackageName());
model.setPackageName(packageName);
// Temporal fix for https://bugzilla.redhat.com/show_bug.cgi?id=998922
model.getImports().addImport(new Import("java.lang.Number"));
final org.uberfire.java.nio.file.Path nioPath = Paths.convert(context).resolve(fileName);
final Path newPath = Paths.convert(nioPath);
if (ioService.exists(nioPath)) {
throw new FileAlreadyExistsException(nioPath.toString());
}
ioService.write(nioPath, toSource(newPath, model), commentedOptionFactory.makeCommentedOption(comment));
return newPath;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class GuidedScoreCardEditorServiceImpl method create.
@Override
public Path create(final Path context, final String fileName, final ScoreCardModel content, final String comment) {
try {
final Package pkg = moduleService.resolvePackage(context);
final String packageName = (pkg == null ? null : pkg.getPackageName());
content.setPackageName(packageName);
final org.uberfire.java.nio.file.Path nioPath = Paths.convert(context).resolve(fileName);
final Path newPath = Paths.convert(nioPath);
if (ioService.exists(nioPath)) {
throw new FileAlreadyExistsException(nioPath.toString());
}
ioService.write(nioPath, GuidedScoreCardXMLPersistence.getInstance().marshal(content), commentedOptionFactory.makeCommentedOption(comment));
return newPath;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class GuidedScoreCardEditorServiceImpl method save.
@Override
public Path save(final Path resource, final ScoreCardModel model, final Metadata metadata, final String comment) {
try {
final Package pkg = moduleService.resolvePackage(resource);
final String packageName = (pkg == null ? null : pkg.getPackageName());
model.setPackageName(packageName);
Metadata currentMetadata = metadataService.getMetadata(resource);
ioService.write(Paths.convert(resource), GuidedScoreCardXMLPersistence.getInstance().marshal(model), metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment));
fireMetadataSocialEvents(resource, currentMetadata, metadata);
return resource;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
Aggregations