02-13-2012 09:13 AM
02-13-2012 12:20 PM
02-14-2012 05:02 AM
02-14-2012 05:41 AM
02-14-2012 10:08 AM
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.chemistry.opencmis.client.api.ItemIterable;
import org.apache.chemistry.opencmis.client.api.QueryResult;
import org.apache.chemistry.opencmis.client.api.Repository;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.client.api.SessionFactory;
import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
import org.apache.chemistry.opencmis.commons.SessionParameter;
import org.apache.chemistry.opencmis.commons.enums.BindingType;
public class CmisTest {
private String serviceUrl = "http://localhost:8080/alfresco/cmisatom";
private Session session = null;
private String user = "admin";
private String password = "admin";
/**
* @param args
*/
public static void main(String[] args) {
CmisTest ct = new CmisTest();
ct.doTest();
}
public void doTest() {
String query = "select * from cmis:document where IN_FOLDER('workspace://SpacesStore/6fc1a5f9-31ac-4457-9620-eef4b82cabdd') AND cmis:lastModificationDate < TIMESTAMP '2012-10-20T00:00:00.000Z'";
ItemIterable<QueryResult> q = getSession().query(query, false);
for (QueryResult qr : q) {
System.out.println(
qr.getPropertyByQueryName("cmis:objectTypeId")
.getFirstValue()
+ " , "
+ qr.getPropertyByQueryName("cmis:name").getFirstValue()
);
}
}
public Session getSession() {
if (session == null) {
// default factory implementation
SessionFactory factory = SessionFactoryImpl.newInstance();
Map<String, String> parameter = new HashMap<String, String>();
// user credentials
parameter.put(SessionParameter.USER, getUser());
parameter.put(SessionParameter.PASSWORD, getPassword());
// connection settings
parameter.put(SessionParameter.ATOMPUB_URL, getServiceUrl());
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
// Set the alfresco object factory
// Used when using the CMIS extension for Alfresco for working with aspects
//parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
List<Repository> repositories = factory.getRepositories(parameter);
this.session = repositories.get(0).createSession();
}
return this.session;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public String getServiceUrl() {
return serviceUrl;
}
}
02-15-2012 06:58 AM
02-15-2012 08:02 AM
02-15-2012 01:09 PM
>>> for doc in folder.getChildren():
… doc.properties['cmis:lastModificationDate']
…
datetime.datetime(2011, 10, 3, 14, 15, 2, 845000, tzinfo=<FixedOffset u'-05:00'>)
datetime.datetime(2011, 10, 3, 14, 10, 26, 199000, tzinfo=<FixedOffset u'-05:00'>)
datetime.datetime(2011, 10, 3, 14, 10, 26, 234000, tzinfo=<FixedOffset u'-05:00'>)
If I do a query for October 3, less than 23:59:59, I get an empty set.>>> query = "select * from cmis:document where IN_FOLDER('workspace://SpacesStore/2735602b-3287-4420-8d34-0eedf7b2cda9') AND cmis:lastModificationDate < TIMESTAMP '2011-10-03T23:59:59.000-05:00'"
>>> rs = repo.query(query)
>>> len(rs)
0
>>> query = "select * from cmis:document where IN_FOLDER('workspace://SpacesStore/2735602b-3287-4420-8d34-0eedf7b2cda9') AND cmis:lastModificationDate <= TIMESTAMP '2011-10-03T03:59:59.000-05:00'"
>>> rs = repo.query(query)
>>> len(rs)
3
>>> query = "select * from cmis:document where IN_FOLDER('workspace://SpacesStore/2735602b-3287-4420-8d34-0eedf7b2cda9') AND cmis:lastModificationDate < TIMESTAMP '2011-10-04T03:59:59.000-05:00'"
>>> rs = repo.query(query)
>>> len(rs)
3
02-15-2012 01:12 PM
02-16-2012 04:19 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.