use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.
the class ListType method getOrCreateEntry.
@Transaction
public ListTypeEntry getOrCreateEntry(Date forDate, JsonObject metadata) {
if (!this.isValid()) {
throw new InvalidMasterListException();
}
ListTypeEntryQuery query = new ListTypeEntryQuery(new QueryFactory());
query.WHERE(query.getListType().EQ(this));
query.AND(query.getForDate().EQ(forDate));
try (OIterator<? extends ListTypeEntry> it = query.getIterator()) {
if (it.hasNext()) {
return it.next();
}
}
return ListTypeEntry.create(this, forDate, metadata);
}
use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.
the class ListType method delete.
@Override
@Transaction
public void delete() {
// Validate there are no public versions
ListTypeVersionQuery query = new ListTypeVersionQuery(new QueryFactory());
query.WHERE(query.getListType().EQ(this));
query.AND(query.getWorking().EQ(false));
query.AND(OR.get(query.getListVisibility().EQ(ListType.PUBLIC), query.getGeospatialVisibility().EQ(ListType.PUBLIC)));
long count = query.getCount();
if (count > 0) {
throw new CannotDeletePublicListTypeException();
}
// Delete all jobs
this.getJobs().forEach(job -> {
job.delete();
});
this.getEntries().forEach(entry -> {
entry.delete();
});
super.delete();
final File directory = this.getShapefileDirectory();
if (directory.exists()) {
try {
FileUtils.deleteDirectory(directory);
} catch (IOException e) {
throw new ProgrammingErrorException(e);
}
}
}
use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.
the class ListTypeAttributeGroup method deleteAll.
public static void deleteAll(ListTypeVersion version) {
ListTypeAttributeGroupQuery query = new ListTypeAttributeGroupQuery(new QueryFactory());
query.WHERE(query.getVersion().EQ(version));
OIterator<? extends ListTypeAttributeGroup> it = query.getIterator();
try {
List<? extends ListTypeAttributeGroup> groups = it.getAll();
for (ListTypeAttributeGroup group : groups) {
group.delete();
}
} finally {
it.close();
}
}
use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.
the class ListTypeEntry method getVersions.
public List<ListTypeVersion> getVersions() {
ListTypeVersionQuery query = new ListTypeVersionQuery(new QueryFactory());
query.WHERE(query.getEntry().EQ(this));
// query.AND(query.getWorking().EQ(false));
query.ORDER_BY_DESC(query.getVersionNumber());
try (OIterator<? extends ListTypeVersion> it = query.getIterator()) {
return new LinkedList<ListTypeVersion>(it.getAll());
}
}
use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.
the class ListTypeVersion method generateShapefile.
// public List<ExecutableJob> getJobs()
// {
// LinkedList<ExecutableJob> jobs = new LinkedList<ExecutableJob>();
//
// PublishShapefileJobQuery psjq = new PublishShapefileJobQuery(new
// QueryFactory());
// psjq.WHERE(psjq.getVersion().EQ(this));
//
// try (OIterator<? extends PublishShapefileJob> it = psjq.getIterator())
// {
// jobs.addAll(it.getAll());
// }
//
// PublishListTypeVersionJobQuery pmlvj = new
// PublishListTypeVersionJobQuery(new QueryFactory());
// pmlvj.WHERE(pmlvj.getListTypeVersion().EQ(this));
//
// try (OIterator<? extends PublishListTypeVersionJob> it =
// pmlvj.getIterator())
// {
// jobs.addAll(it.getAll());
// }
//
// return jobs;
// }
public File generateShapefile() {
String filename = this.getOid() + ".zip";
final ListType list = this.getListType();
final File directory = list.getShapefileDirectory();
directory.mkdirs();
final File file = new File(directory, filename);
MdBusinessDAOIF mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid());
List<? extends MdAttributeConcreteDAOIF> mdAttributes = mdBusiness.definesAttributesOrdered().stream().filter(mdAttribute -> this.isValid(mdAttribute)).collect(Collectors.toList());
try {
ListTypeShapefileExporter exporter = new ListTypeShapefileExporter(this, mdBusiness, mdAttributes, null);
try (final InputStream istream = exporter.export()) {
try (final FileOutputStream fos = new FileOutputStream(file)) {
IOUtils.copy(istream, fos);
}
}
} catch (IOException e) {
throw new ProgrammingErrorException(e);
}
return file;
}
Aggregations