use of com.runwaysdk.system.metadata.MdAttribute in project geoprism-registry by terraframe.
the class ListTypeVersion method create.
@Transaction
public static ListTypeVersion create(ListTypeEntry listEntry, boolean working, int versionNumber, JsonObject metadata) {
ListType listType = listEntry.getListType();
ListTypeVersion version = new ListTypeVersion();
version.setEntry(listEntry);
version.setListType(listType);
version.setForDate(listEntry.getForDate());
version.setVersionNumber(versionNumber);
version.setWorking(working);
if (metadata != null) {
version.parse(metadata);
}
ServerGeoObjectType type = listType.getGeoObjectType();
if (type.getIsPrivate() && (version.getListVisibility().equals(ListType.PUBLIC) || version.getGeospatialVisibility().equals(ListType.PUBLIC))) {
throw new UnsupportedOperationException("A list version cannot be public if the Geo-Object Type is private");
}
TableMetadata tableMetadata = null;
tableMetadata = version.createTable();
version.setMdBusiness(tableMetadata.getMdBusiness());
version.apply();
if (tableMetadata != null) {
Map<MdAttribute, MdAttribute> pairs = tableMetadata.getPairs();
Set<Entry<MdAttribute, MdAttribute>> entries = pairs.entrySet();
for (Entry<MdAttribute, MdAttribute> entry : entries) {
ListTypeAttributeGroup.create(version, entry.getValue(), entry.getKey());
}
}
ListTypeVersion.assignDefaultRolePermissions(version.getMdBusiness());
return version;
}
use of com.runwaysdk.system.metadata.MdAttribute in project geoprism-registry by terraframe.
the class ListTypeVersion method createMdAttributeFromAttributeType.
public static TableMetadata createMdAttributeFromAttributeType(ListTypeVersion version, ServerGeoObjectType type, AttributeType attributeType, Collection<Locale> locales) {
TableMetadata metadata = new TableMetadata();
metadata.setMdBusiness(version.getMdBusiness());
createMdAttributeFromAttributeType(metadata, attributeType, type, locales);
Map<MdAttribute, MdAttribute> pairs = metadata.getPairs();
Set<Entry<MdAttribute, MdAttribute>> entries = pairs.entrySet();
for (Entry<MdAttribute, MdAttribute> entry : entries) {
ListTypeAttributeGroup.create(version, entry.getValue(), entry.getKey());
}
return metadata;
}
use of com.runwaysdk.system.metadata.MdAttribute 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;
}
use of com.runwaysdk.system.metadata.MdAttribute in project geoprism-registry by terraframe.
the class MasterListVersion method generateShapefile.
public File generateShapefile() {
String filename = this.getOid() + ".zip";
final MasterList list = this.getMasterlist();
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 {
MasterListShapefileExporter exporter = new MasterListShapefileExporter(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;
}
use of com.runwaysdk.system.metadata.MdAttribute in project geoprism-registry by terraframe.
the class MasterListVersion method create.
@Transaction
public static MasterListVersion create(MasterList list, Date forDate, String versionType) {
MasterListVersion version = new MasterListVersion();
version.setMasterlist(list);
version.setForDate(forDate);
version.setVersionType(versionType);
TableMetadata metadata = null;
// if (version.isNew())
// {
metadata = version.createTable();
version.setMdBusiness(metadata.getMdBusiness());
// }
version.apply();
if (metadata != null) {
Map<MdAttribute, MdAttribute> pairs = metadata.getPairs();
Set<Entry<MdAttribute, MdAttribute>> entries = pairs.entrySet();
for (Entry<MdAttribute, MdAttribute> entry : entries) {
MasterListAttributeGroup.create(version, entry.getValue(), entry.getKey());
}
}
// if (version.isNew())
// {
MasterListVersion.assignDefaultRolePermissions(version.getMdBusiness());
return version;
}
Aggregations