Pages

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;
    }

No comments: