public WebDBLogin createdblogin(WebObjectSource webObjectSource, String dbLoginName, String schemaName, String password)
{
WebDBLogin dbLogin = null;
String dbLoginId = "";
try
{
if (dbLoginName != "" && schemaName != "")
{
dbLoginId = searchDBLoginID(webObjectSource, dbLoginName);
if (dbLoginId == "")
{
dbLogin = (WebDBLogin) webObjectSource.getNewObject(EnumDSSXMLObjectTypes.DssXmlTypeDBLogin);
dbLogin.setLogin(schemaName);
dbLogin.setPassword(password);
WebFolder folderDBL = (WebFolder) webObjectSource.getObject(webObjectSource.getFolderID(EnumDSSXMLFolderNames.DssXmlFolderNameDBLogins), EnumDSSXMLObjectTypes.DssXmlTypeFolder);
webObjectSource.save(dbLogin, dbLoginName, folderDBL);
System.out.println("DB Login \"" +dbLoginName+ "\"creatd successfully");
}
else
{
dbLogin = (WebDBLogin) webObjectSource.getObject(dbLoginId, EnumDSSXMLObjectTypes.DssXmlTypeDBLogin,true);
System.out.println("DB login: \"" + dbLoginName + "\" already exists.");
dbLogin.setLogin(schemaName);
dbLogin.setPassword(password);
webObjectSource.save(dbLogin);
System.out.println("Modified DB login: \"" + dbLoginName + "\".");
}
}
else
{
MstrObjectList.log.info("Not a valid db login");
}
}
catch (WebObjectsException e)
{
System.out.println(e.getMessage());
}
return dbLogin;
}
Thursday, April 11, 2013
Monday, April 8, 2013
MicroStrategy Web SDK Generic Methods: get object Path
public static String getPath(WebObjectSource objectSource, String objectId, int type)
{
String path = "";
WebFolder folder1 = null;
try
{
folder1 = (WebFolder) objectSource.getObject(objectId, EnumDSSXMLObjectTypes.DssXmlTypeFolder);
folder1.populate();
String p = "";
SimpleList list = folder1.getAncestors();
for (int j = 0; j < folder1.getAncestors().size(); j++)
{
p = ((WebObjectInfo) list.item(j)).getName();
if (!p.equals(MstrObjectList.projectName))
{
path = path + "/" + p;
}
}
}
catch (Exception ex)
{
Logger.log.error("Error while fetching the path of folder: " + ex.getMessage());
}
return path;
}
{
String path = "";
WebFolder folder1 = null;
try
{
folder1 = (WebFolder) objectSource.getObject(objectId, EnumDSSXMLObjectTypes.DssXmlTypeFolder);
folder1.populate();
String p = "";
SimpleList list = folder1.getAncestors();
for (int j = 0; j < folder1.getAncestors().size(); j++)
{
p = ((WebObjectInfo) list.item(j)).getName();
if (!p.equals(MstrObjectList.projectName))
{
path = path + "/" + p;
}
}
}
catch (Exception ex)
{
Logger.log.error("Error while fetching the path of folder: " + ex.getMessage());
}
return path;
}
MicroStrategy Web SDK Generic Methods: get object type
public static String getObjectType(int type)
{
String objectType = "";
if (type == 1)
{
objectType = "Filter";
}
else if (type == 2)
{
objectType = "Template";
}
else if (type == 3)
{
objectType = "Report";
}
else if (type == 4)
{
objectType = "Metric";
}
else if (type == 6)
{
objectType = "Auto Stype";
}
else if (type == 8)
{
objectType = "Folder";
}
else if (type == 9)
{
objectType = "Subscripiton Device";
}
else if (type == 10)
{
objectType = "Prompt";
}
else if (type == 12)
{
objectType = "Attribute";
}
else if (type == 13)
{
objectType = "Fact";
}
else if (type == 14)
{
objectType = "Hierarchy";
}
else if (type == 15)
{
objectType = "Table";
}
else if (type == 16)
{
objectType = "Datamart Report";
}
else if (type == 17)
{
objectType = "Fact Group";
}
else if (type == 18)
{
objectType = "Shortcut";
}
else if (type == 34)
{
objectType = "User";
}
else if (type == 41)
{
objectType = "Data Mart";
}
else if (type == 42)
{
objectType = "Function";
}
else if (type == 47)
{
objectType = "Consolidation";
}
else if (type == 56)
{
objectType = "Drill Map";
}
else if (type == 55)
{
objectType = "Document";
}
return objectType;
}
{
String objectType = "";
if (type == 1)
{
objectType = "Filter";
}
else if (type == 2)
{
objectType = "Template";
}
else if (type == 3)
{
objectType = "Report";
}
else if (type == 4)
{
objectType = "Metric";
}
else if (type == 6)
{
objectType = "Auto Stype";
}
else if (type == 8)
{
objectType = "Folder";
}
else if (type == 9)
{
objectType = "Subscripiton Device";
}
else if (type == 10)
{
objectType = "Prompt";
}
else if (type == 12)
{
objectType = "Attribute";
}
else if (type == 13)
{
objectType = "Fact";
}
else if (type == 14)
{
objectType = "Hierarchy";
}
else if (type == 15)
{
objectType = "Table";
}
else if (type == 16)
{
objectType = "Datamart Report";
}
else if (type == 17)
{
objectType = "Fact Group";
}
else if (type == 18)
{
objectType = "Shortcut";
}
else if (type == 34)
{
objectType = "User";
}
else if (type == 41)
{
objectType = "Data Mart";
}
else if (type == 42)
{
objectType = "Function";
}
else if (type == 47)
{
objectType = "Consolidation";
}
else if (type == 56)
{
objectType = "Drill Map";
}
else if (type == 55)
{
objectType = "Document";
}
return objectType;
}
MicroStrategy Command manager scripts
Create User:
CREATE USER "xxx" PASSWORD "" FULLNAME "xxxx" PASSWORDEXP NEVER;
Create Group:
CREATE USER GROUP "xxx_group" IN GROUP "MicroStrategy Groups";
ALTER USER GROUP "xxx_group" GROUP "";
Add User In group:
ADD USER "xxx" TO GROUP "xxx_group";
Create Security Filter:
CREATE SECURITY FILTER "xxxx" IN PROJECT "project" EXPRESSION "category@ID=27";
CREATE USER "xxx" PASSWORD "" FULLNAME "xxxx" PASSWORDEXP NEVER;
Create Group:
CREATE USER GROUP "xxx_group" IN GROUP "MicroStrategy Groups";
ALTER USER GROUP "xxx_group" GROUP "
Add User In group:
ADD USER "xxx" TO GROUP "xxx_group";
Create Security Filter:
CREATE SECURITY FILTER "xxxx" IN PROJECT "project" EXPRESSION "category@ID=27";
MicroStragey Web Sdk create User Group
UserGroupBean userGroup = WebBeanFactory.getInstance().newUserGroupBean();
userGroup.setSessionInfo(MstrSessionManagement.serverSession);
userGroup.InitAsNew();
userGroup.getUserEntityObject().setFullName(groupName);
userGroup.save();
Logger.log.info("User Group \"" + groupName + "\" has been created successfully.");
userGroupID = userGroup.getObjectID();
userGroup.setSessionInfo(MstrSessionManagement.serverSession);
userGroup.InitAsNew();
userGroup.getUserEntityObject().setFullName(groupName);
userGroup.save();
Logger.log.info("User Group \"" + groupName + "\" has been created successfully.");
userGroupID = userGroup.getObjectID();
MicroStrategy WebSdk Create User
UserBean user = WebBeanFactory.getInstance().newUserBean();
user.setSessionInfo(MstrSessionManagement.serverSession);
user.InitAsNew();
WebUser ua = (WebUser) user.getUserEntityObject();
WebStandardLoginInfo loginInfo = ua.getStandardLoginInfo();
//Set basic user information
ua.setLoginName(loginName);
ua.setFullName(fullName);
user.getObjectInfo().setDescription(description);
loginInfo.setPassword(password);
//Set other properties
// Calendar cal = Calendar.getInstance();
//cal.set(2013, 11, 21);
//Date d = cal.getTime();
loginInfo.setPasswordExpiresAutomatically(false);
//loginInfo.setPasswordExpirationDate(d); //Password expires on November 21, 2013
//loginInfo.setPasswordExpirationFrequency(90); //90 days to expire
//loginInfo.setPasswordExpiresAutomatically(true); //If set to false, password never expires
//loginInfo.setStandardAuthAllowed(true); //The user can log in using standard auth
user.save();
userID = user.getObjectID();
MstrObjectList.log.info("User: \"" + loginName + "\" has been created successfully.");
user.setSessionInfo(MstrSessionManagement.serverSession);
user.InitAsNew();
WebUser ua = (WebUser) user.getUserEntityObject();
WebStandardLoginInfo loginInfo = ua.getStandardLoginInfo();
//Set basic user information
ua.setLoginName(loginName);
ua.setFullName(fullName);
user.getObjectInfo().setDescription(description);
loginInfo.setPassword(password);
//Set other properties
// Calendar cal = Calendar.getInstance();
//cal.set(2013, 11, 21);
//Date d = cal.getTime();
loginInfo.setPasswordExpiresAutomatically(false);
//loginInfo.setPasswordExpirationDate(d); //Password expires on November 21, 2013
//loginInfo.setPasswordExpirationFrequency(90); //90 days to expire
//loginInfo.setPasswordExpiresAutomatically(true); //If set to false, password never expires
//loginInfo.setStandardAuthAllowed(true); //The user can log in using standard auth
user.save();
userID = user.getObjectID();
MstrObjectList.log.info("User: \"" + loginName + "\" has been created successfully.");
Subscribe to:
Posts (Atom)