| Back | Main view
IMiS/Storage Connector JAVA - Read entities
Product: | IMiS/Storage Connector JAVA |
Release: | 10.1.2010 |
Date: | 07/04/2021 |
Case:
IMiS/Storage Connector Java - Read entities
Description:
This example demonstrates operations which reads entities with parameters on the IMiS/ARChive Server.
Below is a description of operations for the reading entities.
1. Read root entities
Operation reads the root entities and prints entities classification code, the collection is ordered by classification code, on the IMiS/ARChive Server.
JAVA
IArchive archive = IMIS_ARCHIVE;
// Create sort keys collection
List<EntitySortKey> sortKeys = new ArrayList<EntitySortKey>();
sortKeys.add(new EntitySortKey(archive.getSystemPropertyName(SystemProperty.CLASSIFICATION_CODE), EntitySortKeyDirection.ASCENDING));
// Read root classes and print classification code
IEntityCollection<IEntityStub> entities = null;
try {
entities = archive.getRootClasses(sortKeys, null);
for (IEntityStub entityStub : entities)
System.out.println(entityStub.getClassificationCode());
}
catch (LoginException e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
catch (StorageConnectorException e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
catch (IOException e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
finally {
// Close entities collection
if (null != entities) {
if (entities instanceof IAutoCloseable) {
try {
((IAutoCloseable)entities).close();
}
catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
}
}
}
Result
C=1
C=14
C=15
C=16
C=18
C=20
C=21
C=22
C=23
C=24
C=25
C=28
C=3
C=30
C=5
C=99
2. Read sub-entities
Operation reads the child entities of entity with classification code "C=1" and prints entities classification code, the collection is ordered by classification code, on the IMiS/ARChive Server.
JAVA
IArchive archive = IMIS_ARCHIVE;
// Create sort keys collection
List<EntitySortKey> sortKeys = new ArrayList<EntitySortKey>();
sortKeys.add(new EntitySortKey(archive.getSystemPropertyName(SystemProperty.CLASSIFICATION_CODE), EntitySortKeyDirection.ASCENDING));
// Read C=1 sub-entities and print classification code
IEntityCollection<IEntityStub> entities = null;
try {
entities = archive.getSubEntities(EntityIdKind.CLASSIFICATION_CODE, "C=1", null, sortKeys, null);
for (IEntityStub entityStub : entities)
System.out.println(entityStub.getClassificationCode());
}
catch (LoginException e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
catch (StorageConnectorException e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
catch (IOException e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
finally {
// Close entities collection
if (null != entities) {
if (entities instanceof IAutoCloseable) {
try {
((IAutoCloseable)entities).close();
}
catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
}
}
}
Result
C=1^D=000012
C=1^D=000120
C=1^D=000121
C=1^D=000128
C=1^D=000129
C=1^D=000130
C=1^D=000131
C=1^D=000132
C=1^D=000133
C=1^D=000134
C=1^D=000135
C=1^D=000136
C=1^D=000137
C=1^D=000138
C=1^D=000147
C=1^D=000149
C=1^C=123
C=1^C=76
3. Read sub-entities with entity type filter
Operation reads the child entities of entity with classification code "C=1" and prints entities classification code, the collection is using documents filter and order by classification code, on the IMiS/ARChive Server.
JAVA
IArchive archive = IMIS_ARCHIVE;
// Create sort keys collection
List<EntitySortKey> sortKeys = new ArrayList<EntitySortKey>();
sortKeys.add(new EntitySortKey(archive.getSystemPropertyName(SystemProperty.CLASSIFICATION_CODE), EntitySortKeyDirection.ASCENDING));
// Read C=1 sub-entities and print classification code
IEntityCollection<IEntityStub> entities = null;
try {
entities = archive.getSubEntities(EntityIdKind.CLASSIFICATION_CODE, "C=1", EntityFilter.DOCUMENTS, sortKeys, null);
for (IEntityStub entityStub : entities)
System.out.println(entityStub.getClassificationCode());
}
catch (LoginException e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
catch (StorageConnectorException e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
catch (IOException e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
finally {
// Close entities collection
if (null != entities) {
if (entities instanceof IAutoCloseable) {
try {
((IAutoCloseable)entities).close();
}
catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
}
}
}
Result
C=1^D=000012
C=1^D=000120
C=1^D=000121
C=1^D=000128
C=1^D=000129
C=1^D=000130
C=1^D=000131
C=1^D=000132
C=1^D=000133
C=1^D=000134
C=1^D=000135
C=1^D=000136
C=1^D=000137
C=1^D=000138
C=1^D=000147
C=1^D=000149
4. Read sub-entities with entity type filter and categorization
Operation reads the child entities of entity with classification code "C=1" and prints available categories and entities classification code, with categorization by category property and "Cat" category, the collection is using documents filter and order by classification code, on the IMiS/ARChive Server.
JAVA
// Create sort keys collection
List<EntitySortKey> sortKeys = new ArrayList<EntitySortKey>();
sortKeys.add(new EntitySortKey(archive.getSystemPropertyName(SystemProperty.CLASSIFICATION_CODE), EntitySortKeyDirection.ASCENDING));
// Create categorization property names
List<String> categorizationPropertyNames = new ArrayList<String>();
categorizationPropertyNames.add(archive.getSystemPropertyName(SystemProperty.CATEGORY));
// Read C=1 sub-entities and print classification code
IEntityCollection<IEntityStub> entities = null;
try {
entities = archive.getSubEntities(EntityIdKind.CLASSIFICATION_CODE, "C=1", EntityFilter.DOCUMENTS, sortKeys, categorizationPropertyNames);
// Print collection categories
System.out.println("Categories:");
for (Map.Entry<String, Long> category : entities.getCategories().entrySet())
System.out.println(category.getKey());
// Set entities collection category
entities.setCategory("Cat");
System.out.println("Entities:");
for (IEntityStub entityStub : entities)
System.out.println(entityStub.getClassificationCode());
}
catch (LoginException e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
catch (StorageConnectorException e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
catch (IOException e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
finally {
// Close entities collection
if (null != entities) {
if (entities instanceof IAutoCloseable) {
try {
((IAutoCloseable)entities).close();
}
catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
}
}
}
Result
Categories:
Cat
cat5
test
Entities:
C=1^D=000012
C=1^D=000129
C=1^D=000149
Related Documents:
| Back | Main view