EntityUtil { public static <T extends Entity> T getClusterView(T entity, String clusterName) { switch(entity.getEntityType()) { case CLUSTER: return entity; case FEED: Feed feed = (Feed) entity.clone(); Cluster feedCluster = FeedHelper.getCluster(feed, clusterName); Iterator<Cluster> itr = feed.getClusters().getClusters().iterator(); while(itr.hasNext()) { Cluster cluster = itr.next(); if(!(cluster.getName().equals(clusterName) || (feedCluster.getType() == ClusterType.TARGET && cluster.getType() == ClusterType.SOURCE))) itr.remove(); } return (T) feed; case PROCESS: Process process = (Process) entity.clone(); Iterator<org.apache.ivory.entity.v0.process.Cluster> procItr = process.getClusters().getClusters().iterator(); while(procItr.hasNext()) { org.apache.ivory.entity.v0.process.Cluster cluster = procItr.next(); if(!cluster.getName().equals(clusterName)) procItr.remove(); } return (T) process; } throw new UnsupportedOperationException("Not supported for entity type " + entity.getEntityType()); }  static T getEntity(EntityType type, String entityName); static T getEntity(String type, String entityName); static TimeZone getTimeZone(String tzId); static Date getEndTime(Entity entity, String cluster); static Date parseDateUTC(String dateStr); static Date getStartTime(Entity entity, String cluster); static Date getEndTime(Process process, String cluster); static Date getStartTime(Process process, String cluster); static Date getEndTime(Feed feed, String cluster); static Date getStartTime(Feed feed, String cluster); static int getParallel(Entity entity); static void setStartDate(Entity entity, String cluster, Date startDate); static void setEndTime(Entity entity, String cluster, Date endDate); static void setParallel(Entity entity, int parallel); static int getParallel(Process process); static void setStartDate(Process process, String cluster, Date startDate); static void setParallel(Process process, int parallel); static void setEndTime(Process process, String cluster, Date endDate); static int getParallel(Feed feed); static void setStartDate(Feed feed, String cluster, Date startDate); static void setEndTime(Feed feed, String cluster, Date endDate); static void setParallel(Feed feed, int parallel); static Frequency getFrequency(Entity entity); static Frequency getFrequency(Process process); static Frequency getFrequency(Feed feed); static TimeZone getTimeZone(Entity entity); static TimeZone getTimeZone(Process process); static TimeZone getTimeZone(Feed feed); static Date getNextStartTime(Date startTime, Frequency frequency, TimeZone timezone, Date now); static int getInstanceSequence(Date startTime, Frequency frequency, TimeZone tz, Date instanceTime); static String md5(Entity entity); static boolean equals(Entity lhs, Entity rhs); static boolean equals(Entity lhs, Entity rhs, String[] filterProps); static String stringOf(Entity entity); static String getStagingPath(Entity entity); static WorkflowName getWorkflowName(Tag tag, List<String> suffixes,
			Entity entity); static WorkflowName getWorkflowName(Tag tag, Entity entity); static WorkflowName getWorkflowName(Entity entity); static String getWorkflowNameSuffix(String workflowName,
			Entity entity); static Tag getWorkflowNameTag(String workflowName, Entity entity); static T getClusterView(T entity, String clusterName); static Set<String> getClustersDefined(Entity entity); static Set<String> getClustersDefinedInColos(Entity entity); static Path getStagingPath(
			org.apache.ivory.entity.v0.cluster.Cluster cluster, Entity entity); static Retry getRetry(Entity entity); static LateProcess getLateProcess(Entity entity); static Path getLogPath(
			org.apache.ivory.entity.v0.cluster.Cluster cluster, Entity entity); static String UTCtoURIDate(String utc);  }
@Test public void testFeedView() throws Exception { Feed feed = (Feed) EntityType.FEED.getUnmarshaller().unmarshal( getClass().getResourceAsStream(FEED_XML)); Feed view = EntityUtil.getClusterView(feed, "testCluster"); Assert.assertEquals(view.getClusters().getClusters().size(), 1); Assert.assertEquals(view.getClusters().getClusters().get(0).getName(), "testCluster"); view = EntityUtil.getClusterView(feed, "backupCluster"); Assert.assertEquals(view.getClusters().getClusters().size(), 2); }