Tabnine Logo
MetaService
Code IndexAdd Tabnine to your IDE (free)

How to use
MetaService
in
com.enioka.admin

Best Java code snippets using com.enioka.admin.MetaService (Showing top 20 results out of 315)

origin: enioka/jqm

  @Override
  int doWork()
  {
    try (DbConn cnx = Helpers.getNewDbSession())
    {
      jqmlogger.info("Existing nodes: " + MetaService.getNodes(cnx).size());
      return 0;
    }
    catch (Exception e)
    {
      jqmlogger.error("Could not fetch node count", e);
      return 111;
    }
  }
}
origin: com.enioka.jqm/jqm-admin

public static void changeUserPassword(DbConn cnx, String userLogin, String newPassword)
{
  List<RUserDto> dtos = getUsers(cnx, "user_select_by_key", 0, userLogin);
  if (dtos.size() == 0)
  {
    throw new JqmAdminApiUserException("Cannot update the password of a user which does not exist - given login was " + userLogin);
  }
  changeUserPassword(cnx, dtos.get(0).getId(), newPassword);
}
origin: com.enioka.jqm/jqm-admin

public static GlobalParameterDto getGlobalParameter(DbConn cnx, String key)
{
  return getGlobalParameter(cnx, "globalprm_select_by_key", key);
}
origin: enioka/jqm

NodeDto template = MetaService.getNode(cnx, templateName);
NodeDto target = MetaService.getNode(cnx, nodeName);
ArrayList<QueueMappingDto> mappings = new ArrayList<>(MetaService.getQueueMappings(cnx));
List<QueueMappingDto> toRemove = new ArrayList<>(10);
List<QueueMappingDto> toAdd = new ArrayList<>(10);
MetaService.syncQueueMappings(cnx, mappings);
target.setRootLogLevel(template.getRootLogLevel());
target.setTmpDirectory(template.getTmpDirectory());
MetaService.upsertNode(cnx, target);
origin: enioka/jqm

List<NodeDto> nodes = MetaService.getNodes(cnx);
NodeDto node = null;
Assert.assertEquals("value1", MetaService.getGlobalParameter(cnx, "key1").getValue());
for (QueueMappingDto qm : MetaService.getQueueMappings(cnx))
QueueDto q = MetaService.getQueue(cnx, queueMapping.getQueueId());
Assert.assertTrue(q.isDefaultQueue());
Assert.assertEquals("test1", MetaService.getJndiObjectResource(cnx, "string/test1").getParameters().get("STRING"));
nodes = MetaService.getNodes(cnx);
node = null;
for (NodeDto dto : nodes)
Assert.assertEquals("value2", MetaService.getGlobalParameter(cnx, "key1").getValue());
for (QueueMappingDto qm : MetaService.getQueueMappings(cnx))
q = MetaService.getQueue(cnx, queueMapping.getQueueId());
Assert.assertFalse(q.isDefaultQueue());
Assert.assertEquals("test1_2", MetaService.getJndiObjectResource(cnx, "string/test1").getParameters().get("STRING"));
nodes = MetaService.getNodes(cnx);
node = null;
for (NodeDto dto : nodes)
origin: enioka/jqm

public static void syncNodes(DbConn cnx, List<NodeDto> dtos)
{
  for (NodeDto existing : getNodes(cnx))
  {
    boolean foundInNewSet = false;
    for (NodeDto newdto : dtos)
    {
      if (newdto.getId() != null && newdto.getId().equals(existing.getId()))
      {
        foundInNewSet = true;
        break;
      }
    }
    if (!foundInNewSet)
    {
      deleteQueue(cnx, existing.getId());
    }
  }
  for (NodeDto dto : dtos)
  {
    upsertNode(cnx, dto);
  }
}
origin: enioka/jqm

  @Test
  public void testTemplate() throws Exception
  {
    NodeDto template = MetaService.getNode(cnx, TestHelpers.nodeMix.getId());
    template.setPort(123);
    MetaService.upsertNode(cnx, template);
    cnx.commit();

    NodeDto target = MetaService.getNode(cnx, TestHelpers.node.getId());
    Assert.assertEquals(3, MetaService.getNodeQueueMappings(cnx, target.getId()).size());

    // Capital letter -> should be ignored.
    Main.runCommand(new String[] { "Install-NodeTemPlate", "-t", TestHelpers.nodeMix.getName(), "-n", TestHelpers.node.getName() });

    target = MetaService.getNode(cnx, TestHelpers.node.getId());

    Assert.assertEquals(template.getPort(), target.getPort());
    Assert.assertEquals(1, MetaService.getNodeQueueMappings(cnx, target.getId()).size());
  }
}
origin: com.enioka.jqm/jqm-admin

public static void syncJndiObjectResource(DbConn cnx, List<JndiObjectResourceDto> dtos)
{
  for (JndiObjectResourceDto existing : getJndiObjectResource(cnx))
  {
    boolean foundInNewSet = false;
    for (JndiObjectResourceDto newdto : dtos)
    {
      if (newdto.getId() != null && newdto.getId().equals(existing.getId()))
      {
        foundInNewSet = true;
        break;
      }
    }
    if (!foundInNewSet)
    {
      deleteJndiObjectResource(cnx, existing.getId());
    }
  }
  for (JndiObjectResourceDto dto : dtos)
  {
    upsertJndiObjectResource(cnx, dto);
  }
}
origin: com.enioka.jqm/jqm-admin

public static void syncQueueMappings(DbConn cnx, List<QueueMappingDto> dtos)
{
  for (QueueMappingDto existing : getQueueMappings(cnx))
  {
    boolean foundInNewSet = false;
    for (QueueMappingDto newdto : dtos)
    {
      if (newdto.getId() != null && newdto.getId().equals(existing.getId()))
      {
        foundInNewSet = true;
        break;
      }
    }
    if (!foundInNewSet)
    {
      deleteQueueMapping(cnx, existing.getId());
    }
  }
  for (QueueMappingDto dto : dtos)
  {
    upsertQueueMapping(cnx, dto);
  }
}
origin: com.enioka.jqm/jqm-admin

public static void syncJobDefs(DbConn cnx, List<JobDefDto> dtos)
{
  for (JobDefDto existing : getJobDef(cnx))
  {
    boolean foundInNewSet = false;
    for (JobDefDto newdto : dtos)
    {
      if (newdto.getId() != null && newdto.getId().equals(existing.getId()))
      {
        foundInNewSet = true;
        break;
      }
    }
    if (!foundInNewSet)
    {
      deleteJobDef(cnx, existing.getId());
    }
  }
  for (JobDefDto dto : dtos)
  {
    upsertJobDef(cnx, dto);
  }
}
origin: enioka/jqm

MetaService.upsertJndiObjectResource(cnx, or);
JndiObjectResourceDto tmp = MetaService.getJndiObjectResource(cnx, "jndi/resource");
Assert.assertEquals("val1", tmp.getParameters().get("prm1"));
MetaService.upsertJndiObjectResource(cnx, tmp);
tmp = MetaService.getJndiObjectResource(cnx, "jndi/resource");
Assert.assertEquals("val2", tmp.getParameters().get("prm1"));
MetaService.syncJndiObjectResource(cnx, dtos);
tmp = MetaService.getJndiObjectResource(cnx, "jndi/resource");
Assert.assertEquals("val2", tmp.getParameters().get("prm1"));
MetaService.syncJndiObjectResource(cnx, dtos);
tmp = MetaService.getJndiObjectResource(cnx, "jndi/resource");
Assert.assertEquals("val3", tmp.getParameters().get("prm1"));
MetaService.syncJndiObjectResource(cnx, dtos);
tmp = MetaService.getJndiObjectResource(cnx, "jndi/resource");
Assert.assertEquals("val3", tmp.getParameters().get("prm1"));
Assert.assertEquals("val1", tmp.getParameters().get("prm2"));
MetaService.syncJndiObjectResource(cnx, dtos);
tmp = MetaService.getJndiObjectResource(cnx, "jndi/resource");
Assert.assertEquals("val3", tmp.getParameters().get("prm1"));
Assert.assertEquals(1, tmp.getParameters().size());
MetaService.syncJndiObjectResource(cnx, dtos);
Assert.assertEquals(0, MetaService.getJndiObjectResource(cnx).size());
origin: com.enioka.jqm/jqm-admin

public static void syncGlobalParameters(DbConn cnx, List<GlobalParameterDto> dtos)
{
  for (GlobalParameterDto existing : getGlobalParameter(cnx))
  {
    boolean foundInNewSet = false;
    for (GlobalParameterDto newdto : dtos)
    {
      if (newdto.getId() != null && newdto.getId().equals(existing.getId()))
      {
        foundInNewSet = true;
        break;
      }
    }
    if (!foundInNewSet)
    {
      deleteGlobalParameter(cnx, existing.getId());
    }
  }
  for (GlobalParameterDto dto : dtos)
  {
    upsertGlobalParameter(cnx, dto);
  }
}
origin: enioka/jqm

public static void syncRoles(DbConn cnx, List<RRoleDto> dtos)
{
  for (RRoleDto existing : getRoles(cnx))
  {
    boolean foundInNewSet = false;
    for (RRoleDto newdto : dtos)
    {
      if (newdto.getId() != null && newdto.getId().equals(existing.getId()))
      {
        foundInNewSet = true;
        break;
      }
    }
    if (!foundInNewSet)
    {
      deleteRole(cnx, existing.getId(), false);
    }
  }
  for (RRoleDto dto : dtos)
  {
    upsertRole(cnx, dto);
  }
}
origin: enioka/jqm

JobDefDto dto = MetaService.getJobDef(cnx, i);
Assert.assertEquals(0, dto.getParameters().size());
MetaService.upsertJobDef(cnx, dto);
cnx.commit();
JobDefDto dto2 = MetaService.getJobDef(cnx, i);
Assert.assertEquals(1, dto2.getSchedules().size());
Assert.assertEquals("5 * * * *", dto2.getSchedules().get(0).getCronExpression());
MetaService.upsertJobDef(cnx, dto);
cnx.commit();
dto2 = MetaService.getJobDef(cnx, i);
Assert.assertEquals(update.getTimeInMillis(), dto2.getSchedules().get(0).getLastUpdated().getTimeInMillis());
MetaService.upsertJobDef(cnx, dto2);
cnx.commit();
dto2 = MetaService.getJobDef(cnx, i);
Assert.assertEquals(1, dto2.getSchedules().get(0).getParameters().size());
Assert.assertNotEquals(update.getTimeInMillis(), dto2.getSchedules().get(0).getLastUpdated().getTimeInMillis());
MetaService.upsertJobDef(cnx, dto2);
cnx.commit();
dto2 = MetaService.getJobDef(cnx, i);
Assert.assertEquals(0, dto2.getSchedules().get(0).getParameters().size());
MetaService.upsertJobDef(cnx, dto2);
cnx.commit();
dto2 = MetaService.getJobDef(cnx, i);
origin: enioka/jqm

  @Override
  int doWork()
  {
    try (DbConn cnx = Helpers.getNewDbSession())
    {
      Helpers.createUserIfMissing(cnx, login, password, "created through CLI", roles.toArray(new String[roles.size()]));
      MetaService.changeUserPassword(cnx, login, password);
      cnx.commit();
      return 0;
    }
  }
}
origin: enioka/jqm

public static List<RRoleDto> getRoles(DbConn cnx)
{
  return getRoles(cnx, "role_select_all", 0);
}
origin: enioka/jqm

@Test // Commented - waiting for one minute is long.
public void testSimpleSchedule()
{
  int id = CreationTools.createJobDef(null, true, "pyl.EngineApiSendMsg", null, "jqm-tests/jqm-test-pyl/target/test.jar",
      TestHelpers.qVip, 42, "MarsuApplication", null, "Franquin", "ModuleMachin", "other", "other", true, cnx);
  int scheduleId = JobRequest.create("MarsuApplication", "test user").setRecurrence("* * * * *").addParameter("key1", "value1")
      .submit();
  JobDef jd_client = JqmClientFactory.getClient().getJobDefinition("MarsuApplication");
  Assert.assertEquals(id, (int) jd_client.getId());
  Assert.assertEquals(1, jd_client.getSchedules().size());
  Assert.assertEquals(scheduleId, jd_client.getSchedules().get(0).getId());
  Assert.assertEquals("* * * * *", jd_client.getSchedules().get(0).getCronExpression());
  addAndStartEngine();
  TestHelpers.waitFor(1, 150000, cnx);
  Assert.assertEquals(1, TestHelpers.getOkCount(cnx));
  JobDefDto jd = MetaService.getJobDef(cnx, id);
  Assert.assertEquals(1, jd.getSchedules().size());
  JqmClientFactory.getClient().removeRecurrence(scheduleId);
  jd = MetaService.getJobDef(cnx, id);
  Assert.assertEquals(0, jd.getSchedules().size());
  Assert.assertTrue(Query.create().run().get(0).isFromSchedule());
}
origin: com.enioka.jqm/jqm-service

NodeDto template = MetaService.getNode(cnx, templateNode);
NodeDto target = MetaService.getNode(cnx, targetNode);
ArrayList<QueueMappingDto> mappings = new ArrayList<QueueMappingDto>(MetaService.getQueueMappings(cnx));
List<QueueMappingDto> toRemove = new ArrayList<QueueMappingDto>(10);
List<QueueMappingDto> toAdd = new ArrayList<QueueMappingDto>(10);
MetaService.syncQueueMappings(cnx, mappings);
target.setRootLogLevel(template.getRootLogLevel());
target.setTmpDirectory(template.getTmpDirectory());
MetaService.upsertNode(cnx, target);
origin: com.enioka.jqm/jqm-admin

public static void syncNodes(DbConn cnx, List<NodeDto> dtos)
{
  for (NodeDto existing : getNodes(cnx))
  {
    boolean foundInNewSet = false;
    for (NodeDto newdto : dtos)
    {
      if (newdto.getId() != null && newdto.getId().equals(existing.getId()))
      {
        foundInNewSet = true;
        break;
      }
    }
    if (!foundInNewSet)
    {
      deleteQueue(cnx, existing.getId());
    }
  }
  for (NodeDto dto : dtos)
  {
    upsertNode(cnx, dto);
  }
}
origin: enioka/jqm

public static void syncJndiObjectResource(DbConn cnx, List<JndiObjectResourceDto> dtos)
{
  for (JndiObjectResourceDto existing : getJndiObjectResource(cnx))
  {
    boolean foundInNewSet = false;
    for (JndiObjectResourceDto newdto : dtos)
    {
      if (newdto.getId() != null && newdto.getId().equals(existing.getId()))
      {
        foundInNewSet = true;
        break;
      }
    }
    if (!foundInNewSet)
    {
      deleteJndiObjectResource(cnx, existing.getId());
    }
  }
  for (JndiObjectResourceDto dto : dtos)
  {
    upsertJndiObjectResource(cnx, dto);
  }
}
com.enioka.adminMetaService

Javadoc

Set of methods to handle metadata.

Most used methods

  • getNodes
  • getQueueMappings
  • upsertNode
  • changeUserPassword
  • getGlobalParameter
  • getJndiObjectResource
  • getJobDef
  • getNode
  • getRoles
  • upsertJndiObjectResource
    Update or insert a resource. Convention is that if dto.id is null, we always insert. If non null, al
  • upsertJobDef
  • addSubElementsToDto
  • upsertJobDef,
  • addSubElementsToDto,
  • deleteAllTransac,
  • deleteGlobalParameter,
  • deleteJndiObjectResource,
  • deleteJobDef,
  • deleteQueue,
  • deleteQueueMapping,
  • deleteRole,
  • deleteUser

Popular in Java

  • Finding current android device location
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getResourceAsStream (ClassLoader)
  • runOnUiThread (Activity)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • Permission (java.security)
    Legacy security code; do not use.
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now